Filename | /usr/share/perl5/DateTime/Format/MySQL.pm |
Statements | Executed 14 statements in 864µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 4.32ms | 14.2ms | BEGIN@11 | DateTime::Format::MySQL::
1 | 1 | 1 | 18µs | 23µs | BEGIN@3 | DateTime::Format::MySQL::
10 | 1 | 1 | 15µs | 15µs | CORE:qr (opcode) | DateTime::Format::MySQL::
1 | 1 | 1 | 9µs | 34µs | BEGIN@5 | DateTime::Format::MySQL::
1 | 1 | 1 | 7µs | 7µs | BEGIN@9 | DateTime::Format::MySQL::
0 | 0 | 0 | 0s | 0s | _fix_2_digit_year | DateTime::Format::MySQL::
0 | 0 | 0 | 0s | 0s | format_date | DateTime::Format::MySQL::
0 | 0 | 0 | 0s | 0s | format_datetime | DateTime::Format::MySQL::
0 | 0 | 0 | 0s | 0s | format_time | DateTime::Format::MySQL::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package DateTime::Format::MySQL; | ||||
2 | |||||
3 | 3 | 32µs | 2 | 27µs | # spent 23µs (18+4) within DateTime::Format::MySQL::BEGIN@3 which was called:
# once (18µs+4µs) by C4::Koha::BEGIN@30 at line 3 # spent 23µs making 1 call to DateTime::Format::MySQL::BEGIN@3
# spent 4µs making 1 call to strict::import |
4 | |||||
5 | 3 | 37µs | 2 | 60µs | # spent 34µs (9+25) within DateTime::Format::MySQL::BEGIN@5 which was called:
# once (9µs+25µs) by C4::Koha::BEGIN@30 at line 5 # spent 34µs making 1 call to DateTime::Format::MySQL::BEGIN@5
# spent 25µs making 1 call to vars::import |
6 | |||||
7 | 1 | 1µs | $VERSION = '0.04'; | ||
8 | |||||
9 | 3 | 380µs | 1 | 7µs | # spent 7µs within DateTime::Format::MySQL::BEGIN@9 which was called:
# once (7µs+0s) by C4::Koha::BEGIN@30 at line 9 # spent 7µs making 1 call to DateTime::Format::MySQL::BEGIN@9 |
10 | use DateTime::Format::Builder | ||||
11 | 11 | 4.01ms | # spent 14.2ms (4.32+9.92) within DateTime::Format::MySQL::BEGIN@11 which was called:
# once (4.32ms+9.92ms) by C4::Koha::BEGIN@30 at line 71 # spent 3.99ms making 1 call to DateTime::Format::Builder::import
# spent 15µs making 10 calls to DateTime::Format::MySQL::CORE:qr, avg 2µs/call | ||
12 | { parse_date => | ||||
13 | { params => [ qw( year month day ) ], | ||||
14 | regex => qr/^(\d{1,4})-(\d\d)-(\d\d)$/, | ||||
15 | }, | ||||
16 | |||||
17 | parse_datetime => | ||||
18 | { params => [ qw( year month day hour minute second ) ], | ||||
19 | regex => qr/^(\d{1,4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$/, | ||||
20 | extra => { time_zone => 'floating' }, | ||||
21 | }, | ||||
22 | |||||
23 | parse_timestamp => | ||||
24 | [ { length => 14, | ||||
25 | params => [ qw( year month day hour minute second ) ], | ||||
26 | regex => qr/^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/, | ||||
27 | extra => { time_zone => 'floating' }, | ||||
28 | }, | ||||
29 | { | ||||
30 | params => [ qw( year month day hour minute second ) ], | ||||
31 | regex => qr/^(\d{1,4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$/, | ||||
32 | extra => { time_zone => 'floating'}, | ||||
33 | }, | ||||
34 | { length => 12, | ||||
35 | params => [ qw( year month day hour minute second ) ], | ||||
36 | regex => qr/^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/, | ||||
37 | extra => { time_zone => 'floating' }, | ||||
38 | postprocess => \&_fix_2_digit_year, | ||||
39 | }, | ||||
40 | { length => 10, | ||||
41 | params => [ qw( year month day hour minute ) ], | ||||
42 | regex => qr/^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/, | ||||
43 | extra => { time_zone => 'floating' }, | ||||
44 | postprocess => \&_fix_2_digit_year, | ||||
45 | }, | ||||
46 | { length => 8, | ||||
47 | params => [ qw( year month day ) ], | ||||
48 | regex => qr/^(\d\d\d\d)(\d\d)(\d\d)$/, | ||||
49 | extra => { time_zone => 'floating' }, | ||||
50 | }, | ||||
51 | { length => 6, | ||||
52 | params => [ qw( year month day ) ], | ||||
53 | regex => qr/^(\d\d)(\d\d)(\d\d)$/, | ||||
54 | extra => { time_zone => 'floating' }, | ||||
55 | postprocess => \&_fix_2_digit_year, | ||||
56 | }, | ||||
57 | { length => 4, | ||||
58 | params => [ qw( year month ) ], | ||||
59 | regex => qr/^(\d\d)(\d\d)$/, | ||||
60 | extra => { time_zone => 'floating' }, | ||||
61 | postprocess => \&_fix_2_digit_year, | ||||
62 | }, | ||||
63 | { length => 2, | ||||
64 | params => [ qw( year ) ], | ||||
65 | regex => qr/^(\d\d)$/, | ||||
66 | extra => { time_zone => 'floating' }, | ||||
67 | postprocess => \&_fix_2_digit_year, | ||||
68 | }, | ||||
69 | ], | ||||
70 | }, | ||||
71 | 3 | 409µs | 1 | 14.2ms | ); # spent 14.2ms making 1 call to DateTime::Format::MySQL::BEGIN@11 |
72 | |||||
73 | sub _fix_2_digit_year | ||||
74 | { | ||||
75 | my %p = @_; | ||||
76 | |||||
77 | $p{parsed}{year} += $p{parsed}{year} <= 69 ? 2000 : 1900; | ||||
78 | } | ||||
79 | |||||
80 | sub format_date | ||||
81 | { | ||||
82 | my ( $self, $dt ) = @_; | ||||
83 | |||||
84 | return $dt->ymd('-'); | ||||
85 | } | ||||
86 | |||||
87 | sub format_time | ||||
88 | { | ||||
89 | my ( $self, $dt ) = @_; | ||||
90 | |||||
91 | return $dt->hms(':'); | ||||
92 | } | ||||
93 | |||||
94 | sub format_datetime | ||||
95 | { | ||||
96 | my ( $self, $dt ) = @_; | ||||
97 | |||||
98 | return $self->format_date($dt) . ' ' . $self->format_time($dt); | ||||
99 | } | ||||
100 | |||||
101 | |||||
102 | 1 | 4µs | 1; | ||
103 | |||||
104 | __END__ | ||||
# spent 15µs within DateTime::Format::MySQL::CORE:qr which was called 10 times, avg 2µs/call:
# 10 times (15µs+0s) by DateTime::Format::MySQL::BEGIN@11 at line 11, avg 2µs/call |