← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 11:58:52 2013
Reported on Tue Oct 15 12:01:05 2013

Filename/usr/share/perl5/DateTime/Locale/Base.pm
StatementsExecuted 215 statements in 4.40ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111109µs124µsDateTime::Locale::Base::::BEGIN@11DateTime::Locale::Base::BEGIN@11
291153µs53µsDateTime::Locale::Base::::CORE:qrDateTime::Locale::Base::CORE:qr (opcode)
11141µs45µsDateTime::Locale::Base::::newDateTime::Locale::Base::new
11120µs24µsDateTime::Locale::Base::::BEGIN@3DateTime::Locale::Base::BEGIN@3
11119µs19µsDateTime::Locale::Base::::BEGIN@7DateTime::Locale::Base::BEGIN@7
11115µs69µsDateTime::Locale::Base::::BEGIN@6DateTime::Locale::Base::BEGIN@6
222114µs14µsDateTime::Locale::Base::::CORE:substDateTime::Locale::Base::CORE:subst (opcode)
11112µs37µsDateTime::Locale::Base::::BEGIN@363DateTime::Locale::Base::BEGIN@363
11112µs26µsDateTime::Locale::Base::::BEGIN@119DateTime::Locale::Base::BEGIN@119
11111µs26µsDateTime::Locale::Base::::BEGIN@176DateTime::Locale::Base::BEGIN@176
11111µs30µsDateTime::Locale::Base::::BEGIN@25DateTime::Locale::Base::BEGIN@25
1119µs52µsDateTime::Locale::Base::::BEGIN@9DateTime::Locale::Base::BEGIN@9
1119µs22µsDateTime::Locale::Base::::BEGIN@4DateTime::Locale::Base::BEGIN@4
1116µs6µsDateTime::Locale::Base::::BEGIN@8DateTime::Locale::Base::BEGIN@8
0000s0sDateTime::Locale::Base::::STORABLE_freezeDateTime::Locale::Base::STORABLE_freeze
0000s0sDateTime::Locale::Base::::STORABLE_thawDateTime::Locale::Base::STORABLE_thaw
0000s0sDateTime::Locale::Base::::__ANON__[:174]DateTime::Locale::Base::__ANON__[:174]
0000s0sDateTime::Locale::Base::::__ANON__[:218]DateTime::Locale::Base::__ANON__[:218]
0000s0sDateTime::Locale::Base::::__ANON__[:222]DateTime::Locale::Base::__ANON__[:222]
0000s0sDateTime::Locale::Base::::__ANON__[:224]DateTime::Locale::Base::__ANON__[:224]
0000s0sDateTime::Locale::Base::::__ANON__[:226]DateTime::Locale::Base::__ANON__[:226]
0000s0sDateTime::Locale::Base::::__ANON__[:227]DateTime::Locale::Base::__ANON__[:227]
0000s0sDateTime::Locale::Base::::__ANON__[:228]DateTime::Locale::Base::__ANON__[:228]
0000s0sDateTime::Locale::Base::::__ANON__[:231]DateTime::Locale::Base::__ANON__[:231]
0000s0sDateTime::Locale::Base::::__ANON__[:235]DateTime::Locale::Base::__ANON__[:235]
0000s0sDateTime::Locale::Base::::__ANON__[:237]DateTime::Locale::Base::__ANON__[:237]
0000s0sDateTime::Locale::Base::::__ANON__[:239]DateTime::Locale::Base::__ANON__[:239]
0000s0sDateTime::Locale::Base::::__ANON__[:240]DateTime::Locale::Base::__ANON__[:240]
0000s0sDateTime::Locale::Base::::__ANON__[:241]DateTime::Locale::Base::__ANON__[:241]
0000s0sDateTime::Locale::Base::::__ANON__[:244]DateTime::Locale::Base::__ANON__[:244]
0000s0sDateTime::Locale::Base::::__ANON__[:248]DateTime::Locale::Base::__ANON__[:248]
0000s0sDateTime::Locale::Base::::__ANON__[:250]DateTime::Locale::Base::__ANON__[:250]
0000s0sDateTime::Locale::Base::::__ANON__[:252]DateTime::Locale::Base::__ANON__[:252]
0000s0sDateTime::Locale::Base::::__ANON__[:253]DateTime::Locale::Base::__ANON__[:253]
0000s0sDateTime::Locale::Base::::__ANON__[:256]DateTime::Locale::Base::__ANON__[:256]
0000s0sDateTime::Locale::Base::::__ANON__[:257]DateTime::Locale::Base::__ANON__[:257]
0000s0sDateTime::Locale::Base::::__ANON__[:259]DateTime::Locale::Base::__ANON__[:259]
0000s0sDateTime::Locale::Base::::__ANON__[:263]DateTime::Locale::Base::__ANON__[:263]
0000s0sDateTime::Locale::Base::::__ANON__[:265]DateTime::Locale::Base::__ANON__[:265]
0000s0sDateTime::Locale::Base::::__ANON__[:267]DateTime::Locale::Base::__ANON__[:267]
0000s0sDateTime::Locale::Base::::__ANON__[:268]DateTime::Locale::Base::__ANON__[:268]
0000s0sDateTime::Locale::Base::::__ANON__[:26]DateTime::Locale::Base::__ANON__[:26]
0000s0sDateTime::Locale::Base::::__ANON__[:271]DateTime::Locale::Base::__ANON__[:271]
0000s0sDateTime::Locale::Base::::__ANON__[:272]DateTime::Locale::Base::__ANON__[:272]
0000s0sDateTime::Locale::Base::::__ANON__[:280]DateTime::Locale::Base::__ANON__[:280]
0000s0sDateTime::Locale::Base::::__ANON__[:291]DateTime::Locale::Base::__ANON__[:291]
0000s0sDateTime::Locale::Base::::__ANON__[:295]DateTime::Locale::Base::__ANON__[:295]
0000s0sDateTime::Locale::Base::::__ANON__[:299]DateTime::Locale::Base::__ANON__[:299]
0000s0sDateTime::Locale::Base::::__ANON__[:303]DateTime::Locale::Base::__ANON__[:303]
0000s0sDateTime::Locale::Base::::__ANON__[:307]DateTime::Locale::Base::__ANON__[:307]
0000s0sDateTime::Locale::Base::::__ANON__[:311]DateTime::Locale::Base::__ANON__[:311]
0000s0sDateTime::Locale::Base::::__ANON__[:315]DateTime::Locale::Base::__ANON__[:315]
0000s0sDateTime::Locale::Base::::__ANON__[:319]DateTime::Locale::Base::__ANON__[:319]
0000s0sDateTime::Locale::Base::::__ANON__[:323]DateTime::Locale::Base::__ANON__[:323]
0000s0sDateTime::Locale::Base::::__ANON__[:327]DateTime::Locale::Base::__ANON__[:327]
0000s0sDateTime::Locale::Base::::__ANON__[:331]DateTime::Locale::Base::__ANON__[:331]
0000s0sDateTime::Locale::Base::::__ANON__[:335]DateTime::Locale::Base::__ANON__[:335]
0000s0sDateTime::Locale::Base::::__ANON__[:339]DateTime::Locale::Base::__ANON__[:339]
0000s0sDateTime::Locale::Base::::__ANON__[:343]DateTime::Locale::Base::__ANON__[:343]
0000s0sDateTime::Locale::Base::::__ANON__[:347]DateTime::Locale::Base::__ANON__[:347]
0000s0sDateTime::Locale::Base::::__ANON__[:351]DateTime::Locale::Base::__ANON__[:351]
0000s0sDateTime::Locale::Base::::__ANON__[:361]DateTime::Locale::Base::__ANON__[:361]
0000s0sDateTime::Locale::Base::::_available_formatsDateTime::Locale::Base::_available_formats
0000s0sDateTime::Locale::Base::::_cldr_to_strftimeDateTime::Locale::Base::_cldr_to_strftime
0000s0sDateTime::Locale::Base::::_convertDateTime::Locale::Base::_convert
0000s0sDateTime::Locale::Base::::_convert_to_strftimeDateTime::Locale::Base::_convert_to_strftime
0000s0sDateTime::Locale::Base::::_make_datetime_formatDateTime::Locale::Base::_make_datetime_format
0000s0sDateTime::Locale::Base::::_self_and_super_pathDateTime::Locale::Base::_self_and_super_path
0000s0sDateTime::Locale::Base::::_stringifyDateTime::Locale::Base::_stringify
0000s0sDateTime::Locale::Base::::available_formatsDateTime::Locale::Base::available_formats
0000s0sDateTime::Locale::Base::::date_format_defaultDateTime::Locale::Base::date_format_default
0000s0sDateTime::Locale::Base::::date_formatsDateTime::Locale::Base::date_formats
0000s0sDateTime::Locale::Base::::datetime_format_defaultDateTime::Locale::Base::datetime_format_default
0000s0sDateTime::Locale::Base::::default_date_format_lengthDateTime::Locale::Base::default_date_format_length
0000s0sDateTime::Locale::Base::::default_time_format_lengthDateTime::Locale::Base::default_time_format_length
0000s0sDateTime::Locale::Base::::format_forDateTime::Locale::Base::format_for
0000s0sDateTime::Locale::Base::::language_idDateTime::Locale::Base::language_id
0000s0sDateTime::Locale::Base::::prefers_24_hour_timeDateTime::Locale::Base::prefers_24_hour_time
0000s0sDateTime::Locale::Base::::script_idDateTime::Locale::Base::script_id
0000s0sDateTime::Locale::Base::::set_default_date_format_lengthDateTime::Locale::Base::set_default_date_format_length
0000s0sDateTime::Locale::Base::::set_default_time_format_lengthDateTime::Locale::Base::set_default_time_format_length
0000s0sDateTime::Locale::Base::::territory_idDateTime::Locale::Base::territory_id
0000s0sDateTime::Locale::Base::::time_format_defaultDateTime::Locale::Base::time_format_default
0000s0sDateTime::Locale::Base::::time_formatsDateTime::Locale::Base::time_formats
0000s0sDateTime::Locale::Base::::variant_idDateTime::Locale::Base::variant_id
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DateTime::Locale::Base;
2
3329µs228µs
# spent 24µs (20+4) within DateTime::Locale::Base::BEGIN@3 which was called: # once (20µs+4µs) by DateTime::Locale::BEGIN@10 at line 3
use strict;
# spent 24µs making 1 call to DateTime::Locale::Base::BEGIN@3 # spent 4µs making 1 call to strict::import
4335µs234µs
# spent 22µs (9+13) within DateTime::Locale::Base::BEGIN@4 which was called: # once (9µs+13µs) by DateTime::Locale::BEGIN@10 at line 4
use warnings;
# spent 22µs making 1 call to DateTime::Locale::Base::BEGIN@4 # spent 13µs making 1 call to warnings::import
5
6338µs2124µs
# spent 69µs (15+54) within DateTime::Locale::Base::BEGIN@6 which was called: # once (15µs+54µs) by DateTime::Locale::BEGIN@10 at line 6
use Carp qw( carp );
# spent 69µs making 1 call to DateTime::Locale::Base::BEGIN@6 # spent 54µs making 1 call to Exporter::import
7352µs119µs
# spent 19µs within DateTime::Locale::Base::BEGIN@7 which was called: # once (19µs+0s) by DateTime::Locale::BEGIN@10 at line 7
use DateTime::Locale;
# spent 19µs making 1 call to DateTime::Locale::Base::BEGIN@7
8326µs16µs
# spent 6µs within DateTime::Locale::Base::BEGIN@8 which was called: # once (6µs+0s) by DateTime::Locale::BEGIN@10 at line 8
use List::MoreUtils ();
# spent 6µs making 1 call to DateTime::Locale::Base::BEGIN@8
9386µs294µs
# spent 52µs (9+42) within DateTime::Locale::Base::BEGIN@9 which was called: # once (9µs+42µs) by DateTime::Locale::BEGIN@10 at line 9
use Params::Validate qw( validate_pos );
# spent 52µs making 1 call to DateTime::Locale::Base::BEGIN@9 # spent 42µs making 1 call to Exporter::import
10
11
# spent 124µs (109+14) within DateTime::Locale::Base::BEGIN@11 which was called: # once (109µs+14µs) by DateTime::Locale::BEGIN@10 at line 28
BEGIN {
1234123µs foreach my $field (
13 qw( id en_complete_name native_complete_name
14 en_language en_script en_territory en_variant
15 native_language native_script native_territory native_variant
16 )
17 ) {
18
19 # remove leading 'en_' for method name
20119µs ( my $meth_name = $field ) =~ s/^en_//;
# spent 9µs making 11 calls to DateTime::Locale::Base::CORE:subst, avg 818ns/call
21
22 # also remove 'complete_'
23115µs $meth_name =~ s/complete_//;
# spent 5µs making 11 calls to DateTime::Locale::Base::CORE:subst, avg 491ns/call
24
25359µs249µs
# spent 30µs (11+19) within DateTime::Locale::Base::BEGIN@25 which was called: # once (11µs+19µs) by DateTime::Locale::BEGIN@10 at line 25
no strict 'refs';
# spent 30µs making 1 call to DateTime::Locale::Base::BEGIN@25 # spent 19µs making 1 call to strict::unimport
26 *{$meth_name} = sub { $_[0]->{$field} };
27 }
281528µs1124µs}
# spent 124µs making 1 call to DateTime::Locale::Base::BEGIN@11
29
30
# spent 45µs (41+4) within DateTime::Locale::Base::new which was called: # once (41µs+4µs) by DateTime::Locale::_load_class_from_id at line 286 of DateTime/Locale.pm
sub new {
31234µs my $class = shift;
32
33 # By making the default format lengths part of the object's hash
34 # key, it allows them to be settable.
3524µs return bless {
36 @_,
37 default_date_format_length => $class->_default_date_format_length(),
38 default_time_format_length => $class->_default_time_format_length(),
39 }, $class;
40}
41
42sub language_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[0] }
43sub script_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[1] }
44sub territory_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[2] }
45sub variant_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[3] }
46
4712µsmy @FormatLengths = qw( short medium long full );
48
49sub date_format_default {
50 my $meth = 'date_format_' . $_[0]->default_date_format_length();
51 $_[0]->$meth();
52}
53
54sub date_formats {
55 return {
56 map {
57 my $meth = 'date_format_' . $_;
58 $_ => $_[0]->$meth()
59 } @FormatLengths
60 };
61}
62
63sub time_format_default {
64 my $meth = 'time_format_' . $_[0]->default_time_format_length();
65 $_[0]->$meth();
66}
67
68sub time_formats {
69 return {
70 map {
71 my $meth = 'time_format_' . $_;
72 $_ => $_[0]->$meth()
73 } @FormatLengths
74 };
75}
76
77sub format_for {
78 my $self = shift;
79 my $for = shift;
80
81 my $meth = '_format_for_' . $for;
82
83 return unless $self->can($meth);
84
85 return $self->$meth();
86}
87
88sub available_formats {
89 my $self = shift;
90
91 # The various parens seem to be necessary to force uniq() to see
92 # the caller's list context. Go figure.
93 my @uniq
94 = List::MoreUtils::uniq(
95 map { keys %{ $_->_available_formats() || {} } }
96 _self_and_super_path( ref $self ) );
97
98 # Doing the sort in the same expression doesn't work under 5.6.x.
99 return sort @uniq;
100}
101
102# Copied wholesale from Class::ISA, because said module warns as deprecated
103# with perl 5.11.0+, which is kind of annoying.
104sub _self_and_super_path {
105 # Assumption: searching is depth-first.
106 # Assumption: '' (empty string) can't be a class package name.
107 # Note: 'UNIVERSAL' is not given any special treatment.
108 return () unless @_;
109
110 my @out = ();
111
112 my @in_stack = ($_[0]);
113 my %seen = ($_[0] => 1);
114
115 my $current;
116 while(@in_stack) {
117 next unless defined($current = shift @in_stack) && length($current);
118 push @out, $current;
1193395µs241µs
# spent 26µs (12+15) within DateTime::Locale::Base::BEGIN@119 which was called: # once (12µs+15µs) by DateTime::Locale::BEGIN@10 at line 119
no strict 'refs';
# spent 26µs making 1 call to DateTime::Locale::Base::BEGIN@119 # spent 15µs making 1 call to strict::unimport
120 unshift @in_stack,
121 map
122 { my $c = $_; # copy, to avoid being destructive
123 substr($c,0,2) = "main::" if substr($c,0,2) eq '::';
124 # Canonize the :: -> main::, ::foo -> main::foo thing.
125 # Should I ever canonize the Foo'Bar = Foo::Bar thing?
126 $seen{$c}++ ? () : $c;
127 }
128 @{"$current\::ISA"}
129 ;
130 # I.e., if this class has any parents (at least, ones I've never seen
131 # before), push them, in order, onto the stack of classes I need to
132 # explore.
133 }
134
135 return @out;
136}
137
138# Just needed for the above method.
139sub _available_formats { }
140
141sub default_date_format_length { $_[0]->{default_date_format_length} }
142
143sub set_default_date_format_length {
144 my $self = shift;
145 my ($l)
146 = validate_pos( @_, { regex => qr/^(?:full|long|medium|short)$/i } );
147
148 $self->{default_date_format_length} = lc $l;
149}
150
151sub default_time_format_length { $_[0]->{default_time_format_length} }
152
153sub set_default_time_format_length {
154 my $self = shift;
155 my ($l)
156 = validate_pos( @_, { regex => qr/^(?:full|long|medium|short)/i } );
157
158 $self->{default_time_format_length} = lc $l;
159}
160
16112µsfor my $length (qw( full long medium short )) {
16243µs my $key = 'datetime_format_' . $length;
163
164 my $sub = sub {
165 my $self = shift;
166
167 return $self->{$key} if exists $self->{$key};
168
169 my $date_meth = 'date_format_' . $length;
170 my $time_meth = 'time_format_' . $length;
171
172 return $self->{$key}
173 = $self->_make_datetime_format( $date_meth, $time_meth );
17449µs };
175
17631.76ms241µs
# spent 26µs (11+15) within DateTime::Locale::Base::BEGIN@176 which was called: # once (11µs+15µs) by DateTime::Locale::BEGIN@10 at line 176
no strict 'refs';
# spent 26µs making 1 call to DateTime::Locale::Base::BEGIN@176 # spent 15µs making 1 call to strict::unimport
177412µs *{$key} = $sub;
178}
179
180sub datetime_format_default {
181 my $self = shift;
182
183 my $date_meth = 'date_format_' . $self->default_date_format_length();
184 my $time_meth = 'time_format_' . $self->default_time_format_length();
185
186 return $self->_make_datetime_format( $date_meth, $time_meth );
187}
188
189sub _make_datetime_format {
190 my $self = shift;
191 my $date_meth = shift;
192 my $time_meth = shift;
193
194 my $dt_format = $self->datetime_format();
195
196 my $time = $self->$time_meth();
197 my $date = $self->$date_meth();
198
199 $dt_format =~ s/\{0\}/$time/g;
200 $dt_format =~ s/\{1\}/$date/g;
201
202 return $dt_format;
203}
204
205sub prefers_24_hour_time {
206 my $self = shift;
207
208 return $self->{prefers_24_hour_time}
209 if exists $self->{prefers_24_hour_time};
210
211 $self->{prefers_24_hour_time}
212 = $self->time_format_short() =~ /h|K/ ? 0 : 1;
213}
214
215# Backwards compat for DateTime.pm version <= 0.42
216{
21711µs my %subs = (
218 month_name => sub { $_[0]->month_format_wide()->[ $_[1]->month_0 ] },
219
220 month_abbreviation => sub {
221 $_[0]->month_format_abbreviated()->[ $_[1]->month_0 ];
222 },
223 month_narrow =>
224 sub { $_[0]->month_format_narrow()->[ $_[1]->month_0 ]; },
225
226 month_names => sub { $_[0]->month_format_wide() },
227 month_abbreviations => sub { $_[0]->month_format_abbreviated() },
228 month_narrows => sub { $_[0]->month_format_narrow() },
229
230 day_name =>
231 sub { $_[0]->day_format_wide()->[ $_[1]->day_of_week_0 ] },
232
233 day_abbreviation => sub {
234 $_[0]->day_format_abbreviated()->[ $_[1]->day_of_week_0 ];
235 },
236 day_narrow =>
237 sub { $_[0]->day_format_narrow()->[ $_[1]->day_of_week_0 ]; },
238
239 day_names => sub { $_[0]->day_format_wide() },
240 day_abbreviations => sub { $_[0]->day_format_abbreviated() },
241 day_narrows => sub { $_[0]->day_format_narrow() },
242
243 quarter_name =>
244 sub { $_[0]->quarter_format_wide()->[ $_[1]->quarter - 1 ] },
245
246 quarter_abbreviation => sub {
247 $_[0]->quarter_format_abbreviated()->[ $_[1]->quarter - 1 ];
248 },
249 quarter_narrow =>
250 sub { $_[0]->quarter_format_narrow()->[ $_[1]->quarter - 1 ] },
251
252 quarter_names => sub { $_[0]->quarter_format_wide() },
253 quarter_abbreviations => sub { $_[0]->quarter_format_abbreviated() },
254
255 am_pm =>
256 sub { $_[0]->am_pm_abbreviated()->[ $_[1]->hour < 12 ? 0 : 1 ] },
257 am_pms => sub { $_[0]->am_pm_abbreviated() },
258
259 era_name => sub { $_[0]->era_wide()->[ $_[1]->ce_year < 0 ? 0 : 1 ] },
260
261 era_abbreviation => sub {
262 $_[0]->era_abbreviated()->[ $_[1]->ce_year < 0 ? 0 : 1 ];
263 },
264 era_narrow =>
265 sub { $_[0]->era_narrow()->[ $_[1]->ce_year < 0 ? 0 : 1 ] },
266
267 era_names => sub { $_[0]->era_wide() },
268 era_abbreviations => sub { $_[0]->era_abbreviated() },
269
270 # ancient backwards compat
271 era => sub { $_[0]->era_abbreviation },
272 eras => sub { $_[0]->era_abbreviations },
273
274 date_before_time => sub {
275 my $self = shift;
276
277 my $dt_format = $self->datetime_format();
278
279 return $dt_format =~ /\{1\}.*\{0\}/ ? 1 : 0;
280 },
281
282 date_parts_order => sub {
283 my $self = shift;
284
285 my $short = $self->date_format_short();
286
287 $short =~ tr{dmyDMY}{}cd;
288 $short =~ tr{dmyDMY}{dmydmy}s;
289
290 return $short;
291 },
292
293 full_date_format => sub {
294 $_[0]->_convert_to_strftime( $_[0]->date_format_full() );
295 },
296
297 long_date_format => sub {
298 $_[0]->_convert_to_strftime( $_[0]->date_format_long() );
299 },
300
301 medium_date_format => sub {
302 $_[0]->_convert_to_strftime( $_[0]->date_format_medium() );
303 },
304
305 short_date_format => sub {
306 $_[0]->_convert_to_strftime( $_[0]->date_format_short() );
307 },
308
309 default_date_format => sub {
310 $_[0]->_convert_to_strftime( $_[0]->date_format_default() );
311 },
312
313 full_time_format => sub {
314 $_[0]->_convert_to_strftime( $_[0]->time_format_full() );
315 },
316
317 long_time_format => sub {
318 $_[0]->_convert_to_strftime( $_[0]->time_format_long() );
319 },
320
321 medium_time_format => sub {
322 $_[0]->_convert_to_strftime( $_[0]->time_format_medium() );
323 },
324
325 short_time_format => sub {
326 $_[0]->_convert_to_strftime( $_[0]->time_format_short() );
327 },
328
329 default_time_format => sub {
330 $_[0]->_convert_to_strftime( $_[0]->time_format_default() );
331 },
332
333 full_datetime_format => sub {
334 $_[0]->_convert_to_strftime( $_[0]->datetime_format_full() );
335 },
336
337 long_datetime_format => sub {
338 $_[0]->_convert_to_strftime( $_[0]->datetime_format_long() );
339 },
340
341 medium_datetime_format => sub {
342 $_[0]->_convert_to_strftime( $_[0]->datetime_format_medium() );
343 },
344
345 short_datetime_format => sub {
346 $_[0]->_convert_to_strftime( $_[0]->datetime_format_short() );
347 },
348
349 default_datetime_format => sub {
350 $_[0]->_convert_to_strftime( $_[0]->datetime_format_default() );
351 },
352187µs );
353
35419µs for my $name ( keys %subs ) {
3554318µs my $real_sub = $subs{$name};
356
357 my $sub = sub {
358 carp
359 "The $name method in DateTime::Locale::Base has been deprecated. Please see the DateTime::Locale distribution's Changes file for details";
360 return shift->$real_sub(@_);
36143123µs };
362
3633693µs261µs
# spent 37µs (12+24) within DateTime::Locale::Base::BEGIN@363 which was called: # once (12µs+24µs) by DateTime::Locale::BEGIN@10 at line 363
no strict 'refs';
# spent 37µs making 1 call to DateTime::Locale::Base::BEGIN@363 # spent 24µs making 1 call to strict::unimport
36443127µs *{$name} = $sub;
365 }
366}
367
368# Older versions of DateTime.pm will not pass in the $cldr_ok flag, so
369# we will give them the converted-to-strftime pattern (bugs and all).
370sub _convert_to_strftime {
371 my $self = shift;
372 my $pattern = shift;
373 my $cldr_ok = shift;
374
375 return $pattern if $cldr_ok;
376
377 return $self->{_converted_patterns}{$pattern}
378 if exists $self->{_converted_patterns}{$pattern};
379
380 return $self->{_converted_patterns}{$pattern}
381 = $self->_cldr_to_strftime($pattern);
382}
383
384{
3852124µs2953µs my @JavaPatterns = (
# spent 53µs making 29 calls to DateTime::Locale::Base::CORE:qr, avg 2µs/call
386 qr/G/ => '{era}',
387 qr/yyyy/ => '{ce_year}',
388 qr/y/ => 'y',
389 qr/u/ => 'Y',
390 qr/MMMM/ => 'B',
391 qr/MMM/ => 'b',
392 qr/MM/ => 'm',
393 qr/M/ => '{month}',
394 qr/dd/ => 'd',
395 qr/d/ => '{day}',
396 qr/hh/ => 'l',
397 qr/h/ => '{hour_12}',
398 qr/HH/ => 'H',
399 qr/H/ => '{hour}',
400 qr/mm/ => 'M',
401 qr/m/ => '{minute}',
402 qr/ss/ => 'S',
403 qr/s/ => '{second}',
404 qr/S/ => 'N',
405 qr/EEEE/ => 'A',
406 qr/E/ => 'a',
407 qr/D/ => 'j',
408 qr/F/ => '{weekday_of_month}',
409 qr/w/ => 'V',
410 qr/W/ => '{week_month}',
411 qr/a/ => 'p',
412 qr/k/ => '{hour_1}',
413 qr/K/ => '{hour_12_0}',
414 qr/z/ => '{time_zone_long_name}',
415 );
416
417 sub _cldr_to_strftime {
418 shift;
419 my $simple = shift;
420
421 $simple
422 =~ s/(G+|y+|u+|M+|d+|h+|H+|m+|s+|S+|E+|D+|F+|w+|W+|a+|k+|K+|z+)|'((?:[^']|'')*)'/
423 $2 ? _stringify($2) : $1 ? _convert($1) : "'"/eg;
424
425 return $simple;
426 }
427
428 sub _convert {
429 my $simple = shift;
430
431 for ( my $x = 0; $x < @JavaPatterns; $x += 2 ) {
432 return '%' . $JavaPatterns[ $x + 1 ]
433 if $simple =~ /$JavaPatterns[$x]/;
434 }
435
436 die "**Dont know $simple***";
437 }
438
439 sub _stringify {
440 my $string = shift;
441
442 $string =~ s/%(?:[^%])/%%/g;
443 $string =~ s/\'\'/\'/g;
444
445 return $string;
446 }
447}
448
449# end backwards compat
450
451sub STORABLE_freeze {
452 my $self = shift;
453 my $cloning = shift;
454
455 return if $cloning;
456
457 return $self->id();
458}
459
460sub STORABLE_thaw {
461 my $self = shift;
462 my $cloning = shift;
463 my $serialized = shift;
464
465 my $obj = DateTime::Locale->load($serialized);
466
467 %$self = %$obj;
468
469 return $self;
470}
471
472129µs1;
473
474__END__
 
# spent 53µs within DateTime::Locale::Base::CORE:qr which was called 29 times, avg 2µs/call: # 29 times (53µs+0s) by DateTime::Locale::BEGIN@10 at line 385, avg 2µs/call
sub DateTime::Locale::Base::CORE:qr; # opcode
# spent 14µs within DateTime::Locale::Base::CORE:subst which was called 22 times, avg 655ns/call: # 11 times (9µs+0s) by DateTime::Locale::Base::BEGIN@11 at line 20, avg 818ns/call # 11 times (5µs+0s) by DateTime::Locale::Base::BEGIN@11 at line 23, avg 491ns/call
sub DateTime::Locale::Base::CORE:subst; # opcode