line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Format::DB2; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
166688
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
249
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
18
|
use vars qw ($VERSION); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
195
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.05'; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
21135
|
use DateTime; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use DateTime::Format::Builder |
11
|
|
|
|
|
|
|
( parsers => |
12
|
|
|
|
|
|
|
# 12/13/2005 |
13
|
|
|
|
|
|
|
{ parse_date => |
14
|
|
|
|
|
|
|
{ params => [ qw( year month day ) ], |
15
|
|
|
|
|
|
|
regex => qr!^(\d\d\d\d)-(\d\d)-(\d\d)$!, |
16
|
|
|
|
|
|
|
}, |
17
|
|
|
|
|
|
|
# 12:17:46 |
18
|
|
|
|
|
|
|
parse_time => |
19
|
|
|
|
|
|
|
{ params => [ qw( hour minute second ) ], |
20
|
|
|
|
|
|
|
regex => qr!^(\d\d):(\d\d):(\d\d)$!, |
21
|
|
|
|
|
|
|
extra => { time_zone => 'floating' }, |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
# 2005-12-13-12.19.07.276270 |
24
|
|
|
|
|
|
|
parse_timestamp => |
25
|
|
|
|
|
|
|
[ { params => [ qw( year month day hour minute second nanosecond) ], |
26
|
|
|
|
|
|
|
regex => qr/^(\d\d\d\d)-(\d\d)-(\d\d)-(\d\d)\.(\d\d)\.(\d\d)(\.\d+)?$/, |
27
|
|
|
|
|
|
|
extra => { time_zone => 'floating' }, |
28
|
|
|
|
|
|
|
postprocess => \&_fix_nano |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
{ params => [ qw( year month day hour minute second nanosecond) ], |
31
|
|
|
|
|
|
|
regex => qr/^(\d\d\d\d)-(\d\d)-(\d\d)\s(\d\d):(\d\d):(\d\d)(\.\d+)?$/, |
32
|
|
|
|
|
|
|
extra => { time_zone => 'floating' }, |
33
|
|
|
|
|
|
|
postprocess => \&_fix_nano |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
], |
36
|
|
|
|
|
|
|
parse_datetime => |
37
|
|
|
|
|
|
|
[ { params => [ qw( year month day hour minute second nanosecond) ], |
38
|
|
|
|
|
|
|
regex => qr/^(\d\d\d\d)-(\d\d)-(\d\d)-(\d\d)\.(\d\d)\.(\d\d)(\.\d+)?$/, |
39
|
|
|
|
|
|
|
extra => { time_zone => 'floating' }, |
40
|
|
|
|
|
|
|
postprocess => \&_fix_nano |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
{ params => [ qw( year month day hour minute second nanosecond) ], |
43
|
|
|
|
|
|
|
regex => qr/^(\d\d\d\d)-(\d\d)-(\d\d)\s(\d\d):(\d\d):(\d\d)(\.\d+)?$/, |
44
|
|
|
|
|
|
|
extra => { time_zone => 'floating' }, |
45
|
|
|
|
|
|
|
postprocess => \&_fix_nano |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
], |
48
|
|
|
|
|
|
|
}, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _fix_nano |
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
my %p = @_; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$p{parsed}{nanosecond} *= 10**9; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return 1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub format_date |
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
my ( $self, $dt ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $dt->ymd('-'); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub format_time |
68
|
|
|
|
|
|
|
{ |
69
|
|
|
|
|
|
|
my ( $self, $dt ) = @_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return $dt->hms(':'); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub format_timestamp |
75
|
|
|
|
|
|
|
{ |
76
|
|
|
|
|
|
|
my ( $self, $dt ) = @_; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return $self->format_date($dt) . '-' . $dt->hms('.'); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
*format_datetime = *format_timestamp; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |