File: DMDateTime.pm

package info (click to toggle)
libtangram-perl 2.04-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 572 kB
  • ctags: 495
  • sloc: perl: 5,061; makefile: 36
file content (32 lines) | stat: -rw-r--r-- 602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# (c) Sound Object Logic 2000-2001

package Tangram::DMDateTime;

use strict;
use Tangram::RawDateTime;
use base qw( Tangram::RawDateTime );

$Tangram::Schema::TYPES{dmdatetime} = Tangram::DMDateTime->new;

#
# Convert SQL DATETIME format to Date::Manip internal format (0):
#
#   2000-07-06 13:55:23  --> 20000706135523
#
# save is not needed, because most DBMs can directly interpret Date::Manip
# format. 
#
sub get_importer
{
  my ($self) = @_;
  my $name = $self->{name};

  return sub {
	my ($obj, $row, $context) = @_;
	my $val = shift @$row;
	$val =~ s/[-: ]//g;
	$obj{$name} = $val;
  }
}

1;