blib/lib/DateTime/Format/DB2.pm

filter: Statementstmt 100% 24 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 100% 35 / 35 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 package DateTime::Format::DB2;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use vars qw ($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 $VERSION = '0.06';
8  
9 3 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 use DateTime::Format::Builder
11 3 ▶ ( parsers =>
Subroutine BEGIN: called CC=1 SCAR=0.0
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 3 );
50  
51 sub _fix_nano
52 3 ▶{
Subroutine _fix_nano: called CC=1 SCAR=0.0
53 3 my %p = @_;
54  
55 3 $p{parsed}{nanosecond} = int($p{parsed}{nanosecond} * 10**9);
56  
57 3 return 1;
58 }
59  
60 sub format_date
61 2 ▶{
Subroutine format_date: called CC=1 SCAR=0.0
Pod documented
62 2 my ( $self, $dt ) = @_;
63  
64 2 return $dt->ymd('-');
65 }
66  
67 sub format_time
68 1 ▶{
Subroutine format_time: called CC=1 SCAR=0.0
Pod documented
69 1 my ( $self, $dt ) = @_;
70  
71 1 return $dt->hms(':');
72 }
73  
74 sub format_timestamp
75 1 ▶{
Subroutine format_timestamp: called CC=1 SCAR=0.0
Pod documented
76 1 my ( $self, $dt ) = @_;
77  
78 1 return $self->format_date($dt) . '-' . $dt->hms('.');
79 }
80  
81 3 *format_datetime = *format_timestamp;
82  
83 3 1;
84  
85 __END__
↑ Summary