← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 05.Domain_and_Item.t
  Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:23:04 2010

File /usr/local/lib/perl5/site_perl/5.10.1/DateTime/Format/Strptime.pm
Statements Executed 1017
Statement Execution Time 8.91ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
5111.49ms6.34msDateTime::Format::Strptime::::_build_parserDateTime::Format::Strptime::_build_parser
5111.04ms20.5msDateTime::Format::Strptime::::parse_datetimeDateTime::Format::Strptime::parse_datetime
335137451µs451µsDateTime::Format::Strptime::::CORE:matchDateTime::Format::Strptime::CORE:match (opcode)
380762348µs348µsDateTime::Format::Strptime::::CORE:substDateTime::Format::Strptime::CORE:subst (opcode)
511323µs7.57msDateTime::Format::Strptime::::newDateTime::Format::Strptime::new
51167µs28.1msDateTime::Format::Strptime::::strptimeDateTime::Format::Strptime::strptime
81163µs1.64msDateTime::Format::Strptime::::strftimeDateTime::Format::Strptime::strftime
552244µs44µsDateTime::Format::Strptime::::CORE:substcontDateTime::Format::Strptime::CORE:substcont (opcode)
11114µs18µsDateTime::Format::Strptime::::BEGIN@3DateTime::Format::Strptime::BEGIN@3
11114µs18µsDateTime::Format::Strptime::::BEGIN@540DateTime::Format::Strptime::BEGIN@540
11113µs15µsDateTime::Format::Strptime::::BEGIN@550DateTime::Format::Strptime::BEGIN@550
1118µs41µsDateTime::Format::Strptime::::BEGIN@9DateTime::Format::Strptime::BEGIN@9
1118µs64µsDateTime::Format::Strptime::::BEGIN@8DateTime::Format::Strptime::BEGIN@8
1118µs22µsDateTime::Format::Strptime::::BEGIN@11DateTime::Format::Strptime::BEGIN@11
1117µs113µsDateTime::Format::Strptime::::BEGIN@12DateTime::Format::Strptime::BEGIN@12
1114µs4µsDateTime::Format::Strptime::::BEGIN@5DateTime::Format::Strptime::BEGIN@5
1114µs4µsDateTime::Format::Strptime::::BEGIN@7DateTime::Format::Strptime::BEGIN@7
1113µs3µsDateTime::Format::Strptime::::BEGIN@6DateTime::Format::Strptime::BEGIN@6
10223µs3µsDateTime::Format::Strptime::::CORE:sortDateTime::Format::Strptime::CORE:sort (opcode)
0000s0sDateTime::Format::Strptime::::errmsgDateTime::Format::Strptime::errmsg
0000s0sDateTime::Format::Strptime::::format_datetimeDateTime::Format::Strptime::format_datetime
0000s0sDateTime::Format::Strptime::::format_durationDateTime::Format::Strptime::format_duration
0000s0sDateTime::Format::Strptime::::local_carpDateTime::Format::Strptime::local_carp
0000s0sDateTime::Format::Strptime::::local_croakDateTime::Format::Strptime::local_croak
0000s0sDateTime::Format::Strptime::::localeDateTime::Format::Strptime::locale
0000s0sDateTime::Format::Strptime::::parse_durationDateTime::Format::Strptime::parse_duration
0000s0sDateTime::Format::Strptime::::patternDateTime::Format::Strptime::pattern
0000s0sDateTime::Format::Strptime::::time_zoneDateTime::Format::Strptime::time_zone
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DateTime::Format::Strptime;
2
3322µs221µ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
use strict;
# spent 18µs making 1 call to DateTime::Format::Strptime::BEGIN@3 # spent 3µs making 1 call to strict::import
4
5317µs14µ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
use DateTime;
# spent 4µs making 1 call to DateTime::Format::Strptime::BEGIN@5
6318µs13µ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
use DateTime::Locale;
# spent 3µs making 1 call to DateTime::Format::Strptime::BEGIN@6
7322µs14µ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
use DateTime::TimeZone;
# spent 4µs making 1 call to DateTime::Format::Strptime::BEGIN@7
8323µs2120µ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
use Params::Validate qw( validate SCALAR SCALARREF BOOLEAN OBJECT CODEREF );
# spent 64µs making 1 call to DateTime::Format::Strptime::BEGIN@8 # spent 56µs making 1 call to Exporter::import
9322µs274µ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
use Carp;
# spent 41µs making 1 call to DateTime::Format::Strptime::BEGIN@9 # spent 33µs making 1 call to Exporter::import
10
11323µs236µ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
use Exporter;
# spent 22µs making 1 call to DateTime::Format::Strptime::BEGIN@11 # spent 14µs making 1 call to Exporter::import
1232.57ms2218µ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
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK %ZONEMAP %FORMATS $CROAK $errmsg);
# spent 113µs making 1 call to DateTime::Format::Strptime::BEGIN@12 # spent 105µs making 1 call to vars::import
13
14119µs@ISA = 'Exporter';
151500ns$VERSION = '1.1000';
1611µs@EXPORT_OK = qw( &strftime &strptime );
171200ns@EXPORT = ();
18
191202µ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
sub new {
12653µs my $class = shift;
1275398µs5268µ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
13559µs 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
14254µs unless (ref ($args{locale})) {
143524µs5310µs my $locale = DateTime::Locale->load( $args{locale} );
# spent 310µs making 5 calls to DateTime::Locale::load, avg 62µs/call
144
14551µs croak("Could not create locale from $args{locale}") unless $locale;
146
14756µs $args{_locale} = $locale;
148 } else {
149 $args{_locale} = $args{locale};
150 ($args{locale}) = ref($args{_locale}) =~/::(\w+)[^:]+$/
151 }
152
15354µs 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 {
161528µs5319µs $args{time_zone} = DateTime::TimeZone->new( name => 'floating' );
# spent 319µs making 5 calls to DateTime::TimeZone::new, avg 64µs/call
16256µs $args{set_time_zone} = '';
163 }
164
165
166522µs my $self = bless \%args, $class;
167
168
169 # Deal with the parser
170525µs56.34ms $self->{parser} = $self->_build_parser($args{pattern});
# spent 6.34ms making 5 calls to DateTime::Format::Strptime::_build_parser, avg 1.27ms/call
171523µs510µs 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
175516µs return $self;
176}
177
178sub 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
194sub 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
212sub 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
sub parse_datetime {
23055µs my ( $self, $time_string ) = @_;
231
232514µs local $^W = undef;
233
234 # Variables from the parser
23557µs 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
24754µs my ( $Year, $Month, $Day,
248 $Hour, $Minute, $Second, $Nanosecond,
249 $Am, $Pm
250 ) = ();
251
252 # Run the parser
25352µs my $parser = $self->{parser};
2545548µs537µs eval($parser);
# spent 37µs making 5 calls to DateTime::Format::Strptime::CORE:match, avg 7µs/call
25551µs die $@ if $@;
256
25754µs if ($self->{diagnostic}) {
258 print qq|
259
260Entered = $time_string
261Parser = $parser
262
263dow_name = $dow_name
264month_name = $month_name
265century = $century
266day = $day
267hour_24 = $hour_24
268hour_12 = $hour_12
269doy = $doy
270month = $month
271minute = $minute
272ampm = $ampm
273second = $second
274nanosecond = $nanosecond
275week_sun_0 = $week_sun_0
276dow_sun_0 = $dow_sun_0
277dow_mon_1 = $dow_mon_1
278week_mon_1 = $week_mon_1
279year_100 = $year_100
280year = $year
281ce_year = $ce_year
282tz_offset = $tz_offset
283tz_olson = $tz_olson
284timezone = $timezone
285epoch = $epoch
286iso_week_year = $iso_week_year
287iso_week_year_100 = $iso_week_year_100
288
289 |;
290
291 }
292
2935244µs11565µs $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
32153µs if ($tz_offset) {
322 $use_timezone = $tz_offset;
323 }
324
32552µs 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
33251µs 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
3465800ns $use_timezone = $self->{time_zone} unless ($use_timezone);
347
34853µs 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
35151µs 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:
3675800ns 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 }
38152µs if ($year) {
38251µs $self->local_croak("Your two year values ($year_100 and $year) do not match.") and return undef if ($Year && ($year != $Year));
38351µs $Year = $year;
384 }
3855900ns 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 }
38951µs $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
39451µs 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 }
42452µs if ($month) {
42551µs $self->local_croak("There is no use providing a month without providing a year.") and return undef unless $Year;
42654µs $self->local_croak("$month is too large to be a month of the year.") and return undef unless $month <= 12;
42751µs $self->local_croak("Your two month values ($month_name and $month) do not match.") and return undef if $Month and $month != $Month;
42851µs $Month = $month;
429 }
43051µs $self->local_croak("Your month value does not match your epoch.") and return undef if $epoch_dt and $Month and $Month != $epoch_dt->month;
4315900ns 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 }
44252µs $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
44652µs $self->local_croak("$day is too large to be a day of the month.") and return undef unless $day <= 31;
44752µs $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;
44853µs $Day ||= ($day)
449 ? $day
450 : ($doy_dt)
451 ? $doy_dt->day
452 : '';
45353µs if ($Day) {
45451µs $self->local_croak("There is no use providing a day without providing a month and year.") and return undef unless $Year and $Month;
45555µs my $dt = eval {
456514µs517.7ms 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 };
45852µs $self->local_croak("Datetime $Year-$Month-$Day is not a valid date") and return undef if $@;
459528µs517µs $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 }
46252µs $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
46653µs $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!
46752µs $self->local_croak("$hour_12 is too large to be an hour of the day.") and return undef unless $hour_12 <= 12;
46852µs $self->local_croak("You must specify am or pm for 12 hour clocks ($hour_12|$ampm).") and return undef if ($hour_12 && (! $ampm));
469520µs528µs ($Am, $Pm) = @{$self->{_locale}->am_pms};
# spent 28µs making 5 calls to DateTime::Locale::Base::am_pms, avg 6µs/call
47058µs 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 }
48156µs 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 }
48952µs $self->local_croak("Your hour does not match your epoch.") and return undef if $epoch_dt and $Hour and $Hour != $epoch_dt->hour;
49053µs print "Set hour to $Hour.\n" if $self->{diagnostic};
491
492 # Minutes
49353µs $self->local_croak("$minute is too large to be a minute.") and return undef unless $minute <= 59;
49452µs $Minute ||= $minute;
49552µs $self->local_croak("Your minute does not match your epoch.") and return undef if $epoch_dt and $Minute and $Minute != $epoch_dt->minute;
49652µs print "Set minute to $Minute.\n" if $self->{diagnostic};
497
498
499 # Seconds
50052µs $self->local_croak("$second is too large to be a second.") and return undef unless $second <= 59; #OK so leap seconds will break!
50152µs $Second ||= $second;
50251µs $self->local_croak("Your second does not match your epoch.") and return undef if $epoch_dt and $Second and $Second != $epoch_dt->second;
50352µs print "Set second to $Second.\n" if $self->{diagnostic};
504
505
506 # Nanoeconds
50755µs $self->local_croak("$nanosecond is too large to be a nanosecond.") and return undef unless length($nanosecond) <= 9;
50852µs $Nanosecond ||= $nanosecond;
50956µs $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;
51252µs print "Set nanosecond to $Nanosecond.\n" if $self->{diagnostic};
513
51454µs my $potential_return = eval {
515518µs51.54ms 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 };
52951µs $self->local_croak("Datetime is not a valid date") and return undef if $@;
530
53152µs $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
53352µs $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
53552µs if ($dow_name) {
536 my $dow_count = 0;
537 my $dow_number = 0;
538 foreach my $dow (@{$self->{_locale}->day_names}) {
539 $dow_count++;
540358µs221µ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
use bytes;
# 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++;
55031.76ms217µ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
use bytes;
# 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
56352µs $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;
56452µs $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;
56552µs $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;
56652µs $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
56953µs print "Potential Datetime: " . $potential_return->strftime("%F %T %z %Z") . "\n" if $self->{diagnostic};
57052µs print "Setting timezone: " . $self->{set_time_zone} . "\n" if $self->{diagnostic};
57153µs 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 }
57652µs print "Actual Datetime: " . $potential_return->strftime("%F %T %z %Z") . "\n" if $self->{diagnostic};
577
578530µs return $potential_return;
579}
580
581sub parse_duration {
582 croak "DateTime::Format::Strptime doesn't do durations.";
583}
584
585sub 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
592sub 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
sub _build_parser {
59952µs my $self = shift;
60056µs my $regex = my $field_list = shift;
60153µs if( ref $regex eq 'Regexp' ){
602 $field_list =~ s/^\(\?-xism:(.+)\)$/$1/;
603 }
604599µs566µs my @fields = $field_list =~ m/(%\{\w+\}|%\d*.)/g;
# spent 66µs making 5 calls to DateTime::Format::Strptime::CORE:match, avg 13µs/call
60556µs $field_list = join('',@fields);
606
607518µs52.18ms 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
610529µs542µs my $ampm_list = join('|', @{$self->{_locale}->am_pms});
# spent 42µs making 5 calls to DateTime::Locale::Base::am_pms, avg 8µs/call
61155µs $ampm_list .= '|' . lc $ampm_list;
612
613519µs5344µs 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
614556µs537µs 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
61556µs $default_date_format = join('',@locale_format);
616
617521µs5595µs 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
618558µs532µs @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
61954µs $default_time_format = join('',@locale_format);
620
621520µs5814µs 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
622580µs546µs @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
62355µs $default_datetime_format = join('',@locale_format);
624
62553µs print "Date format: $default_date_format\nTime format: $default_time_format\nDatetime format: $default_datetime_format\n" if $self->{diagnostic};
626
627516µs53µs $regex =~ s/%%/ovnksdjhvniurnvkjsdhfbngkjsdbnhuyw678rhiuwf/g;
# spent 3µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 620ns/call
628510µs52µs $field_list =~ s/%%/ovnksdjhvniurnvkjsdhfbngkjsdbnhuyw678rhiuwf/g;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 380ns/call
629
630511µs52µs $regex =~ s/%c/$self->{_locale}->default_datetime_format/eg;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 480ns/call
631510µs52µs $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
634512µs52µs $regex =~ s/%x/$self->{_locale}->default_date_format/eg;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 360ns/call
635511µs52µs $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
638510µs52µs $regex =~ s/%X/$self->{_locale}->default_time_format/eg;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 320ns/call
639510µs52µs $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
64255µs if( ref $regex ne 'Regexp' ){
64354µs $regex = quotemeta( $regex );
644535µs524µs $regex =~ s/(?<!\\)\\%/%/g;
# spent 24µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 5µs/call
645512µs53µs $regex =~ s/%\\\{([^\}]+)\\\}/%{$1}/g;
# spent 3µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 620ns/call
646 }
647
648513µs52µs $regex =~ s/%T/%H:%M:%S/g;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 400ns/call
64959µs52µs $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
65259µs51µs $regex =~ s/%r/%I:%M:%S %p/g;
# spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call
653510µs51µs $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
65659µs51µs $regex =~ s/%R/%H:%M/g;
# spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 220ns/call
65758µs5700ns $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
660510µs52µs $regex =~ s|%D|%m\\/%d\\/%y|g;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 380ns/call
66159µs51µs $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
66458µs51µs $regex =~ s|%F|%Y\\-%m\\-%d|g;
# spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 280ns/call
665511µs5800ns $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 }
6715165µs8593µs 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 );
67352µs $day_re .= '|' if $day_re;
674516µs55µs $regex =~ s/%a/($day_re\\w+)/gi;
# spent 5µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 940ns/call
675511µs52µs $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 }
6825328µs135203µs 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 );
68451µs $month_re .= '|' if $month_re;
68551µs $month_re .= '[^\\s\\d]+';
686519µs59µs $regex =~ s/%[bBh]/($month_re)/g;
# spent 9µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call
687515µs56µs $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
69559µs52µs $regex =~ s/%C/([\\d ]?\\d)/g;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 320ns/call
696510µs52µs $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
699528µs518µs $regex =~ s/%[de]/([\\d ]?\\d)/g;
# spent 18µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 4µs/call
700522µs513µs $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
704523µs514µs $regex =~ s/%[Hk]/([\\d ]?\\d)/g;
# spent 14µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 3µs/call
705524µs513µs $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
709511µs52µs $regex =~ s/%g/([\\d ]?\\d)/g;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 440ns/call
71059µs52µs $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
71359µs51µs $regex =~ s/%G/(\\d{4})/g;
# spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 280ns/call
714510µs5900ns $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
717515µs57µs $regex =~ s/%[Il]/([\\d ]?\\d)/g;
# spent 7µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 1µs/call
718514µs56µs $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
722511µs52µs $regex =~ s/%j/(\\d{1,3})/g;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 400ns/call
723510µs51µs $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
726518µs59µs $regex =~ s/%m/([\\d ]?\\d)/g;
# spent 9µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call
727518µs58µs $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
730518µs59µs $regex =~ s/%M/([\\d ]?\\d)/g;
# spent 9µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call
731518µs59µs $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
734514µs56µs $regex =~ s/%[nt]/\\s+/g;
# spent 6µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 1µs/call
735513µs55µs $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
739512µs53µs $regex =~ s/%p/($ampm_list)/gi;
# spent 3µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 540ns/call
74059µs52µs $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
74359µs51µs $regex =~ s/%s/(\\d+)/g;
# spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call
744510µs52µs $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
747519µs59µs $regex =~ s/%S/([\\d ]?\\d)/g;
# spent 9µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call
748518µs58µs $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
751561µs1527µs $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
752524µs514µs $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
755510µs52µs $regex =~ s/%U/([\\d ]?\\d)/g;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 380ns/call
756510µs52µs $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
75958µs51µs $regex =~ s/%w/([0-6])/g;
# spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call
76059µs51µs $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
76358µs51µs $regex =~ s/%u/([1-7])/g;
# spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 220ns/call
764510µs52µs $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
76759µs52µs $regex =~ s/%W/([\\d ]?\\d)/g;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 360ns/call
76858µs51µs $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
77158µs51µs $regex =~ s/%y/([\\d ]?\\d)/g;
# spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 260ns/call
77258µs51µs $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
775520µs510µs $regex =~ s/%Y/(\\d{4})/g;
# spent 10µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call
776518µs58µs $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
779519µs510µs $regex =~ s|%z|([+-]\\d{4})|g;
# spent 10µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 2µs/call
780517µs58µs $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
783510µs52µs $regex =~ s|%Z|(\\w+)|g;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 340ns/call
78459µs52µs $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
78759µs51µs $regex =~ s|%O|(\\w+\\/\\w+)|g;
# spent 1µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 240ns/call
78859µs52µs $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
79159µs52µs $regex =~ s|%{(\w+)}|($tempdt->can($1)) ? "(.+)" : ".+"|eg;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 480ns/call
792510µs52µs $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
795510µs52µs $regex =~ s/ovnksdjhvniurnvkjsdhfbngkjsdbnhuyw678rhiuwf/\\%/g;
# spent 2µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 440ns/call
79658µs5900ns $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
8005117µs5039µs $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
801523µs513µs $field_list=~s/,\s*$//;
# spent 13µs making 5 calls to DateTime::Format::Strptime::CORE:subst, avg 3µs/call
802
803559µs return qq|($field_list) = \$time_string =~ /$regex/|;
804}
805
806# Utility functions
807
808sub 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}
815sub 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
823sub 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
sub strftime {
830811µs my ($pattern, $dt) = @_;
831847µs81.58ms 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
sub strptime {
83557µs my ($pattern, $time_string) = @_;
836556µs1028.0ms 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
8401232µs1;
841__END__
842
843=head1 NAME
844
845DateTime::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
887This module implements most of C<strptime(3)>, the POSIX function that
888is the reverse of C<strftime(3)>, for C<DateTime>. While C<strftime>
889takes a C<DateTime> and a pattern and returns a string, C<strptime> takes
890a string and a pattern and returns the C<DateTime> object
891associated.
892
893=head1 CONSTRUCTOR
894
895=over 4
896
897=item * new( pattern=>$strptime_pattern )
898
899Creates the format object. You must specify a pattern, you can also
900specify a C<time_zone> and a C<locale>. If you specify a time zone
901then any resulting C<DateTime> object will be in that time zone. If you
902do not specify a C<time_zone> parameter, but there is a time zone in the
903string you pass to C<parse_datetime>, then the resulting C<DateTime> will
904use that time zone.
905
906You can optionally use an on_error parameter. This parameter has three
907valid options:
908
909=over 4
910
911=item * 'undef'
912
913(not undef, 'undef', it's a string not an undefined value)
914
915This is the default behavior. The module will return undef whenever it
916gets upset. The error can be accessed using the $object->errstr method.
917This is the ideal behaviour for interactive use where a user might
918provide 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
924This used to be the default behaviour. The module will croak with an
925error message whenever it gets upset.
926
927=item * sub{...} or \&subname
928
929When given a code ref, the module will call that sub when it gets upset.
930The sub receives two parameters: the object and the error message. Using
931these two it is possible to emulate the 'undef' behavior. (Returning a
932true value causes the method to return undef. Returning a false value
933causes the method to bravely continue):
934
935sub{$_[0]->{errmsg} = $_[1]; 1},
936
937=back
938
939=back
940
941=head1 METHODS
942
943This class offers the following methods.
944
945=over 4
946
947=item * parse_datetime($string)
948
949Given a string in the pattern specified in the constructor, this method
950will return a new C<DateTime> object.
951
952If given a string that doesn't match the pattern, the formatter will
953croak or return undef, depending on the setting of on_error in the constructor.
954
955=item * format_datetime($datetime)
956
957Given a C<DateTime> object, this methods returns a string formatted in
958the object's format. This method is synonymous with C<DateTime>'s
959strftime method.
960
961=item * locale($locale)
962
963When given a locale or C<DateTime::Locale> object, this method sets
964its locale appropriately. If the locale is not understood, the method
965will croak or return undef (depending on the setting of on_error in
966the constructor)
967
968If successful this method returns the current locale. (After
969processing as above).
970
971=item * pattern($strptime_pattern)
972
973When given a pattern, this method sets the object's pattern. If the
974pattern is invalid, the method will croak or return undef (depending on
975the value of the C<on_error> parameter)
976
977If successful this method returns the current pattern. (After processing
978as above)
979
980=item * time_zone($time_zone)
981
982When given a name, offset or C<DateTime::TimeZone> object, this method
983sets the object's time zone. This effects the C<DateTime> object
984returned by parse_datetime
985
986If the time zone is invalid, the method will croak or return undef
987(depending on the value of the C<on_error> parameter)
988
989If successful this method returns the current time zone. (After processing
990as above)
991
992=item * errmsg
993
994If the on_error behavior of the object is 'undef', error messages with
995this method so you can work out why things went wrong.
996
997This code emulates a C<$DateTime::Format::Strptime> with
998the C<on_error> parameter equal to C<'croak'>:
999
1000C<$Strp->pattern($pattern) or die $DateTime::Format::Strptime::errmsg>
1001
1002=back
1003
1004=head1 EXPORTS
1005
1006There are no methods exported by default, however the following are
1007available:
1008
1009=over 4
1010
1011=item * strptime($strptime_pattern, $string)
1012
1013Given a pattern and a string this function will return a new C<DateTime>
1014object.
1015
1016=item * strftime($strftime_pattern, $datetime)
1017
1018Given a pattern and a C<DateTime> object this function will return a
1019formatted string.
1020
1021=back
1022
1023=head1 STRPTIME PATTERN TOKENS
1024
1025The following tokens are allowed in the pattern string for strptime
1026(parse_datetime):
1027
1028=over 4
1029
1030=item * %%
1031
1032The % character.
1033
1034=item * %a or %A
1035
1036The weekday name according to the current locale, in abbreviated form or
1037the full name.
1038
1039=item * %b or %B or %h
1040
1041The month name according to the current locale, in abbreviated form or
1042the full name.
1043
1044=item * %C
1045
1046The century number (0-99).
1047
1048=item * %d or %e
1049
1050The day of month (1-31).
1051
1052=item * %D
1053
1054Equivalent to %m/%d/%y. (This is the American style date, very confusing
1055to non-Americans, especially since %d/%m/%y is widely used in Europe.
1056The ISO 8601 standard pattern is %F.)
1057
1058=item * %F
1059
1060Equivalent to %Y-%m-%d. (This is the ISO style date)
1061
1062=item * %g
1063
1064The year corresponding to the ISO week number, but without the century
1065(0-99).
1066
1067=item * %G
1068
1069The year corresponding to the ISO week number.
1070
1071=item * %H
1072
1073The hour (0-23).
1074
1075=item * %I
1076
1077The hour on a 12-hour clock (1-12).
1078
1079=item * %j
1080
1081The day number in the year (1-366).
1082
1083=item * %m
1084
1085The month number (1-12).
1086
1087=item * %M
1088
1089The minute (0-59).
1090
1091=item * %n
1092
1093Arbitrary whitespace.
1094
1095=item * %N
1096
1097Nanoseconds. For other sub-second values use C<%[number]N>.
1098
1099=item * %p
1100
1101The equivalent of AM or PM according to the locale in use. (See
1102L<DateTime::Locale>)
1103
1104=item * %r
1105
1106Equivalent to %I:%M:%S %p.
1107
1108=item * %R
1109
1110Equivalent to %H:%M.
1111
1112=item * %s
1113
1114Number of seconds since the Epoch.
1115
1116=item * %S
1117
1118The second (0-60; 60 may occur for leap seconds. See
1119L<DateTime::LeapSecond>).
1120
1121=item * %t
1122
1123Arbitrary whitespace.
1124
1125=item * %T
1126
1127Equivalent to %H:%M:%S.
1128
1129=item * %U
1130
1131The week number with Sunday the first day of the week (0-53). The first
1132Sunday of January is the first day of week 1.
1133
1134=item * %u
1135
1136The weekday number (1-7) with Monday = 1. This is the C<DateTime> standard.
1137
1138=item * %w
1139
1140The weekday number (0-6) with Sunday = 0.
1141
1142=item * %W
1143
1144The week number with Monday the first day of the week (0-53). The first
1145Monday of January is the first day of week 1.
1146
1147=item * %y
1148
1149The year within century (0-99). When a century is not otherwise
1150specified, values in the range 69-99 refer to years in the twen- tieth
1151century (1969-1999); values in the range 00-68 refer to years in the
1152twenty-first century (2000-2068).
1153
1154=item * %Y
1155
1156The year, including century (for example, 1991).
1157
1158=item * %z
1159
1160An RFC-822/ISO 8601 standard time zone specification. (For example
1161+1100) [See note below]
1162
1163=item * %Z
1164
1165The timezone name. (For example EST -- which is ambiguous) [See note
1166below]
1167
1168=item * %O
1169
1170This extended token allows the use of Olson Time Zone names to appear
1171in parsed strings. B<NOTE>: This pattern cannot be passed to C<DateTime>'s
1172C<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
1182Support for this module is primarily provided via the DateTime
1183Mailing List: C<datetime@perl.org>
1184
1185http://lists.cpan.org/showlist.cgi?name=datetime
1186
1187=item * Bugtracker
1188
1189For bug tracking and reporting, please use the google-code tracker
1190rather than the RT interface linked at search.cpan.org
1191
1192http://code.google.com/p/datetime-format-strptime/issues/list
1193
1194=item * Homepage
1195
1196http://datetime-format-strptime.googlecode.com/
1197
1198=item * Subversion Repository
1199
1200The latest version is always available via subversion:
1201
1202http://datetime-format-strptime.googlecode.com/svn/trunk/
1203
1204=back
1205
1206=head1 LICENSE AND COPYRIGHT
1207
1208Copyright E<169> Rick Measham, 2003-2007. All rights reserved.
1209
1210This library is free software; you can redistribute it and/or modify it
1211under the same terms as Perl itself.
1212
1213The full text of the licenses can be found in the F<LICENCE> file
1214included with this module.
1215
1216=head1 AUTHOR
1217
1218Rick Measham <rickm@cpan.org>
1219
1220=head1 SEE ALSO
1221
1222C<datetime@perl.org> mailing list.
1223
1224http://datetime.perl.org/
1225
1226L<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
sub DateTime::Format::Strptime::CORE:match; # xsub
# 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
sub DateTime::Format::Strptime::CORE:sort; # xsub
# 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
sub DateTime::Format::Strptime::CORE:subst; # xsub
# 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
sub DateTime::Format::Strptime::CORE:substcont; # xsub