File | /usr/local/lib/perl5/site_perl/5.10.1/DateTime/Format/Strptime.pm |
Statements Executed | 1019 |
Statement Execution Time | 8.91ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
5 | 1 | 1 | 1.49ms | 6.34ms | _build_parser | DateTime::Format::Strptime::
5 | 1 | 1 | 1.04ms | 20.5ms | parse_datetime | DateTime::Format::Strptime::
335 | 13 | 7 | 451µs | 451µs | CORE:match (opcode) | DateTime::Format::Strptime::
380 | 76 | 2 | 348µs | 348µs | CORE:subst (opcode) | DateTime::Format::Strptime::
5 | 1 | 1 | 323µs | 7.57ms | new | DateTime::Format::Strptime::
5 | 1 | 1 | 67µs | 28.1ms | strptime | DateTime::Format::Strptime::
8 | 1 | 1 | 63µs | 1.64ms | strftime | DateTime::Format::Strptime::
55 | 2 | 2 | 44µs | 44µs | CORE:substcont (opcode) | DateTime::Format::Strptime::
1 | 1 | 1 | 14µs | 18µs | BEGIN@3 | DateTime::Format::Strptime::
1 | 1 | 1 | 14µs | 18µs | BEGIN@540 | DateTime::Format::Strptime::
1 | 1 | 1 | 13µs | 15µs | BEGIN@550 | DateTime::Format::Strptime::
1 | 1 | 1 | 8µs | 41µs | BEGIN@9 | DateTime::Format::Strptime::
1 | 1 | 1 | 8µs | 64µs | BEGIN@8 | DateTime::Format::Strptime::
1 | 1 | 1 | 8µs | 22µs | BEGIN@11 | DateTime::Format::Strptime::
1 | 1 | 1 | 7µs | 113µs | BEGIN@12 | DateTime::Format::Strptime::
1 | 1 | 1 | 4µs | 4µs | BEGIN@5 | DateTime::Format::Strptime::
1 | 1 | 1 | 4µs | 4µs | BEGIN@7 | DateTime::Format::Strptime::
1 | 1 | 1 | 3µs | 3µs | BEGIN@6 | DateTime::Format::Strptime::
10 | 2 | 2 | 3µs | 3µs | CORE:sort (opcode) | DateTime::Format::Strptime::
0 | 0 | 0 | 0s | 0s | errmsg | DateTime::Format::Strptime::
0 | 0 | 0 | 0s | 0s | format_datetime | DateTime::Format::Strptime::
0 | 0 | 0 | 0s | 0s | format_duration | DateTime::Format::Strptime::
0 | 0 | 0 | 0s | 0s | local_carp | DateTime::Format::Strptime::
0 | 0 | 0 | 0s | 0s | local_croak | DateTime::Format::Strptime::
0 | 0 | 0 | 0s | 0s | locale | DateTime::Format::Strptime::
0 | 0 | 0 | 0s | 0s | parse_duration | DateTime::Format::Strptime::
0 | 0 | 0 | 0s | 0s | pattern | DateTime::Format::Strptime::
0 | 0 | 0 | 0s | 0s | time_zone | DateTime::Format::Strptime::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package DateTime::Format::Strptime; | ||||
2 | |||||
3 | 3 | 22µs | 2 | 21µs | # spent 18µs (14+3) within DateTime::Format::Strptime::BEGIN@3 which was called
# once (14µs+3µs) by SimpleDB::Class::SQL::BEGIN@20 at line 3 # spent 18µs making 1 call to DateTime::Format::Strptime::BEGIN@3
# spent 3µs making 1 call to strict::import |
4 | |||||
5 | 3 | 17µs | 1 | 4µs | # spent 4µs within DateTime::Format::Strptime::BEGIN@5 which was called
# once (4µs+0s) by SimpleDB::Class::SQL::BEGIN@20 at line 5 # spent 4µs making 1 call to DateTime::Format::Strptime::BEGIN@5 |
6 | 3 | 18µs | 1 | 3µs | # spent 3µs within DateTime::Format::Strptime::BEGIN@6 which was called
# once (3µs+0s) by SimpleDB::Class::SQL::BEGIN@20 at line 6 # spent 3µs making 1 call to DateTime::Format::Strptime::BEGIN@6 |
7 | 3 | 22µs | 1 | 4µs | # spent 4µs within DateTime::Format::Strptime::BEGIN@7 which was called
# once (4µs+0s) by SimpleDB::Class::SQL::BEGIN@20 at line 7 # spent 4µs making 1 call to DateTime::Format::Strptime::BEGIN@7 |
8 | 3 | 23µs | 2 | 120µs | # spent 64µs (8+56) within DateTime::Format::Strptime::BEGIN@8 which was called
# once (8µs+56µs) by SimpleDB::Class::SQL::BEGIN@20 at line 8 # spent 64µs making 1 call to DateTime::Format::Strptime::BEGIN@8
# spent 56µs making 1 call to Exporter::import |
9 | 3 | 22µs | 2 | 74µs | # spent 41µs (8+33) within DateTime::Format::Strptime::BEGIN@9 which was called
# once (8µs+33µs) by SimpleDB::Class::SQL::BEGIN@20 at line 9 # spent 41µs making 1 call to DateTime::Format::Strptime::BEGIN@9
# spent 33µs making 1 call to Exporter::import |
10 | |||||
11 | 3 | 23µs | 2 | 36µs | # spent 22µs (8+14) within DateTime::Format::Strptime::BEGIN@11 which was called
# once (8µs+14µs) by SimpleDB::Class::SQL::BEGIN@20 at line 11 # spent 22µs making 1 call to DateTime::Format::Strptime::BEGIN@11
# spent 14µs making 1 call to Exporter::import |
12 | 3 | 2.57ms | 2 | 218µs | # spent 113µs (7+105) within DateTime::Format::Strptime::BEGIN@12 which was called
# once (7µs+105µs) by SimpleDB::Class::SQL::BEGIN@20 at line 12 # spent 113µs making 1 call to DateTime::Format::Strptime::BEGIN@12
# spent 105µs making 1 call to vars::import |
13 | |||||
14 | 1 | 19µs | @ISA = 'Exporter'; | ||
15 | 1 | 500ns | $VERSION = '1.1000'; | ||
16 | 1 | 1µs | @EXPORT_OK = qw( &strftime &strptime ); | ||
17 | 1 | 200ns | @EXPORT = (); | ||
18 | |||||
19 | 1 | 202µs | %ZONEMAP = ( | ||
20 | 'A' => '+0100', 'ACDT' => '+1030', 'ACST' => '+0930', | ||||
21 | 'ADT' => 'Ambiguous', 'AEDT' => '+1100', 'AES' => '+1000', | ||||
22 | 'AEST' => '+1000', 'AFT' => '+0430', 'AHDT' => '-0900', | ||||
23 | 'AHST' => '-1000', 'AKDT' => '-0800', 'AKST' => '-0900', | ||||
24 | 'AMST' => '+0400', 'AMT' => '+0400', 'ANAST' => '+1300', | ||||
25 | 'ANAT' => '+1200', 'ART' => '-0300', 'AST' => 'Ambiguous', | ||||
26 | 'AT' => '-0100', 'AWST' => '+0800', 'AZOST' => '+0000', | ||||
27 | 'AZOT' => '-0100', 'AZST' => '+0500', 'AZT' => '+0400', | ||||
28 | 'B' => '+0200', 'BADT' => '+0400', 'BAT' => '+0600', | ||||
29 | 'BDST' => '+0200', 'BDT' => '+0600', 'BET' => '-1100', | ||||
30 | 'BNT' => '+0800', 'BORT' => '+0800', 'BOT' => '-0400', | ||||
31 | 'BRA' => '-0300', 'BST' => 'Ambiguous', 'BT' => 'Ambiguous', | ||||
32 | 'BTT' => '+0600', 'C' => '+0300', 'CAST' => '+0930', | ||||
33 | 'CAT' => 'Ambiguous', 'CCT' => 'Ambiguous', 'CDT' => 'Ambiguous', | ||||
34 | 'CEST' => '+0200', 'CET' => '+0100', 'CETDST' => '+0200', | ||||
35 | 'CHADT' => '+1345', 'CHAST' => '+1245', 'CKT' => '-1000', | ||||
36 | 'CLST' => '-0300', 'CLT' => '-0400', 'COT' => '-0500', | ||||
37 | 'CST' => 'Ambiguous', 'CSuT' => '+1030', 'CUT' => '+0000', | ||||
38 | 'CVT' => '-0100', 'CXT' => '+0700', 'ChST' => '+1000', | ||||
39 | 'D' => '+0400', 'DAVT' => '+0700', 'DDUT' => '+1000', | ||||
40 | 'DNT' => '+0100', 'DST' => '+0200', 'E' => '+0500', | ||||
41 | 'EASST' => '-0500', 'EAST' => 'Ambiguous', 'EAT' => '+0300', | ||||
42 | 'ECT' => 'Ambiguous', 'EDT' => 'Ambiguous', 'EEST' => '+0300', | ||||
43 | 'EET' => '+0200', 'EETDST' => '+0300', 'EGST' => '+0000', | ||||
44 | 'EGT' => '-0100', 'EMT' => '+0100', 'EST' => 'Ambiguous', | ||||
45 | 'ESuT' => '+1100', 'F' => '+0600', 'FDT' => 'Ambiguous', | ||||
46 | 'FJST' => '+1300', 'FJT' => '+1200', 'FKST' => '-0300', | ||||
47 | 'FKT' => '-0400', 'FST' => 'Ambiguous', 'FWT' => '+0100', | ||||
48 | 'G' => '+0700', 'GALT' => '-0600', 'GAMT' => '-0900', | ||||
49 | 'GEST' => '+0500', 'GET' => '+0400', 'GFT' => '-0300', | ||||
50 | 'GILT' => '+1200', 'GMT' => '+0000', 'GST' => 'Ambiguous', | ||||
51 | 'GT' => '+0000', 'GYT' => '-0400', 'GZ' => '+0000', | ||||
52 | 'H' => '+0800', 'HAA' => '-0300', 'HAC' => '-0500', | ||||
53 | 'HAE' => '-0400', 'HAP' => '-0700', 'HAR' => '-0600', | ||||
54 | 'HAT' => '-0230', 'HAY' => '-0800', 'HDT' => '-0930', | ||||
55 | 'HFE' => '+0200', 'HFH' => '+0100', 'HG' => '+0000', | ||||
56 | 'HKT' => '+0800', 'HL' => 'local', 'HNA' => '-0400', | ||||
57 | 'HNC' => '-0600', 'HNE' => '-0500', 'HNP' => '-0800', | ||||
58 | 'HNR' => '-0700', 'HNT' => '-0330', 'HNY' => '-0900', | ||||
59 | 'HOE' => '+0100', 'HST' => '-1000', 'I' => '+0900', | ||||
60 | 'ICT' => '+0700', 'IDLE' => '+1200', 'IDLW' => '-1200', | ||||
61 | 'IDT' => 'Ambiguous', 'IOT' => '+0500', 'IRDT' => '+0430', | ||||
62 | 'IRKST' => '+0900', 'IRKT' => '+0800', 'IRST' => '+0430', | ||||
63 | 'IRT' => '+0330', 'IST' => 'Ambiguous', 'IT' => '+0330', | ||||
64 | 'ITA' => '+0100', 'JAVT' => '+0700', 'JAYT' => '+0900', | ||||
65 | 'JST' => '+0900', 'JT' => '+0700', 'K' => '+1000', | ||||
66 | 'KDT' => '+1000', 'KGST' => '+0600', 'KGT' => '+0500', | ||||
67 | 'KOST' => '+1200', 'KRAST' => '+0800', 'KRAT' => '+0700', | ||||
68 | 'KST' => '+0900', 'L' => '+1100', 'LHDT' => '+1100', | ||||
69 | 'LHST' => '+1030', 'LIGT' => '+1000', 'LINT' => '+1400', | ||||
70 | 'LKT' => '+0600', 'LST' => 'local', 'LT' => 'local', | ||||
71 | 'M' => '+1200', 'MAGST' => '+1200', 'MAGT' => '+1100', | ||||
72 | 'MAL' => '+0800', 'MART' => '-0930', 'MAT' => '+0300', | ||||
73 | 'MAWT' => '+0600', 'MDT' => '-0600', 'MED' => '+0200', | ||||
74 | 'MEDST' => '+0200', 'MEST' => '+0200', 'MESZ' => '+0200', | ||||
75 | 'MET' => 'Ambiguous', 'MEWT' => '+0100', 'MEX' => '-0600', | ||||
76 | 'MEZ' => '+0100', 'MHT' => '+1200', 'MMT' => '+0630', | ||||
77 | 'MPT' => '+1000', 'MSD' => '+0400', 'MSK' => '+0300', | ||||
78 | 'MSKS' => '+0400', 'MST' => '-0700', 'MT' => '+0830', | ||||
79 | 'MUT' => '+0400', 'MVT' => '+0500', 'MYT' => '+0800', | ||||
80 | 'N' => '-0100', 'NCT' => '+1100', 'NDT' => '-0230', | ||||
81 | 'NFT' => 'Ambiguous', 'NOR' => '+0100', 'NOVST' => '+0700', | ||||
82 | 'NOVT' => '+0600', 'NPT' => '+0545', 'NRT' => '+1200', | ||||
83 | 'NST' => 'Ambiguous', 'NSUT' => '+0630', 'NT' => '-1100', | ||||
84 | 'NUT' => '-1100', 'NZDT' => '+1300', 'NZST' => '+1200', | ||||
85 | 'NZT' => '+1200', 'O' => '-0200', 'OESZ' => '+0300', | ||||
86 | 'OEZ' => '+0200', 'OMSST' => '+0700', 'OMST' => '+0600', | ||||
87 | 'OZ' => 'local', 'P' => '-0300', 'PDT' => '-0700', | ||||
88 | 'PET' => '-0500', 'PETST' => '+1300', 'PETT' => '+1200', | ||||
89 | 'PGT' => '+1000', 'PHOT' => '+1300', 'PHT' => '+0800', | ||||
90 | 'PKT' => '+0500', 'PMDT' => '-0200', 'PMT' => '-0300', | ||||
91 | 'PNT' => '-0830', 'PONT' => '+1100', 'PST' => 'Ambiguous', | ||||
92 | 'PWT' => '+0900', 'PYST' => '-0300', 'PYT' => '-0400', | ||||
93 | 'Q' => '-0400', 'R' => '-0500', 'R1T' => '+0200', | ||||
94 | 'R2T' => '+0300', 'RET' => '+0400', 'ROK' => '+0900', | ||||
95 | 'S' => '-0600', 'SADT' => '+1030', 'SAST' => 'Ambiguous', | ||||
96 | 'SBT' => '+1100', 'SCT' => '+0400', 'SET' => '+0100', | ||||
97 | 'SGT' => '+0800', 'SRT' => '-0300', 'SST' => 'Ambiguous', | ||||
98 | 'SWT' => '+0100', 'T' => '-0700', 'TFT' => '+0500', | ||||
99 | 'THA' => '+0700', 'THAT' => '-1000', 'TJT' => '+0500', | ||||
100 | 'TKT' => '-1000', 'TMT' => '+0500', 'TOT' => '+1300', | ||||
101 | 'TRUT' => '+1000', 'TST' => '+0300', 'TUC ' => '+0000', | ||||
102 | 'TVT' => '+1200', 'U' => '-0800', 'ULAST' => '+0900', | ||||
103 | 'ULAT' => '+0800', 'USZ1' => '+0200', 'USZ1S' => '+0300', | ||||
104 | 'USZ3' => '+0400', 'USZ3S' => '+0500', 'USZ4' => '+0500', | ||||
105 | 'USZ4S' => '+0600', 'USZ5' => '+0600', 'USZ5S' => '+0700', | ||||
106 | 'USZ6' => '+0700', 'USZ6S' => '+0800', 'USZ7' => '+0800', | ||||
107 | 'USZ7S' => '+0900', 'USZ8' => '+0900', 'USZ8S' => '+1000', | ||||
108 | 'USZ9' => '+1000', 'USZ9S' => '+1100', 'UTZ' => '-0300', | ||||
109 | 'UYT' => '-0300', 'UZ10' => '+1100', 'UZ10S' => '+1200', | ||||
110 | 'UZ11' => '+1200', 'UZ11S' => '+1300', 'UZ12' => '+1200', | ||||
111 | 'UZ12S' => '+1300', 'UZT' => '+0500', 'V' => '-0900', | ||||
112 | 'VET' => '-0400', 'VLAST' => '+1100', 'VLAT' => '+1000', | ||||
113 | 'VTZ' => '-0200', 'VUT' => '+1100', 'W' => '-1000', | ||||
114 | 'WAKT' => '+1200', 'WAST' => 'Ambiguous', 'WAT' => '+0100', | ||||
115 | 'WEST' => '+0100', 'WESZ' => '+0100', 'WET' => '+0000', | ||||
116 | 'WETDST' => '+0100', 'WEZ' => '+0000', 'WFT' => '+1200', | ||||
117 | 'WGST' => '-0200', 'WGT' => '-0300', 'WIB' => '+0700', | ||||
118 | 'WIT' => '+0900', 'WITA' => '+0800', 'WST' => 'Ambiguous', | ||||
119 | 'WTZ' => '-0100', 'WUT' => '+0100', 'X' => '-1100', | ||||
120 | 'Y' => '-1200', 'YAKST' => '+1000', 'YAKT' => '+0900', | ||||
121 | 'YAPT' => '+1000', 'YDT' => '-0800', 'YEKST' => '+0600', | ||||
122 | 'YEKT' => '+0500', 'YST' => '-0900', 'Z' => '+0000', | ||||
123 | ); | ||||
124 | |||||
125 | # spent 7.57ms (323µs+7.24) within DateTime::Format::Strptime::new which was called 5 times, avg 1.51ms/call:
# 5 times (323µs+7.24ms) by DateTime::Format::Strptime::strptime at line 836, avg 1.51ms/call | ||||
126 | 70 | 372µs | my $class = shift; | ||
127 | 1 | 199µs | 5 | 268µs | my %args = validate( @_, { pattern => { type => SCALAR | SCALARREF }, # spent 268µs making 5 calls to Params::Validate::_validate, avg 54µs/call |
128 | time_zone => { type => SCALAR | OBJECT, optional => 1 }, | ||||
129 | locale => { type => SCALAR | OBJECT, default => 'English' }, | ||||
130 | on_error => { type => SCALAR | CODEREF, default => 'undef' }, | ||||
131 | diagnostic => { type => SCALAR, default => 0 }, | ||||
132 | } | ||||
133 | ); | ||||
134 | |||||
135 | croak("The value supplied to on_error must be either 'croak', 'undef' or a code reference.") | ||||
136 | unless ref($args{on_error}) eq 'CODE' | ||||
137 | or $args{on_error} eq 'croak' | ||||
138 | or $args{on_error} eq 'undef'; | ||||
139 | |||||
140 | |||||
141 | # Deal with locale | ||||
142 | unless (ref ($args{locale})) { | ||||
143 | my $locale = DateTime::Locale->load( $args{locale} ); # spent 310µs making 5 calls to DateTime::Locale::load, avg 62µs/call | ||||
144 | |||||
145 | croak("Could not create locale from $args{locale}") unless $locale; | ||||
146 | |||||
147 | $args{_locale} = $locale; | ||||
148 | } else { | ||||
149 | $args{_locale} = $args{locale}; | ||||
150 | ($args{locale}) = ref($args{_locale}) =~/::(\w+)[^:]+$/ | ||||
151 | } | ||||
152 | |||||
153 | if ($args{time_zone}) { | ||||
154 | unless (ref ($args{time_zone})) { | ||||
155 | $args{time_zone} = DateTime::TimeZone->new( name => $args{time_zone} ); | ||||
156 | |||||
157 | croak("Could not create time zone from $args{time_zone}") unless $args{time_zone}; | ||||
158 | } | ||||
159 | $args{set_time_zone} = $args{time_zone}; | ||||
160 | } else { | ||||
161 | $args{time_zone} = DateTime::TimeZone->new( name => 'floating' ); # spent 319µs making 5 calls to DateTime::TimeZone::new, avg 64µs/call | ||||
162 | $args{set_time_zone} = ''; | ||||
163 | } | ||||
164 | |||||
165 | |||||
166 | my $self = bless \%args, $class; | ||||
167 | |||||
168 | |||||
169 | # Deal with the parser | ||||
170 | $self->{parser} = $self->_build_parser($args{pattern}); # spent 6.34ms making 5 calls to DateTime::Format::Strptime::_build_parser, avg 1.27ms/call | ||||
171 | if ($self->{parser}=~/(%\{\w+\}|%\w)/ and $args{pattern} !~ /\%$1/) { # spent 10µs making 5 calls to DateTime::Format::Strptime::CORE:match, avg 2µs/call | ||||
172 | croak("Unidentified token in pattern: $1 in $self->{pattern}"); | ||||
173 | } | ||||
174 | |||||
175 | return $self; | ||||
176 | } | ||||
177 | |||||
178 | sub pattern { | ||||
179 | my $self = shift; | ||||
180 | my $pattern = shift; | ||||
181 | |||||
182 | if ($pattern) { | ||||
183 | my $possible_parser = $self->_build_parser($pattern); | ||||
184 | if ($possible_parser=~/(%\{\w+\}|%\w)/ and $pattern !~ /\%$1/) { | ||||
185 | $self->local_carp("Unidentified token in pattern: $1 in $pattern. Leaving old pattern intact.") and return undef; | ||||
186 | } else { | ||||
187 | $self->{parser} = $possible_parser; | ||||
188 | $self->{pattern} = $pattern; | ||||
189 | } | ||||
190 | } | ||||
191 | return $self->{pattern}; | ||||
192 | } | ||||
193 | |||||
194 | sub locale { | ||||
195 | my $self = shift; | ||||
196 | my $locale = shift; | ||||
197 | |||||
198 | if ($locale) { | ||||
199 | my $possible_locale = DateTime::Locale->load( $locale ); | ||||
200 | unless ($possible_locale) { | ||||
201 | $self->local_carp("Could not create locale from $locale. Leaving old locale intact.") and return undef; | ||||
202 | } else { | ||||
203 | $self->{locale} = $locale; | ||||
204 | $self->{_locale} = $possible_locale; | ||||
205 | # When the locale changes we need to rebuild the parser | ||||
206 | $self->{parser} = $self->_build_parser($self->{pattern}); | ||||
207 | } | ||||
208 | } | ||||
209 | return $self->{locale}; | ||||
210 | } | ||||
211 | |||||
212 | sub time_zone { | ||||
213 | my $self = shift; | ||||
214 | my $time_zone = shift; | ||||
215 | |||||
216 | if ($time_zone) { | ||||
217 | my $possible_time_zone = DateTime::TimeZone->new( name => $time_zone ); | ||||
218 | unless ($possible_time_zone) { | ||||
219 | $self->local_carp("Could not create time zone from $time_zone. Leaving old time zone intact.") and return undef; | ||||
220 | } else { | ||||
221 | $self->{time_zone} = $possible_time_zone; | ||||
222 | $self->{set_time_zone} = $self->{time_zone}; | ||||
223 | } | ||||
224 | } | ||||
225 | return $self->{time_zone}->name; | ||||
226 | } | ||||
227 | |||||
228 | |||||
229 | # spent 20.5ms (1.04+19.4) within DateTime::Format::Strptime::parse_datetime which was called 5 times, avg 4.09ms/call:
# 5 times (1.04ms+19.4ms) by DateTime::Format::Strptime::strptime at line 836, avg 4.09ms/call | ||||
230 | 375 | 956µs | my ( $self, $time_string ) = @_; | ||
231 | |||||
232 | local $^W = undef; | ||||
233 | |||||
234 | # Variables from the parser | ||||
235 | my ( $dow_name, $month_name, $century, $day, | ||||
236 | $hour_24, $hour_12, $doy, $month, | ||||
237 | $minute, $ampm, $second, $week_sun_0, | ||||
238 | $dow_sun_0, $dow_mon_1, $week_mon_1, $year_100, | ||||
239 | $year, $iso_week_year_100, $iso_week_year, | ||||
240 | $epoch, $tz_offset, $timezone, $tz_olson, | ||||
241 | $nanosecond, $ce_year, | ||||
242 | |||||
243 | $doy_dt, $epoch_dt, $use_timezone, $set_time_zone, | ||||
244 | ); | ||||
245 | |||||
246 | # Variables for DateTime | ||||
247 | my ( $Year, $Month, $Day, | ||||
248 | $Hour, $Minute, $Second, $Nanosecond, | ||||
249 | $Am, $Pm | ||||
250 | ) = (); | ||||
251 | |||||
252 | # Run the parser | ||||
253 | my $parser = $self->{parser}; | ||||
254 | 1 | 125µs | 5 | 37µs | eval($parser); # spent 37µs making 5 calls to DateTime::Format::Strptime::CORE:match, avg 7µs/call |
255 | die $@ if $@; | ||||
256 | |||||
257 | if ($self->{diagnostic}) { | ||||
258 | print qq| | ||||
259 | |||||
260 | Entered = $time_string | ||||
261 | Parser = $parser | ||||
262 | |||||
263 | dow_name = $dow_name | ||||
264 | month_name = $month_name | ||||
265 | century = $century | ||||
266 | day = $day | ||||
267 | hour_24 = $hour_24 | ||||
268 | hour_12 = $hour_12 | ||||
269 | doy = $doy | ||||
270 | month = $month | ||||
271 | minute = $minute | ||||
272 | ampm = $ampm | ||||
273 | second = $second | ||||
274 | nanosecond = $nanosecond | ||||
275 | week_sun_0 = $week_sun_0 | ||||
276 | dow_sun_0 = $dow_sun_0 | ||||
277 | dow_mon_1 = $dow_mon_1 | ||||
278 | week_mon_1 = $week_mon_1 | ||||
279 | year_100 = $year_100 | ||||
280 | year = $year | ||||
281 | ce_year = $ce_year | ||||
282 | tz_offset = $tz_offset | ||||
283 | tz_olson = $tz_olson | ||||
284 | timezone = $timezone | ||||
285 | epoch = $epoch | ||||
286 | iso_week_year = $iso_week_year | ||||
287 | iso_week_year_100 = $iso_week_year_100 | ||||
288 | |||||
289 | |; | ||||
290 | |||||
291 | } | ||||
292 | |||||
293 | $self->local_croak("Your datetime does not match your pattern.") and return undef # spent 65µs making 115 calls to DateTime::Format::Strptime::CORE:match, avg 561ns/call | ||||
294 | if ( | ||||
295 | ($self->{parser}=~/\$dow_name\b/ and $dow_name eq '') or | ||||
296 | ($self->{parser}=~/\$month_name\b/ and $month_name eq '') or | ||||
297 | ($self->{parser}=~/\$century\b/ and $century eq '') or | ||||
298 | ($self->{parser}=~/\$day\b/ and $day eq '') or | ||||
299 | ($self->{parser}=~/\$hour_24\b/ and $hour_24 eq '') or | ||||
300 | ($self->{parser}=~/\$hour_12\b/ and $hour_12 eq '') or | ||||
301 | ($self->{parser}=~/\$doy\b/ and $doy eq '') or | ||||
302 | ($self->{parser}=~/\$month\b/ and $month eq '') or | ||||
303 | ($self->{parser}=~/\$minute\b/ and $minute eq '') or | ||||
304 | ($self->{parser}=~/\$ampm\b/ and $ampm eq '') or | ||||
305 | ($self->{parser}=~/\$second\b/ and $second eq '') or | ||||
306 | ($self->{parser}=~/\$nanosecond\b/ and $nanosecond eq '') or | ||||
307 | ($self->{parser}=~/\$week_sun_0\b/ and $week_sun_0 eq '') or | ||||
308 | ($self->{parser}=~/\$dow_sun_0\b/ and $dow_sun_0 eq '') or | ||||
309 | ($self->{parser}=~/\$dow_mon_1\b/ and $dow_mon_1 eq '') or | ||||
310 | ($self->{parser}=~/\$week_mon_1\b/ and $week_mon_1 eq '') or | ||||
311 | ($self->{parser}=~/\$year_100\b/ and $year_100 eq '') or | ||||
312 | ($self->{parser}=~/\$year\b/ and $year eq '') or | ||||
313 | ($self->{parser}=~/\$ce_year\b/ and $ce_year eq '') or | ||||
314 | ($self->{parser}=~/\$tz_offset\b/ and $tz_offset eq '') or | ||||
315 | ($self->{parser}=~/\$tz_olson\b/ and $tz_olson eq '') or | ||||
316 | ($self->{parser}=~/\$timezone\b/ and $timezone eq '') or | ||||
317 | ($self->{parser}=~/\$epoch\b/ and $epoch eq '') | ||||
318 | ); | ||||
319 | |||||
320 | # Create a timezone to work with | ||||
321 | if ($tz_offset) { | ||||
322 | $use_timezone = $tz_offset; | ||||
323 | } | ||||
324 | |||||
325 | if ($timezone) { | ||||
326 | $self->local_croak("I don't recognise the timezone $timezone.") and return undef unless $ZONEMAP{$timezone}; | ||||
327 | $self->local_croak("The timezone '$timezone' is ambiguous.") and return undef if $ZONEMAP{$timezone} eq 'Ambiguous' and not ($tz_offset or $tz_olson); | ||||
328 | $self->local_croak("Your timezones ('$tz_offset' and '$timezone') do not match.") and return undef if $tz_offset and $ZONEMAP{$timezone} ne 'Ambiguous' and $ZONEMAP{$timezone} != $tz_offset; | ||||
329 | $use_timezone = $ZONEMAP{$timezone} if $ZONEMAP{$timezone} ne 'Ambiguous'; | ||||
330 | } | ||||
331 | |||||
332 | if ($tz_olson) { | ||||
333 | my $tz = eval { DateTime::TimeZone->new( name => $tz_olson ) }; | ||||
334 | if( not $tz ){ | ||||
335 | print "Provided olson TZ didn't work ($tz_olson). Attempting to normalize it.\n" if $self->{diagnostic}; | ||||
336 | $tz_olson = ucfirst lc $tz_olson; | ||||
337 | $tz_olson =~ s|([/_])(\w)|$1\U$2|g; | ||||
338 | print " Trying $tz_olson.\n" if $self->{diagnostic}; | ||||
339 | $tz = eval { DateTime::TimeZone->new( name => $tz_olson ) }; | ||||
340 | } | ||||
341 | $self->local_croak("I don't recognise the time zone '$tz_olson'.") and return undef unless $tz; | ||||
342 | $use_timezone = $set_time_zone = $tz; | ||||
343 | |||||
344 | } | ||||
345 | |||||
346 | $use_timezone = $self->{time_zone} unless ($use_timezone); | ||||
347 | |||||
348 | print "Using timezone $use_timezone.\n" if $self->{diagnostic}; | ||||
349 | |||||
350 | # If there's an epoch, we're done. Just need to check all the others | ||||
351 | if ($epoch) { | ||||
352 | $epoch_dt = DateTime->from_epoch( epoch => $epoch, time_zone => $use_timezone ); | ||||
353 | |||||
354 | $Year = $epoch_dt->year; | ||||
355 | $Month = $epoch_dt->month; | ||||
356 | $Day = $epoch_dt->day; | ||||
357 | |||||
358 | $Hour = $epoch_dt->hour; | ||||
359 | $Minute = $epoch_dt->minute; | ||||
360 | $Second = $epoch_dt->second; | ||||
361 | $Nanosecond= $epoch_dt->nanosecond; | ||||
362 | |||||
363 | print $epoch_dt->strftime("Epoch: %D %T.%N\n") if $self->{diagnostic}; | ||||
364 | } | ||||
365 | |||||
366 | # Work out the year we're working with: | ||||
367 | if ($year_100) { | ||||
368 | if ($century) { | ||||
369 | $Year = (($century * 100) - 0) + $year_100; | ||||
370 | } else { | ||||
371 | print "No century, guessing for $year_100" if $self->{diagnostic}; | ||||
372 | if ($year_100 >= 69 and $year_100 <= 99) { | ||||
373 | print "Guessed 1900s" if $self->{diagnostic}; | ||||
374 | $Year = 1900 + $year_100; | ||||
375 | } else { | ||||
376 | print "Guessed 2000s" if $self->{diagnostic}; | ||||
377 | $Year = 2000 + $year_100; | ||||
378 | } | ||||
379 | } | ||||
380 | } | ||||
381 | if ($year) { | ||||
382 | $self->local_croak("Your two year values ($year_100 and $year) do not match.") and return undef if ($Year && ($year != $Year)); | ||||
383 | $Year = $year; | ||||
384 | } | ||||
385 | if ($ce_year) { | ||||
386 | $self->local_croak("Your two year values ($ce_year and $year) do not match.") and return undef if ($Year && ($ce_year != $Year)); | ||||
387 | $Year = $ce_year; | ||||
388 | } | ||||
389 | $self->local_croak("Your year value does not match your epoch.") and return undef if $epoch_dt and $Year and $Year != $epoch_dt->year; | ||||
390 | |||||
391 | |||||
392 | # Work out which month we want | ||||
393 | # Month names | ||||
394 | if ($month_name) { | ||||
395 | $self->local_croak("There is no use providing a month name ($month_name) without providing a year.") and return undef unless $Year; | ||||
396 | my $month_count = 0; | ||||
397 | my $month_number = 0; | ||||
398 | foreach my $month (@{$self->{_locale}->month_names}) { | ||||
399 | $month_count++; | ||||
400 | # use bytes; | ||||
401 | if (lc $month eq lc $month_name) { | ||||
402 | $month_number = $month_count; | ||||
403 | last; | ||||
404 | } | ||||
405 | } | ||||
406 | unless ($month_number) { | ||||
407 | my $month_count = 0; | ||||
408 | foreach my $month (@{$self->{_locale}->month_abbreviations}) { | ||||
409 | $month_count++; | ||||
410 | # use bytes; | ||||
411 | # When abbreviating, sometimes there's a period, sometimes not. | ||||
412 | $month =~ s/\.$//; $month_name =~ s/\.$//; | ||||
413 | if (lc $month eq lc $month_name) { | ||||
414 | $month_number = $month_count; | ||||
415 | last; | ||||
416 | } | ||||
417 | } | ||||
418 | } | ||||
419 | unless ($month_number) { | ||||
420 | $self->local_croak("$month_name is not a recognised month in this locale.") and return undef; | ||||
421 | } | ||||
422 | $Month = $month_number; | ||||
423 | } | ||||
424 | if ($month) { | ||||
425 | $self->local_croak("There is no use providing a month without providing a year.") and return undef unless $Year; | ||||
426 | $self->local_croak("$month is too large to be a month of the year.") and return undef unless $month <= 12; | ||||
427 | $self->local_croak("Your two month values ($month_name and $month) do not match.") and return undef if $Month and $month != $Month; | ||||
428 | $Month = $month; | ||||
429 | } | ||||
430 | $self->local_croak("Your month value does not match your epoch.") and return undef if $epoch_dt and $Month and $Month != $epoch_dt->month; | ||||
431 | if ($doy) { | ||||
432 | $self->local_croak("There is no use providing a day of the year without providing a year.") and return undef unless $Year; | ||||
433 | $doy_dt = eval { | ||||
434 | DateTime->from_day_of_year(year=>$Year, day_of_year=>$doy, time_zone => $use_timezone); | ||||
435 | }; | ||||
436 | $self->local_croak("Day of year $Year-$doy is not valid") and return undef if $@; | ||||
437 | |||||
438 | my $month = $doy_dt->month; | ||||
439 | $self->local_croak("Your day of the year ($doy - in ".$doy_dt->month_name.") is not in your month ($Month)") and return undef if $Month and $month != $Month; | ||||
440 | $Month = $month; | ||||
441 | } | ||||
442 | $self->local_croak("Your day of the year does not match your epoch.") and return undef if $epoch_dt and $doy_dt and $doy_dt->doy != $epoch_dt->doy; | ||||
443 | |||||
444 | |||||
445 | # Day of the month | ||||
446 | $self->local_croak("$day is too large to be a day of the month.") and return undef unless $day <= 31; | ||||
447 | $self->local_croak("Your day of the month ($day) does not match your day of the year.") and return undef if $doy_dt and $day and $day != $doy_dt->day; | ||||
448 | $Day ||= ($day) | ||||
449 | ? $day | ||||
450 | : ($doy_dt) | ||||
451 | ? $doy_dt->day | ||||
452 | : ''; | ||||
453 | if ($Day) { | ||||
454 | $self->local_croak("There is no use providing a day without providing a month and year.") and return undef unless $Year and $Month; | ||||
455 | my $dt = eval { | ||||
456 | DateTime->new(year=>$Year, month=>$Month, day=>$Day, hour=>12, time_zone => $use_timezone); # spent 17.7ms making 5 calls to DateTime::new, avg 3.55ms/call | ||||
457 | }; | ||||
458 | $self->local_croak("Datetime $Year-$Month-$Day is not a valid date") and return undef if $@; | ||||
459 | $self->local_croak("There is no day $Day in $dt->month_name, $Year") and return undef # spent 17µs making 5 calls to DateTime::month, avg 3µs/call | ||||
460 | unless $dt->month == $Month; | ||||
461 | } | ||||
462 | $self->local_croak("Your day of the month does not match your epoch.") and return undef if $epoch_dt and $Day and $Day != $epoch_dt->day; | ||||
463 | |||||
464 | |||||
465 | # Hour of the day | ||||
466 | $self->local_croak("$hour_24 is too large to be an hour of the day.") and return undef unless $hour_24 <= 23; #OK so leap seconds will break! | ||||
467 | $self->local_croak("$hour_12 is too large to be an hour of the day.") and return undef unless $hour_12 <= 12; | ||||
468 | $self->local_croak("You must specify am or pm for 12 hour clocks ($hour_12|$ampm).") and return undef if ($hour_12 && (! $ampm)); | ||||
469 | ($Am, $Pm) = @{$self->{_locale}->am_pms}; # spent 28µs making 5 calls to DateTime::Locale::Base::am_pms, avg 6µs/call | ||||
470 | if (lc $ampm eq lc $Pm) { | ||||
471 | if ($hour_12) { | ||||
472 | $hour_12 += 12 if $hour_12 and $hour_12 != 12; | ||||
473 | } | ||||
474 | $self->local_croak("Your am/pm value ($ampm) does not match your hour ($hour_24)") and return undef if $hour_24 and $hour_24 < 12; | ||||
475 | } elsif (lc $ampm eq lc $Am) { | ||||
476 | if ($hour_12) { | ||||
477 | $hour_12 = 0 if $hour_12 == 12; | ||||
478 | } | ||||
479 | $self->local_croak("Your am/pm value ($ampm) does not match your hour ($hour_24)") and return undef if $hour_24 >= 12; | ||||
480 | } | ||||
481 | if ($hour_12 and $hour_24) { | ||||
482 | $self->local_croak("You have specified mis-matching 12 and 24 hour clock information") and return undef unless $hour_12 == $hour_24; | ||||
483 | $Hour = $hour_24; | ||||
484 | } elsif ($hour_12) { | ||||
485 | $Hour = $hour_12; | ||||
486 | } elsif ($hour_24) { | ||||
487 | $Hour = $hour_24; | ||||
488 | } | ||||
489 | $self->local_croak("Your hour does not match your epoch.") and return undef if $epoch_dt and $Hour and $Hour != $epoch_dt->hour; | ||||
490 | print "Set hour to $Hour.\n" if $self->{diagnostic}; | ||||
491 | |||||
492 | # Minutes | ||||
493 | $self->local_croak("$minute is too large to be a minute.") and return undef unless $minute <= 59; | ||||
494 | $Minute ||= $minute; | ||||
495 | $self->local_croak("Your minute does not match your epoch.") and return undef if $epoch_dt and $Minute and $Minute != $epoch_dt->minute; | ||||
496 | print "Set minute to $Minute.\n" if $self->{diagnostic}; | ||||
497 | |||||
498 | |||||
499 | # Seconds | ||||
500 | $self->local_croak("$second is too large to be a second.") and return undef unless $second <= 59; #OK so leap seconds will break! | ||||
501 | $Second ||= $second; | ||||
502 | $self->local_croak("Your second does not match your epoch.") and return undef if $epoch_dt and $Second and $Second != $epoch_dt->second; | ||||
503 | print "Set second to $Second.\n" if $self->{diagnostic}; | ||||
504 | |||||
505 | |||||
506 | # Nanoeconds | ||||
507 | $self->local_croak("$nanosecond is too large to be a nanosecond.") and return undef unless length($nanosecond) <= 9; | ||||
508 | $Nanosecond ||= $nanosecond; | ||||
509 | $Nanosecond .= '0' while length($Nanosecond) < 9; | ||||
510 | # Epoch doesn't return nanoseconds | ||||
511 | # croak "Your nanosecond does not match your epoch." if $epoch_dt and $Nanosecond and $Nanosecond != $epoch_dt->nanosecond; | ||||
512 | print "Set nanosecond to $Nanosecond.\n" if $self->{diagnostic}; | ||||
513 | |||||
514 | my $potential_return = eval { | ||||
515 | DateTime->new( # spent 1.54ms making 5 calls to DateTime::new, avg 308µs/call | ||||
516 | year => ($Year || 1), | ||||
517 | month => ($Month || 1), | ||||
518 | day => ($Day || 1), | ||||
519 | |||||
520 | hour => ($Hour || 0), | ||||
521 | minute => ($Minute || 0), | ||||
522 | second => ($Second || 0), | ||||
523 | nanosecond => ($Nanosecond || 0), | ||||
524 | |||||
525 | locale => $self->{_locale}, | ||||
526 | time_zone => $use_timezone, | ||||
527 | ); | ||||
528 | }; | ||||
529 | $self->local_croak("Datetime is not a valid date") and return undef if $@; | ||||
530 | |||||
531 | $self->local_croak("Your day of the week ($dow_mon_1) does not match the date supplied: ".$potential_return->ymd) and return undef if $dow_mon_1 and $potential_return->dow != $dow_mon_1; | ||||
532 | |||||
533 | $self->local_croak("Your day of the week ($dow_sun_0) does not match the date supplied: ".$potential_return->ymd) and return undef if $dow_sun_0 and ($potential_return->dow % 7) != $dow_sun_0; | ||||
534 | |||||
535 | if ($dow_name) { | ||||
536 | my $dow_count = 0; | ||||
537 | my $dow_number = 0; | ||||
538 | foreach my $dow (@{$self->{_locale}->day_names}) { | ||||
539 | $dow_count++; | ||||
540 | 3 | 58µs | 2 | 21µs | # spent 18µs (14+4) within DateTime::Format::Strptime::BEGIN@540 which was called
# once (14µs+4µs) by SimpleDB::Class::SQL::BEGIN@20 at line 540 # spent 18µs making 1 call to DateTime::Format::Strptime::BEGIN@540
# spent 4µs making 1 call to bytes::import |
541 | if (lc $dow eq lc $dow_name) { | ||||
542 | $dow_number = $dow_count; | ||||
543 | last; | ||||
544 | } | ||||
545 | } | ||||
546 | unless ($dow_number) { | ||||
547 | my $dow_count = 0; | ||||
548 | foreach my $dow (@{$self->{_locale}->day_abbreviations}) { | ||||
549 | $dow_count++; | ||||
550 | 3 | 1.76ms | 2 | 17µs | # spent 15µs (13+2) within DateTime::Format::Strptime::BEGIN@550 which was called
# once (13µs+2µs) by SimpleDB::Class::SQL::BEGIN@20 at line 550 # spent 15µs making 1 call to DateTime::Format::Strptime::BEGIN@550
# spent 2µs making 1 call to bytes::import |
551 | if (lc $dow eq lc $dow_name) { | ||||
552 | $dow_number = $dow_count; | ||||
553 | last; | ||||
554 | } | ||||
555 | } | ||||
556 | } | ||||
557 | unless ($dow_number) { | ||||
558 | $self->local_croak("$dow_name is not a recognised day in this locale.") and return undef; | ||||
559 | } | ||||
560 | $self->local_croak("Your day of the week ($dow_name) does not match the date supplied: ".$potential_return->ymd) and return undef if $dow_number and $potential_return->dow != $dow_number; | ||||
561 | } | ||||
562 | |||||
563 | $self->local_croak("Your week number ($week_sun_0) does not match the date supplied: ".$potential_return->ymd) and return undef if $week_sun_0 and $potential_return->strftime('%U') != $week_sun_0; | ||||
564 | $self->local_croak("Your week number ($week_mon_1) does not match the date supplied: ".$potential_return->ymd) and return undef if $week_mon_1 and $potential_return->strftime('%W') != $week_mon_1; | ||||
565 | $self->local_croak("Your ISO week year ($iso_week_year) does not match the date supplied: ".$potential_return->ymd) and return undef if $iso_week_year and $potential_return->strftime('%G') != $iso_week_year; | ||||
566 | $self->local_croak("Your ISO week year ($iso_week_year_100) does not match the date supplied: ".$potential_return->ymd) and return undef if $iso_week_year_100 and $potential_return->strftime('%g') != $iso_week_year_100; | ||||
567 | |||||
568 | # Move into the timezone in the object - if there is one | ||||
569 | print "Potential Datetime: " . $potential_return->strftime("%F %T %z %Z") . "\n" if $self->{diagnostic}; | ||||
570 | print "Setting timezone: " . $self->{set_time_zone} . "\n" if $self->{diagnostic}; | ||||
571 | if ($self->{set_time_zone}) { | ||||
572 | $potential_return->set_time_zone($self->{set_time_zone}); | ||||
573 | } elsif ($set_time_zone) { | ||||
574 | $potential_return->set_time_zone($set_time_zone); | ||||
575 | } | ||||
576 | print "Actual Datetime: " . $potential_return->strftime("%F %T %z %Z") . "\n" if $self->{diagnostic}; | ||||
577 | |||||
578 | return $potential_return; | ||||
579 | } | ||||
580 | |||||
581 | sub parse_duration { | ||||
582 | croak "DateTime::Format::Strptime doesn't do durations."; | ||||
583 | } | ||||
584 | |||||
585 | sub format_datetime { | ||||
586 | my ( $self, $dt ) = @_; | ||||
587 | my $pattern = $self->pattern; | ||||
588 | $pattern =~ s/%O/$dt->time_zone->name/eg; | ||||
589 | return $dt->clone->set_locale($self->locale)->strftime($pattern); | ||||
590 | } | ||||
591 | |||||
592 | sub format_duration { | ||||
593 | croak "DateTime::Format::Strptime doesn't do durations."; | ||||
594 | } | ||||
595 | |||||
596 | |||||
597 | |||||
598 | # spent 6.34ms (1.49+4.85) within DateTime::Format::Strptime::_build_parser which was called 5 times, avg 1.27ms/call:
# 5 times (1.49ms+4.85ms) by DateTime::Format::Strptime::new at line 170, avg 1.27ms/call | ||||
599 | 510 | 2.14ms | my $self = shift; | ||
600 | my $regex = my $field_list = shift; | ||||
601 | if( ref $regex eq 'Regexp' ){ | ||||
602 | $field_list =~ s/^\(\?-xism:(.+)\)$/$1/; | ||||
603 | } | ||||
604 | my @fields = $field_list =~ m/(%\{\w+\}|%\d*.)/g; # spent 66µs making 5 calls to DateTime::Format::Strptime::CORE:match, avg 13µs/call | ||||
605 | $field_list = join('',@fields); | ||||
606 | |||||
607 | my $tempdt = DateTime->now(); # Created just so we can do $tempdt->can(..) # spent 2.18ms making 5 calls to DateTime::now, avg 437µs/call | ||||
608 | |||||
609 | # Locale-ize the parser | ||||
610 | my $ampm_list = join('|', @{$self->{_locale}->am_pms}); # spent 42µs making 5 calls to DateTime::Locale::Base::am_pms, avg 8µs/call | ||||
611 | $ampm_list .= '|' . lc $ampm_list; | ||||
612 | |||||
613 | my $default_date_format = $self->{_locale}->default_date_format; # spent 344µs making 5 calls to DateTime::Locale::Base::default_date_format, avg 69µs/call | ||||
614 | my @locale_format = $default_date_format =~ m/(%\{\w+\}|%\d*.)/g; # spent 37µs making 5 calls to DateTime::Format::Strptime::CORE:match, avg 7µs/call | ||||
615 | $default_date_format = join('',@locale_format); | ||||
616 | |||||
617 | my $default_time_format = $self->{_locale}->default_time_format; # spent 595µs making 5 calls to DateTime::Locale::Base::default_time_format, avg 119µs/call | ||||
618 | @locale_format = $default_time_format =~ m/(%\{\w+\}|%\d*.)/g; # spent 32µs making 5 calls to DateTime::Format::Strptime::CORE:match, avg 6µs/call | ||||
619 | $default_time_format = join('',@locale_format); | ||||
620 | |||||
621 | my $default_datetime_format = $self->{_locale}->default_datetime_format; # spent 814µs making 5 calls to DateTime::Locale::Base::default_datetime_format, avg 163µs/call | ||||
622 | @locale_format = $default_datetime_format =~ m/(%\{\w+\}|%\d*.)/g; # spent 46µs making 5 calls to DateTime::Format::Strptime::CORE:match, avg 9µs/call | ||||
623 | $default_datetime_format = join('',@locale_format); | ||||
624 | |||||
625 | print "Date format: $default_date_format\nTime format: $default_time_format\nDatetime format: $default_datetime_format\n" if $self->{diagnostic}; | ||||
626 | |||||
627 | $regex =~ s/%%/ovnksdjhvniurnvkjsdhfbngkjsdbnhuyw678rhiuwf/g; # spent 3µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 620ns/call | ||||
628 | $field_list =~ s/%%/ovnksdjhvniurnvkjsdhfbngkjsdbnhuyw678rhiuwf/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 380ns/call | ||||
629 | |||||
630 | $regex =~ s/%c/$self->{_locale}->default_datetime_format/eg; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 480ns/call | ||||
631 | $field_list =~ s/%c/$default_datetime_format/eg; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 320ns/call | ||||
632 | # %c is the locale's default datetime format. | ||||
633 | |||||
634 | $regex =~ s/%x/$self->{_locale}->default_date_format/eg; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 360ns/call | ||||
635 | $field_list =~ s/%x/$default_date_format/eg; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 440ns/call | ||||
636 | # %x is the locale's default date format. | ||||
637 | |||||
638 | $regex =~ s/%X/$self->{_locale}->default_time_format/eg; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 320ns/call | ||||
639 | $field_list =~ s/%X/$default_time_format/eg; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 420ns/call | ||||
640 | # %x is the locale's default time format. | ||||
641 | |||||
642 | if( ref $regex ne 'Regexp' ){ | ||||
643 | $regex = quotemeta( $regex ); | ||||
644 | $regex =~ s/(?<!\\)\\%/%/g; # spent 24µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 5µs/call | ||||
645 | $regex =~ s/%\\\{([^\}]+)\\\}/%{$1}/g; # spent 3µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 620ns/call | ||||
646 | } | ||||
647 | |||||
648 | $regex =~ s/%T/%H:%M:%S/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 400ns/call | ||||
649 | $field_list =~ s/%T/%H%M%S/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 340ns/call | ||||
650 | # %T is the time as %H:%M:%S. | ||||
651 | |||||
652 | $regex =~ s/%r/%I:%M:%S %p/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call | ||||
653 | $field_list =~ s/%r/%I%M%S%p/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call | ||||
654 | #is the time as %I:%M:%S %p. | ||||
655 | |||||
656 | $regex =~ s/%R/%H:%M/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 220ns/call | ||||
657 | $field_list =~ s/%R/%H%M/g; # spent 700ns making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 140ns/call | ||||
658 | #is the time as %H:%M. | ||||
659 | |||||
660 | $regex =~ s|%D|%m\\/%d\\/%y|g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 380ns/call | ||||
661 | $field_list =~ s|%D|%m%d%y|g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call | ||||
662 | #is the same as %m/%d/%y. | ||||
663 | |||||
664 | $regex =~ s|%F|%Y\\-%m\\-%d|g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 280ns/call | ||||
665 | $field_list =~ s|%F|%Y%m%d|g; # spent 800ns making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 160ns/call | ||||
666 | #is the same as %Y-%m-%d - the ISO date format. | ||||
667 | |||||
668 | my $day_re = join('|', | ||||
669 | map { quotemeta $_ } | ||||
670 | sort { length $b <=> length $a } | ||||
671 | grep(/\W/, @{$self->{_locale}->day_names}, @{$self->{_locale}->day_abbreviations}) # spent 36µs making 5 calls to DateTime::Locale::Base::day_names, avg 7µs/call
# spent 32µs making 5 calls to DateTime::Locale::Base::day_abbreviations, avg 6µs/call
# spent 22µs making 70 calls to DateTime::Format::Strptime::CORE:match, avg 320ns/call
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:sort, avg 420ns/call | ||||
672 | ); | ||||
673 | $day_re .= '|' if $day_re; | ||||
674 | $regex =~ s/%a/($day_re\\w+)/gi; # spent 5µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 940ns/call | ||||
675 | $field_list =~ s/%a/#dow_name#/gi; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 440ns/call | ||||
676 | # %a is the day of the week, using the locale's weekday names; either the abbreviated or full name may be specified. | ||||
677 | # %A is the same as %a. | ||||
678 | |||||
679 | my $month_re = join('|', | ||||
680 | map { quotemeta $_ } | ||||
681 | sort { length $b <=> length $a } | ||||
682 | grep(/\s|\d/, @{$self->{_locale}->month_names}, @{$self->{_locale}->month_abbreviations}) # spent 135µs making 120 calls to DateTime::Format::Strptime::CORE:match, avg 1µs/call
# spent 34µs making 5 calls to DateTime::Locale::Base::month_names, avg 7µs/call
# spent 33µs making 5 calls to DateTime::Locale::Base::month_abbreviations, avg 7µs/call
# spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:sort, avg 220ns/call | ||||
683 | ); | ||||
684 | $month_re .= '|' if $month_re; | ||||
685 | $month_re .= '[^\\s\\d]+'; | ||||
686 | $regex =~ s/%[bBh]/($month_re)/g; # spent 9µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
687 | $field_list =~ s/%[bBh]/#month_name#/g; # spent 6µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 1µs/call | ||||
688 | #is the month, using the locale's month names; either the abbreviated or full name may be specified. | ||||
689 | # %B is the same as %b. | ||||
690 | # %h is the same as %b. | ||||
691 | |||||
692 | #s/%c//g; | ||||
693 | #is replaced by the locale's appropriate date and time representation. | ||||
694 | |||||
695 | $regex =~ s/%C/([\\d ]?\\d)/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 320ns/call | ||||
696 | $field_list =~ s/%C/#century#/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 320ns/call | ||||
697 | #is the century number [0,99]; leading zeros are permitted by not required. | ||||
698 | |||||
699 | $regex =~ s/%[de]/([\\d ]?\\d)/g; # spent 18µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 4µs/call | ||||
700 | $field_list =~ s/%[de]/#day#/g; # spent 13µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 3µs/call | ||||
701 | #is the day of the month [1,31]; leading zeros are permitted but not required. | ||||
702 | #%e is the same as %d. | ||||
703 | |||||
704 | $regex =~ s/%[Hk]/([\\d ]?\\d)/g; # spent 14µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 3µs/call | ||||
705 | $field_list =~ s/%[Hk]/#hour_24#/g; # spent 13µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 3µs/call | ||||
706 | #is the hour (24-hour clock) [0,23]; leading zeros are permitted but not required. | ||||
707 | # %k is the same as %H | ||||
708 | |||||
709 | $regex =~ s/%g/([\\d ]?\\d)/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 440ns/call | ||||
710 | $field_list =~ s/%g/#iso_week_year_100#/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 300ns/call | ||||
711 | # The year corresponding to the ISO week number, but without the century (0-99). | ||||
712 | |||||
713 | $regex =~ s/%G/(\\d{4})/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 280ns/call | ||||
714 | $field_list =~ s/%G/#iso_week_year#/g; # spent 900ns making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 180ns/call | ||||
715 | # The year corresponding to the ISO week number. | ||||
716 | |||||
717 | $regex =~ s/%[Il]/([\\d ]?\\d)/g; # spent 7µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 1µs/call | ||||
718 | $field_list =~ s/%[Il]/#hour_12#/g; # spent 6µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 1µs/call | ||||
719 | #is the hour (12-hour clock) [1-12]; leading zeros are permitted but not required. | ||||
720 | # %l is the same as %I. | ||||
721 | |||||
722 | $regex =~ s/%j/(\\d{1,3})/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 400ns/call | ||||
723 | $field_list =~ s/%j/#doy#/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call | ||||
724 | #is the day of the year [1,366]; leading zeros are permitted but not required. | ||||
725 | |||||
726 | $regex =~ s/%m/([\\d ]?\\d)/g; # spent 9µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
727 | $field_list =~ s/%m/#month#/g; # spent 8µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
728 | #is the month number [1-12]; leading zeros are permitted but not required. | ||||
729 | |||||
730 | $regex =~ s/%M/([\\d ]?\\d)/g; # spent 9µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
731 | $field_list =~ s/%M/#minute#/g; # spent 9µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
732 | #is the minute [0-59]; leading zeros are permitted but not required. | ||||
733 | |||||
734 | $regex =~ s/%[nt]/\\s+/g; # spent 6µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 1µs/call | ||||
735 | $field_list =~ s/%[nt]//g; # spent 5µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 960ns/call | ||||
736 | # %n is any white space. | ||||
737 | # %t is any white space. | ||||
738 | |||||
739 | $regex =~ s/%p/($ampm_list)/gi; # spent 3µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 540ns/call | ||||
740 | $field_list =~ s/%p/#ampm#/gi; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 400ns/call | ||||
741 | # %p is the locale's equivalent of either A.M./P.M. indicator for 12-hour clock. | ||||
742 | |||||
743 | $regex =~ s/%s/(\\d+)/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call | ||||
744 | $field_list =~ s/%s/#epoch#/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 340ns/call | ||||
745 | # %s is the seconds since the epoch | ||||
746 | |||||
747 | $regex =~ s/%S/([\\d ]?\\d)/g; # spent 9µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
748 | $field_list =~ s/%S/#second#/g; # spent 8µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
749 | # %S is the seconds [0-61]; leading zeros are permitted but not required. | ||||
750 | |||||
751 | $regex =~ s/%(\d*)N/($1) ? "(\\d{$1})" : "(\\d+)"/eg; # spent 14µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 3µs/call
# spent 13µs making 10 calls to DateTime::Format::Strptime::CORE:substcont, avg 1µs/call | ||||
752 | $field_list =~ s/%\d*N/#nanosecond#/g; # spent 14µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 3µs/call | ||||
753 | # %N is the nanoseconds (or sub seconds really) | ||||
754 | |||||
755 | $regex =~ s/%U/([\\d ]?\\d)/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 380ns/call | ||||
756 | $field_list =~ s/%U/#week_sun_0#/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 340ns/call | ||||
757 | # %U is the week number of the year (Sunday as the first day of the week) as a decimal number [0-53]; leading zeros are permitted but not required. | ||||
758 | |||||
759 | $regex =~ s/%w/([0-6])/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call | ||||
760 | $field_list =~ s/%w/#dow_sun_0#/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 220ns/call | ||||
761 | # is the weekday as a decimal number [0-6], with 0 representing Sunday. | ||||
762 | |||||
763 | $regex =~ s/%u/([1-7])/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 220ns/call | ||||
764 | $field_list =~ s/%u/#dow_mon_1#/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 420ns/call | ||||
765 | # is the weekday as a decimal number [1-7], with 1 representing Monday - a la DateTime. | ||||
766 | |||||
767 | $regex =~ s/%W/([\\d ]?\\d)/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 360ns/call | ||||
768 | $field_list =~ s/%W/#week_mon_1#/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 280ns/call | ||||
769 | #is the week number of the year (Monday as the first day of the week) as a decimal number [0,53]; leading zeros are permitted but not required. | ||||
770 | |||||
771 | $regex =~ s/%y/([\\d ]?\\d)/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call | ||||
772 | $field_list =~ s/%y/#year_100#/g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 200ns/call | ||||
773 | # is the year within the century. When a century is not otherwise specified, values in the range 69-99 refer to years in the twentieth century (1969 to 1999 inclusive); values in the range 0-68 refer to years in the twenty-first century (2000-2068 inclusive). Leading zeros are permitted but not required. | ||||
774 | |||||
775 | $regex =~ s/%Y/(\\d{4})/g; # spent 10µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
776 | $field_list =~ s/%Y/#year#/g; # spent 8µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
777 | # is the year including the century (for example, 1998). | ||||
778 | |||||
779 | $regex =~ s|%z|([+-]\\d{4})|g; # spent 10µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
780 | $field_list =~ s/%z/#tz_offset#/g; # spent 8µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
781 | # Timezone Offset. | ||||
782 | |||||
783 | $regex =~ s|%Z|(\\w+)|g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 340ns/call | ||||
784 | $field_list =~ s/%Z/#timezone#/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 320ns/call | ||||
785 | # The short timezone name. | ||||
786 | |||||
787 | $regex =~ s|%O|(\\w+\\/\\w+)|g; # spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 240ns/call | ||||
788 | $field_list =~ s/%O/#tz_olson#/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 300ns/call | ||||
789 | # The Olson timezone name. | ||||
790 | |||||
791 | $regex =~ s|%{(\w+)}|($tempdt->can($1)) ? "(.+)" : ".+"|eg; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 480ns/call | ||||
792 | $field_list =~ s|(%{(\w+)})|($tempdt->can($2)) ? "#$2#" : $1 |eg; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 320ns/call | ||||
793 | # Any function in DateTime. | ||||
794 | |||||
795 | $regex =~ s/ovnksdjhvniurnvkjsdhfbngkjsdbnhuyw678rhiuwf/\\%/g; # spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 440ns/call | ||||
796 | $field_list =~ s/ovnksdjhvniurnvkjsdhfbngkjsdbnhuyw678rhiuwf//g; # spent 900ns making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 180ns/call | ||||
797 | # is replaced by %. | ||||
798 | #print $regex; | ||||
799 | |||||
800 | $field_list=~s/#([a-z0-9_]+)#/\$$1, /gi; # spent 30µs making 45 calls to DateTime::Format::Strptime::CORE:substcont, avg 676ns/call
# spent 8µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call | ||||
801 | $field_list=~s/,\s*$//; # spent 13µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 3µs/call | ||||
802 | |||||
803 | return qq|($field_list) = \$time_string =~ /$regex/|; | ||||
804 | } | ||||
805 | |||||
806 | # Utility functions | ||||
807 | |||||
808 | sub local_croak { | ||||
809 | my $self = $_[0]; | ||||
810 | return &{$self->{on_error}}(@_) if ref($self->{on_error}); | ||||
811 | croak($_[1]) if $self->{on_error} eq 'croak'; | ||||
812 | $self->{errmsg} = $_[1]; | ||||
813 | return ($self->{on_error} eq 'undef'); | ||||
814 | } | ||||
815 | sub local_carp { | ||||
816 | my $self = $_[0]; | ||||
817 | return &{$self->{on_error}}(@_) if ref($self->{on_error}); | ||||
818 | carp($_[1]) if $self->{on_error} eq 'croak'; | ||||
819 | $self->{errmsg} = $_[1]; | ||||
820 | return ($self->{on_error} eq 'undef'); | ||||
821 | } | ||||
822 | |||||
823 | sub errmsg { | ||||
824 | $_[0]->{errmsg}; | ||||
825 | } | ||||
826 | |||||
827 | # Exportable functions: | ||||
828 | |||||
829 | # spent 1.64ms (63µs+1.58) within DateTime::Format::Strptime::strftime which was called 8 times, avg 205µs/call:
# 8 times (63µs+1.58ms) by SimpleDB::Class::Types::__ANON__[../lib/SimpleDB/Class/Types.pm:152] at line 152 of ../lib/SimpleDB/Class/Types.pm, avg 205µs/call | ||||
830 | 16 | 58µs | my ($pattern, $dt) = @_; | ||
831 | return $dt->strftime($pattern); # spent 1.58ms making 8 calls to DateTime::strftime, avg 197µs/call | ||||
832 | } | ||||
833 | |||||
834 | # spent 28.1ms (67µs+28.0) within DateTime::Format::Strptime::strptime which was called 5 times, avg 5.62ms/call:
# 5 times (67µs+28.0ms) by SimpleDB::Class::Types::__ANON__[../lib/SimpleDB/Class/Types.pm:185] at line 180 of ../lib/SimpleDB/Class/Types.pm, avg 5.62ms/call | ||||
835 | 10 | 63µs | my ($pattern, $time_string) = @_; | ||
836 | return DateTime::Format::Strptime->new( pattern => $pattern, on_error=>'croak' )->parse_datetime($time_string); # spent 20.5ms making 5 calls to DateTime::Format::Strptime::parse_datetime, avg 4.09ms/call
# spent 7.57ms making 5 calls to DateTime::Format::Strptime::new, avg 1.51ms/call | ||||
837 | } | ||||
838 | |||||
839 | |||||
840 | 1 | 232µs | 1; | ||
841 | __END__ | ||||
842 | |||||
843 | =head1 NAME | ||||
844 | |||||
845 | DateTime::Format::Strptime - Parse and format strp and strf time patterns | ||||
846 | |||||
847 | =head1 SYNOPSIS | ||||
848 | |||||
849 | use DateTime::Format::Strptime; | ||||
850 | |||||
851 | my $Strp = new DateTime::Format::Strptime( | ||||
852 | pattern => '%T', | ||||
853 | locale => 'en_AU', | ||||
854 | time_zone => 'Australia/Melbourne', | ||||
855 | ); | ||||
856 | |||||
857 | my $dt = $Strp->parse_datetime('23:16:42'); | ||||
858 | |||||
859 | $Strp->format_datetime($dt); | ||||
860 | # 23:16:42 | ||||
861 | |||||
862 | |||||
863 | |||||
864 | # Croak when things go wrong: | ||||
865 | my $Strp = new DateTime::Format::Strptime( | ||||
866 | pattern => '%T', | ||||
867 | locale => 'en_AU', | ||||
868 | time_zone => 'Australia/Melbourne', | ||||
869 | on_error => 'croak', | ||||
870 | ); | ||||
871 | |||||
872 | $newpattern = $Strp->pattern('%Q'); | ||||
873 | # Unidentified token in pattern: %Q in %Q at line 34 of script.pl | ||||
874 | |||||
875 | # Do something else when things go wrong: | ||||
876 | my $Strp = new DateTime::Format::Strptime( | ||||
877 | pattern => '%T', | ||||
878 | locale => 'en_AU', | ||||
879 | time_zone => 'Australia/Melbourne', | ||||
880 | on_error => \&phone_police, | ||||
881 | ); | ||||
882 | |||||
883 | |||||
884 | |||||
885 | =head1 DESCRIPTION | ||||
886 | |||||
887 | This module implements most of C<strptime(3)>, the POSIX function that | ||||
888 | is the reverse of C<strftime(3)>, for C<DateTime>. While C<strftime> | ||||
889 | takes a C<DateTime> and a pattern and returns a string, C<strptime> takes | ||||
890 | a string and a pattern and returns the C<DateTime> object | ||||
891 | associated. | ||||
892 | |||||
893 | =head1 CONSTRUCTOR | ||||
894 | |||||
895 | =over 4 | ||||
896 | |||||
897 | =item * new( pattern=>$strptime_pattern ) | ||||
898 | |||||
899 | Creates the format object. You must specify a pattern, you can also | ||||
900 | specify a C<time_zone> and a C<locale>. If you specify a time zone | ||||
901 | then any resulting C<DateTime> object will be in that time zone. If you | ||||
902 | do not specify a C<time_zone> parameter, but there is a time zone in the | ||||
903 | string you pass to C<parse_datetime>, then the resulting C<DateTime> will | ||||
904 | use that time zone. | ||||
905 | |||||
906 | You can optionally use an on_error parameter. This parameter has three | ||||
907 | valid options: | ||||
908 | |||||
909 | =over 4 | ||||
910 | |||||
911 | =item * 'undef' | ||||
912 | |||||
913 | (not undef, 'undef', it's a string not an undefined value) | ||||
914 | |||||
915 | This is the default behavior. The module will return undef whenever it | ||||
916 | gets upset. The error can be accessed using the $object->errstr method. | ||||
917 | This is the ideal behaviour for interactive use where a user might | ||||
918 | provide an illegal pattern or a date that doesn't match the pattern. | ||||
919 | |||||
920 | =item * 'croak' | ||||
921 | |||||
922 | (not croak, 'croak', it's a string, not a function) | ||||
923 | |||||
924 | This used to be the default behaviour. The module will croak with an | ||||
925 | error message whenever it gets upset. | ||||
926 | |||||
927 | =item * sub{...} or \&subname | ||||
928 | |||||
929 | When given a code ref, the module will call that sub when it gets upset. | ||||
930 | The sub receives two parameters: the object and the error message. Using | ||||
931 | these two it is possible to emulate the 'undef' behavior. (Returning a | ||||
932 | true value causes the method to return undef. Returning a false value | ||||
933 | causes the method to bravely continue): | ||||
934 | |||||
935 | sub{$_[0]->{errmsg} = $_[1]; 1}, | ||||
936 | |||||
937 | =back | ||||
938 | |||||
939 | =back | ||||
940 | |||||
941 | =head1 METHODS | ||||
942 | |||||
943 | This class offers the following methods. | ||||
944 | |||||
945 | =over 4 | ||||
946 | |||||
947 | =item * parse_datetime($string) | ||||
948 | |||||
949 | Given a string in the pattern specified in the constructor, this method | ||||
950 | will return a new C<DateTime> object. | ||||
951 | |||||
952 | If given a string that doesn't match the pattern, the formatter will | ||||
953 | croak or return undef, depending on the setting of on_error in the constructor. | ||||
954 | |||||
955 | =item * format_datetime($datetime) | ||||
956 | |||||
957 | Given a C<DateTime> object, this methods returns a string formatted in | ||||
958 | the object's format. This method is synonymous with C<DateTime>'s | ||||
959 | strftime method. | ||||
960 | |||||
961 | =item * locale($locale) | ||||
962 | |||||
963 | When given a locale or C<DateTime::Locale> object, this method sets | ||||
964 | its locale appropriately. If the locale is not understood, the method | ||||
965 | will croak or return undef (depending on the setting of on_error in | ||||
966 | the constructor) | ||||
967 | |||||
968 | If successful this method returns the current locale. (After | ||||
969 | processing as above). | ||||
970 | |||||
971 | =item * pattern($strptime_pattern) | ||||
972 | |||||
973 | When given a pattern, this method sets the object's pattern. If the | ||||
974 | pattern is invalid, the method will croak or return undef (depending on | ||||
975 | the value of the C<on_error> parameter) | ||||
976 | |||||
977 | If successful this method returns the current pattern. (After processing | ||||
978 | as above) | ||||
979 | |||||
980 | =item * time_zone($time_zone) | ||||
981 | |||||
982 | When given a name, offset or C<DateTime::TimeZone> object, this method | ||||
983 | sets the object's time zone. This effects the C<DateTime> object | ||||
984 | returned by parse_datetime | ||||
985 | |||||
986 | If the time zone is invalid, the method will croak or return undef | ||||
987 | (depending on the value of the C<on_error> parameter) | ||||
988 | |||||
989 | If successful this method returns the current time zone. (After processing | ||||
990 | as above) | ||||
991 | |||||
992 | =item * errmsg | ||||
993 | |||||
994 | If the on_error behavior of the object is 'undef', error messages with | ||||
995 | this method so you can work out why things went wrong. | ||||
996 | |||||
997 | This code emulates a C<$DateTime::Format::Strptime> with | ||||
998 | the C<on_error> parameter equal to C<'croak'>: | ||||
999 | |||||
1000 | C<$Strp->pattern($pattern) or die $DateTime::Format::Strptime::errmsg> | ||||
1001 | |||||
1002 | =back | ||||
1003 | |||||
1004 | =head1 EXPORTS | ||||
1005 | |||||
1006 | There are no methods exported by default, however the following are | ||||
1007 | available: | ||||
1008 | |||||
1009 | =over 4 | ||||
1010 | |||||
1011 | =item * strptime($strptime_pattern, $string) | ||||
1012 | |||||
1013 | Given a pattern and a string this function will return a new C<DateTime> | ||||
1014 | object. | ||||
1015 | |||||
1016 | =item * strftime($strftime_pattern, $datetime) | ||||
1017 | |||||
1018 | Given a pattern and a C<DateTime> object this function will return a | ||||
1019 | formatted string. | ||||
1020 | |||||
1021 | =back | ||||
1022 | |||||
1023 | =head1 STRPTIME PATTERN TOKENS | ||||
1024 | |||||
1025 | The following tokens are allowed in the pattern string for strptime | ||||
1026 | (parse_datetime): | ||||
1027 | |||||
1028 | =over 4 | ||||
1029 | |||||
1030 | =item * %% | ||||
1031 | |||||
1032 | The % character. | ||||
1033 | |||||
1034 | =item * %a or %A | ||||
1035 | |||||
1036 | The weekday name according to the current locale, in abbreviated form or | ||||
1037 | the full name. | ||||
1038 | |||||
1039 | =item * %b or %B or %h | ||||
1040 | |||||
1041 | The month name according to the current locale, in abbreviated form or | ||||
1042 | the full name. | ||||
1043 | |||||
1044 | =item * %C | ||||
1045 | |||||
1046 | The century number (0-99). | ||||
1047 | |||||
1048 | =item * %d or %e | ||||
1049 | |||||
1050 | The day of month (1-31). | ||||
1051 | |||||
1052 | =item * %D | ||||
1053 | |||||
1054 | Equivalent to %m/%d/%y. (This is the American style date, very confusing | ||||
1055 | to non-Americans, especially since %d/%m/%y is widely used in Europe. | ||||
1056 | The ISO 8601 standard pattern is %F.) | ||||
1057 | |||||
1058 | =item * %F | ||||
1059 | |||||
1060 | Equivalent to %Y-%m-%d. (This is the ISO style date) | ||||
1061 | |||||
1062 | =item * %g | ||||
1063 | |||||
1064 | The year corresponding to the ISO week number, but without the century | ||||
1065 | (0-99). | ||||
1066 | |||||
1067 | =item * %G | ||||
1068 | |||||
1069 | The year corresponding to the ISO week number. | ||||
1070 | |||||
1071 | =item * %H | ||||
1072 | |||||
1073 | The hour (0-23). | ||||
1074 | |||||
1075 | =item * %I | ||||
1076 | |||||
1077 | The hour on a 12-hour clock (1-12). | ||||
1078 | |||||
1079 | =item * %j | ||||
1080 | |||||
1081 | The day number in the year (1-366). | ||||
1082 | |||||
1083 | =item * %m | ||||
1084 | |||||
1085 | The month number (1-12). | ||||
1086 | |||||
1087 | =item * %M | ||||
1088 | |||||
1089 | The minute (0-59). | ||||
1090 | |||||
1091 | =item * %n | ||||
1092 | |||||
1093 | Arbitrary whitespace. | ||||
1094 | |||||
1095 | =item * %N | ||||
1096 | |||||
1097 | Nanoseconds. For other sub-second values use C<%[number]N>. | ||||
1098 | |||||
1099 | =item * %p | ||||
1100 | |||||
1101 | The equivalent of AM or PM according to the locale in use. (See | ||||
1102 | L<DateTime::Locale>) | ||||
1103 | |||||
1104 | =item * %r | ||||
1105 | |||||
1106 | Equivalent to %I:%M:%S %p. | ||||
1107 | |||||
1108 | =item * %R | ||||
1109 | |||||
1110 | Equivalent to %H:%M. | ||||
1111 | |||||
1112 | =item * %s | ||||
1113 | |||||
1114 | Number of seconds since the Epoch. | ||||
1115 | |||||
1116 | =item * %S | ||||
1117 | |||||
1118 | The second (0-60; 60 may occur for leap seconds. See | ||||
1119 | L<DateTime::LeapSecond>). | ||||
1120 | |||||
1121 | =item * %t | ||||
1122 | |||||
1123 | Arbitrary whitespace. | ||||
1124 | |||||
1125 | =item * %T | ||||
1126 | |||||
1127 | Equivalent to %H:%M:%S. | ||||
1128 | |||||
1129 | =item * %U | ||||
1130 | |||||
1131 | The week number with Sunday the first day of the week (0-53). The first | ||||
1132 | Sunday of January is the first day of week 1. | ||||
1133 | |||||
1134 | =item * %u | ||||
1135 | |||||
1136 | The weekday number (1-7) with Monday = 1. This is the C<DateTime> standard. | ||||
1137 | |||||
1138 | =item * %w | ||||
1139 | |||||
1140 | The weekday number (0-6) with Sunday = 0. | ||||
1141 | |||||
1142 | =item * %W | ||||
1143 | |||||
1144 | The week number with Monday the first day of the week (0-53). The first | ||||
1145 | Monday of January is the first day of week 1. | ||||
1146 | |||||
1147 | =item * %y | ||||
1148 | |||||
1149 | The year within century (0-99). When a century is not otherwise | ||||
1150 | specified, values in the range 69-99 refer to years in the twen- tieth | ||||
1151 | century (1969-1999); values in the range 00-68 refer to years in the | ||||
1152 | twenty-first century (2000-2068). | ||||
1153 | |||||
1154 | =item * %Y | ||||
1155 | |||||
1156 | The year, including century (for example, 1991). | ||||
1157 | |||||
1158 | =item * %z | ||||
1159 | |||||
1160 | An RFC-822/ISO 8601 standard time zone specification. (For example | ||||
1161 | +1100) [See note below] | ||||
1162 | |||||
1163 | =item * %Z | ||||
1164 | |||||
1165 | The timezone name. (For example EST -- which is ambiguous) [See note | ||||
1166 | below] | ||||
1167 | |||||
1168 | =item * %O | ||||
1169 | |||||
1170 | This extended token allows the use of Olson Time Zone names to appear | ||||
1171 | in parsed strings. B<NOTE>: This pattern cannot be passed to C<DateTime>'s | ||||
1172 | C<strftime()> method, but can be passed to C<format_datetime()>. | ||||
1173 | |||||
1174 | =back | ||||
1175 | |||||
1176 | =head1 RESOURCES | ||||
1177 | |||||
1178 | =over 4 | ||||
1179 | |||||
1180 | =item * Mailing List | ||||
1181 | |||||
1182 | Support for this module is primarily provided via the DateTime | ||||
1183 | Mailing List: C<datetime@perl.org> | ||||
1184 | |||||
1185 | http://lists.cpan.org/showlist.cgi?name=datetime | ||||
1186 | |||||
1187 | =item * Bugtracker | ||||
1188 | |||||
1189 | For bug tracking and reporting, please use the google-code tracker | ||||
1190 | rather than the RT interface linked at search.cpan.org | ||||
1191 | |||||
1192 | http://code.google.com/p/datetime-format-strptime/issues/list | ||||
1193 | |||||
1194 | =item * Homepage | ||||
1195 | |||||
1196 | http://datetime-format-strptime.googlecode.com/ | ||||
1197 | |||||
1198 | =item * Subversion Repository | ||||
1199 | |||||
1200 | The latest version is always available via subversion: | ||||
1201 | |||||
1202 | http://datetime-format-strptime.googlecode.com/svn/trunk/ | ||||
1203 | |||||
1204 | =back | ||||
1205 | |||||
1206 | =head1 LICENSE AND COPYRIGHT | ||||
1207 | |||||
1208 | Copyright E<169> Rick Measham, 2003-2007. All rights reserved. | ||||
1209 | |||||
1210 | This library is free software; you can redistribute it and/or modify it | ||||
1211 | under the same terms as Perl itself. | ||||
1212 | |||||
1213 | The full text of the licenses can be found in the F<LICENCE> file | ||||
1214 | included with this module. | ||||
1215 | |||||
1216 | =head1 AUTHOR | ||||
1217 | |||||
1218 | Rick Measham <rickm@cpan.org> | ||||
1219 | |||||
1220 | =head1 SEE ALSO | ||||
1221 | |||||
1222 | C<datetime@perl.org> mailing list. | ||||
1223 | |||||
1224 | http://datetime.perl.org/ | ||||
1225 | |||||
1226 | L<perl>, L<DateTime>, L<DateTime::TimeZone>, L<DateTime::Locale> | ||||
1227 | |||||
1228 | =cut | ||||
# spent 451µs within DateTime::Format::Strptime::CORE:match which was called 335 times, avg 1µs/call:
# 120 times (135µs+0s) by DateTime::Format::Strptime::_build_parser at line 682 of DateTime/Format/Strptime.pm, avg 1µs/call
# 115 times (65µs+0s) by DateTime::Format::Strptime::parse_datetime at line 293 of DateTime/Format/Strptime.pm, avg 561ns/call
# 70 times (22µs+0s) by DateTime::Format::Strptime::_build_parser at line 671 of DateTime/Format/Strptime.pm, avg 320ns/call
# 5 times (66µs+0s) by DateTime::Format::Strptime::_build_parser at line 604 of DateTime/Format/Strptime.pm, avg 13µs/call
# 5 times (46µs+0s) by DateTime::Format::Strptime::_build_parser at line 622 of DateTime/Format/Strptime.pm, avg 9µs/call
# 5 times (37µs+0s) by DateTime::Format::Strptime::_build_parser at line 614 of DateTime/Format/Strptime.pm, avg 7µs/call
# 5 times (32µs+0s) by DateTime::Format::Strptime::_build_parser at line 618 of DateTime/Format/Strptime.pm, avg 6µs/call
# 5 times (10µs+0s) by DateTime::Format::Strptime::new at line 171 of DateTime/Format/Strptime.pm, avg 2µs/call
# once (9µs+0s) by DateTime::Format::Strptime::parse_datetime at line 1 of (eval 0)[DateTime/Format/Strptime.pm:254] at line 254 of DateTime/Format/Strptime.pm
# once (8µs+0s) by DateTime::Format::Strptime::parse_datetime at line 1 of (eval 0)[DateTime/Format/Strptime.pm:254] at line 254 of DateTime/Format/Strptime.pm
# once (7µs+0s) by DateTime::Format::Strptime::parse_datetime at line 1 of (eval 0)[DateTime/Format/Strptime.pm:254] at line 254 of DateTime/Format/Strptime.pm
# once (7µs+0s) by DateTime::Format::Strptime::parse_datetime at line 1 of (eval 0)[DateTime/Format/Strptime.pm:254] at line 254 of DateTime/Format/Strptime.pm
# once (6µs+0s) by DateTime::Format::Strptime::parse_datetime at line 1 of (eval 0)[DateTime/Format/Strptime.pm:254] at line 254 of DateTime/Format/Strptime.pm | |||||
# spent 3µs within DateTime::Format::Strptime::CORE:sort which was called 10 times, avg 320ns/call:
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 671 of DateTime/Format/Strptime.pm, avg 420ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 682 of DateTime/Format/Strptime.pm, avg 220ns/call | |||||
# spent 348µs within DateTime::Format::Strptime::CORE:subst which was called 380 times, avg 916ns/call:
# 5 times (24µs+0s) by DateTime::Format::Strptime::_build_parser at line 644 of DateTime/Format/Strptime.pm, avg 5µs/call
# 5 times (18µs+0s) by DateTime::Format::Strptime::_build_parser at line 699 of DateTime/Format/Strptime.pm, avg 4µs/call
# 5 times (14µs+0s) by DateTime::Format::Strptime::_build_parser at line 704 of DateTime/Format/Strptime.pm, avg 3µs/call
# 5 times (14µs+0s) by DateTime::Format::Strptime::_build_parser at line 751 of DateTime/Format/Strptime.pm, avg 3µs/call
# 5 times (14µs+0s) by DateTime::Format::Strptime::_build_parser at line 752 of DateTime/Format/Strptime.pm, avg 3µs/call
# 5 times (13µs+0s) by DateTime::Format::Strptime::_build_parser at line 705 of DateTime/Format/Strptime.pm, avg 3µs/call
# 5 times (13µs+0s) by DateTime::Format::Strptime::_build_parser at line 801 of DateTime/Format/Strptime.pm, avg 3µs/call
# 5 times (13µs+0s) by DateTime::Format::Strptime::_build_parser at line 700 of DateTime/Format/Strptime.pm, avg 3µs/call
# 5 times (10µs+0s) by DateTime::Format::Strptime::_build_parser at line 775 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (10µs+0s) by DateTime::Format::Strptime::_build_parser at line 779 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (9µs+0s) by DateTime::Format::Strptime::_build_parser at line 747 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (9µs+0s) by DateTime::Format::Strptime::_build_parser at line 686 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (9µs+0s) by DateTime::Format::Strptime::_build_parser at line 730 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (9µs+0s) by DateTime::Format::Strptime::_build_parser at line 726 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (9µs+0s) by DateTime::Format::Strptime::_build_parser at line 731 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (8µs+0s) by DateTime::Format::Strptime::_build_parser at line 748 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (8µs+0s) by DateTime::Format::Strptime::_build_parser at line 776 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (8µs+0s) by DateTime::Format::Strptime::_build_parser at line 727 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (8µs+0s) by DateTime::Format::Strptime::_build_parser at line 800 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (8µs+0s) by DateTime::Format::Strptime::_build_parser at line 780 of DateTime/Format/Strptime.pm, avg 2µs/call
# 5 times (7µs+0s) by DateTime::Format::Strptime::_build_parser at line 717 of DateTime/Format/Strptime.pm, avg 1µs/call
# 5 times (6µs+0s) by DateTime::Format::Strptime::_build_parser at line 687 of DateTime/Format/Strptime.pm, avg 1µs/call
# 5 times (6µs+0s) by DateTime::Format::Strptime::_build_parser at line 718 of DateTime/Format/Strptime.pm, avg 1µs/call
# 5 times (6µs+0s) by DateTime::Format::Strptime::_build_parser at line 734 of DateTime/Format/Strptime.pm, avg 1µs/call
# 5 times (5µs+0s) by DateTime::Format::Strptime::_build_parser at line 735 of DateTime/Format/Strptime.pm, avg 960ns/call
# 5 times (5µs+0s) by DateTime::Format::Strptime::_build_parser at line 674 of DateTime/Format/Strptime.pm, avg 940ns/call
# 5 times (3µs+0s) by DateTime::Format::Strptime::_build_parser at line 645 of DateTime/Format/Strptime.pm, avg 620ns/call
# 5 times (3µs+0s) by DateTime::Format::Strptime::_build_parser at line 627 of DateTime/Format/Strptime.pm, avg 620ns/call
# 5 times (3µs+0s) by DateTime::Format::Strptime::_build_parser at line 739 of DateTime/Format/Strptime.pm, avg 540ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 630 of DateTime/Format/Strptime.pm, avg 480ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 791 of DateTime/Format/Strptime.pm, avg 480ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 675 of DateTime/Format/Strptime.pm, avg 440ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 635 of DateTime/Format/Strptime.pm, avg 440ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 709 of DateTime/Format/Strptime.pm, avg 440ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 795 of DateTime/Format/Strptime.pm, avg 440ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 764 of DateTime/Format/Strptime.pm, avg 420ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 639 of DateTime/Format/Strptime.pm, avg 420ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 722 of DateTime/Format/Strptime.pm, avg 400ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 740 of DateTime/Format/Strptime.pm, avg 400ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 648 of DateTime/Format/Strptime.pm, avg 400ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 755 of DateTime/Format/Strptime.pm, avg 380ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 628 of DateTime/Format/Strptime.pm, avg 380ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 660 of DateTime/Format/Strptime.pm, avg 380ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 767 of DateTime/Format/Strptime.pm, avg 360ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 634 of DateTime/Format/Strptime.pm, avg 360ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 744 of DateTime/Format/Strptime.pm, avg 340ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 649 of DateTime/Format/Strptime.pm, avg 340ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 783 of DateTime/Format/Strptime.pm, avg 340ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 756 of DateTime/Format/Strptime.pm, avg 340ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 695 of DateTime/Format/Strptime.pm, avg 320ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 696 of DateTime/Format/Strptime.pm, avg 320ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 631 of DateTime/Format/Strptime.pm, avg 320ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 784 of DateTime/Format/Strptime.pm, avg 320ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 792 of DateTime/Format/Strptime.pm, avg 320ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 638 of DateTime/Format/Strptime.pm, avg 320ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 788 of DateTime/Format/Strptime.pm, avg 300ns/call
# 5 times (2µs+0s) by DateTime::Format::Strptime::_build_parser at line 710 of DateTime/Format/Strptime.pm, avg 300ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 713 of DateTime/Format/Strptime.pm, avg 280ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 768 of DateTime/Format/Strptime.pm, avg 280ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 664 of DateTime/Format/Strptime.pm, avg 280ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 743 of DateTime/Format/Strptime.pm, avg 260ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 771 of DateTime/Format/Strptime.pm, avg 260ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 759 of DateTime/Format/Strptime.pm, avg 260ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 653 of DateTime/Format/Strptime.pm, avg 260ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 652 of DateTime/Format/Strptime.pm, avg 260ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 723 of DateTime/Format/Strptime.pm, avg 260ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 661 of DateTime/Format/Strptime.pm, avg 260ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 787 of DateTime/Format/Strptime.pm, avg 240ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 656 of DateTime/Format/Strptime.pm, avg 220ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 763 of DateTime/Format/Strptime.pm, avg 220ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 760 of DateTime/Format/Strptime.pm, avg 220ns/call
# 5 times (1µs+0s) by DateTime::Format::Strptime::_build_parser at line 772 of DateTime/Format/Strptime.pm, avg 200ns/call
# 5 times (900ns+0s) by DateTime::Format::Strptime::_build_parser at line 796 of DateTime/Format/Strptime.pm, avg 180ns/call
# 5 times (900ns+0s) by DateTime::Format::Strptime::_build_parser at line 714 of DateTime/Format/Strptime.pm, avg 180ns/call
# 5 times (800ns+0s) by DateTime::Format::Strptime::_build_parser at line 665 of DateTime/Format/Strptime.pm, avg 160ns/call
# 5 times (700ns+0s) by DateTime::Format::Strptime::_build_parser at line 657 of DateTime/Format/Strptime.pm, avg 140ns/call | |||||
# spent 44µs within DateTime::Format::Strptime::CORE:substcont which was called 55 times, avg 795ns/call:
# 45 times (30µs+0s) by DateTime::Format::Strptime::_build_parser at line 800 of DateTime/Format/Strptime.pm, avg 676ns/call
# 10 times (13µs+0s) by DateTime::Format::Strptime::_build_parser at line 751 of DateTime/Format/Strptime.pm, avg 1µs/call |