← 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:09 2010

File /usr/local/lib/perl5/site_perl/5.10.1/DateTime/Locale/Base.pm
Statements Executed 721
Statement Execution Time 4.82ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1411779µs1.00msDateTime::Locale::Base::::_convertDateTime::Locale::Base::_convert
1711454µs1.30msDateTime::Locale::Base::::STORABLE_thawDateTime::Locale::Base::STORABLE_thaw
111417µs550µsDateTime::Locale::Base::::BEGIN@6DateTime::Locale::Base::BEGIN@6
17812171µs171µsDateTime::Locale::Base::::CORE:regcompDateTime::Locale::Base::CORE:regcomp (opcode)
311104µs1.16msDateTime::Locale::Base::::_cldr_to_strftimeDateTime::Locale::Base::_cldr_to_strftime
51196µs144µsDateTime::Locale::Base::::_make_datetime_formatDateTime::Locale::Base::_make_datetime_format
131193µs139µsDateTime::Locale::Base::::STORABLE_freezeDateTime::Locale::Base::STORABLE_freeze
153184µs1.25msDateTime::Locale::Base::::_convert_to_strftimeDateTime::Locale::Base::_convert_to_strftime
11181µs91µsDateTime::Locale::Base::::BEGIN@12DateTime::Locale::Base::BEGIN@12
51171µs228µsDateTime::Locale::Base::::datetime_format_defaultDateTime::Locale::Base::datetime_format_default
21159µs66µsDateTime::Locale::Base::::newDateTime::Locale::Base::new
51155µs75µsDateTime::Locale::Base::::date_format_defaultDateTime::Locale::Base::date_format_default
51154µs74µsDateTime::Locale::Base::::time_format_defaultDateTime::Locale::Base::time_format_default
102152µs70µsDateTime::Locale::Base::::am_pmsDateTime::Locale::Base::am_pms
1781250µs50µsDateTime::Locale::Base::::CORE:matchDateTime::Locale::Base::CORE:match (opcode)
51148µs344µsDateTime::Locale::Base::::default_date_formatDateTime::Locale::Base::default_date_format
171247µs47µsDateTime::Locale::Base::::CORE:substcontDateTime::Locale::Base::CORE:substcont (opcode)
355247µs47µsDateTime::Locale::Base::::CORE:substDateTime::Locale::Base::CORE:subst (opcode)
131146µs46µsDateTime::Locale::Base::::__ANON__[:26]DateTime::Locale::Base::__ANON__[:26]
51142µs595µsDateTime::Locale::Base::::default_time_formatDateTime::Locale::Base::default_time_format
51140µs814µsDateTime::Locale::Base::::default_datetime_formatDateTime::Locale::Base::default_datetime_format
51127µs36µsDateTime::Locale::Base::::day_namesDateTime::Locale::Base::day_names
51126µs34µsDateTime::Locale::Base::::month_namesDateTime::Locale::Base::month_names
51124µs32µsDateTime::Locale::Base::::day_abbreviationsDateTime::Locale::Base::day_abbreviations
51124µs33µsDateTime::Locale::Base::::month_abbreviationsDateTime::Locale::Base::month_abbreviations
291224µs24µsDateTime::Locale::Base::::CORE:qrDateTime::Locale::Base::CORE:qr (opcode)
102119µs19µsDateTime::Locale::Base::::default_date_format_lengthDateTime::Locale::Base::default_date_format_length
102118µs18µsDateTime::Locale::Base::::default_time_format_lengthDateTime::Locale::Base::default_time_format_length
11114µs16µsDateTime::Locale::Base::::BEGIN@3DateTime::Locale::Base::BEGIN@3
1118µs8µsDateTime::Locale::Base::::BEGIN@7DateTime::Locale::Base::BEGIN@7
1118µs16µsDateTime::Locale::Base::::BEGIN@4DateTime::Locale::Base::BEGIN@4
1118µs19µsDateTime::Locale::Base::::BEGIN@138DateTime::Locale::Base::BEGIN@138
1117µs18µsDateTime::Locale::Base::::BEGIN@25DateTime::Locale::Base::BEGIN@25
1117µs37µsDateTime::Locale::Base::::BEGIN@9DateTime::Locale::Base::BEGIN@9
1114µs4µsDateTime::Locale::Base::::BEGIN@8DateTime::Locale::Base::BEGIN@8
0000s0sDateTime::Locale::Base::::__ANON__[:136]DateTime::Locale::Base::__ANON__[:136]
0000s0sDateTime::Locale::Base::::_available_formatsDateTime::Locale::Base::_available_formats
0000s0sDateTime::Locale::Base::::_stringifyDateTime::Locale::Base::_stringify
0000s0sDateTime::Locale::Base::::am_pmDateTime::Locale::Base::am_pm
0000s0sDateTime::Locale::Base::::available_formatsDateTime::Locale::Base::available_formats
0000s0sDateTime::Locale::Base::::date_before_timeDateTime::Locale::Base::date_before_time
0000s0sDateTime::Locale::Base::::date_formatsDateTime::Locale::Base::date_formats
0000s0sDateTime::Locale::Base::::date_parts_orderDateTime::Locale::Base::date_parts_order
0000s0sDateTime::Locale::Base::::day_abbreviationDateTime::Locale::Base::day_abbreviation
0000s0sDateTime::Locale::Base::::day_nameDateTime::Locale::Base::day_name
0000s0sDateTime::Locale::Base::::day_narrowDateTime::Locale::Base::day_narrow
0000s0sDateTime::Locale::Base::::day_narrowsDateTime::Locale::Base::day_narrows
0000s0sDateTime::Locale::Base::::eraDateTime::Locale::Base::era
0000s0sDateTime::Locale::Base::::era_abbreviationDateTime::Locale::Base::era_abbreviation
0000s0sDateTime::Locale::Base::::era_abbreviationsDateTime::Locale::Base::era_abbreviations
0000s0sDateTime::Locale::Base::::era_nameDateTime::Locale::Base::era_name
0000s0sDateTime::Locale::Base::::era_namesDateTime::Locale::Base::era_names
0000s0sDateTime::Locale::Base::::era_narrowDateTime::Locale::Base::era_narrow
0000s0sDateTime::Locale::Base::::erasDateTime::Locale::Base::eras
0000s0sDateTime::Locale::Base::::format_forDateTime::Locale::Base::format_for
0000s0sDateTime::Locale::Base::::full_date_formatDateTime::Locale::Base::full_date_format
0000s0sDateTime::Locale::Base::::full_datetime_formatDateTime::Locale::Base::full_datetime_format
0000s0sDateTime::Locale::Base::::full_time_formatDateTime::Locale::Base::full_time_format
0000s0sDateTime::Locale::Base::::language_idDateTime::Locale::Base::language_id
0000s0sDateTime::Locale::Base::::long_date_formatDateTime::Locale::Base::long_date_format
0000s0sDateTime::Locale::Base::::long_datetime_formatDateTime::Locale::Base::long_datetime_format
0000s0sDateTime::Locale::Base::::long_time_formatDateTime::Locale::Base::long_time_format
0000s0sDateTime::Locale::Base::::medium_date_formatDateTime::Locale::Base::medium_date_format
0000s0sDateTime::Locale::Base::::medium_datetime_formatDateTime::Locale::Base::medium_datetime_format
0000s0sDateTime::Locale::Base::::medium_time_formatDateTime::Locale::Base::medium_time_format
0000s0sDateTime::Locale::Base::::month_abbreviationDateTime::Locale::Base::month_abbreviation
0000s0sDateTime::Locale::Base::::month_nameDateTime::Locale::Base::month_name
0000s0sDateTime::Locale::Base::::month_narrowDateTime::Locale::Base::month_narrow
0000s0sDateTime::Locale::Base::::month_narrowsDateTime::Locale::Base::month_narrows
0000s0sDateTime::Locale::Base::::prefers_24_hour_timeDateTime::Locale::Base::prefers_24_hour_time
0000s0sDateTime::Locale::Base::::quarter_abbreviationDateTime::Locale::Base::quarter_abbreviation
0000s0sDateTime::Locale::Base::::quarter_abbreviationsDateTime::Locale::Base::quarter_abbreviations
0000s0sDateTime::Locale::Base::::quarter_nameDateTime::Locale::Base::quarter_name
0000s0sDateTime::Locale::Base::::quarter_namesDateTime::Locale::Base::quarter_names
0000s0sDateTime::Locale::Base::::quarter_narrowDateTime::Locale::Base::quarter_narrow
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::::short_date_formatDateTime::Locale::Base::short_date_format
0000s0sDateTime::Locale::Base::::short_datetime_formatDateTime::Locale::Base::short_datetime_format
0000s0sDateTime::Locale::Base::::short_time_formatDateTime::Locale::Base::short_time_format
0000s0sDateTime::Locale::Base::::territory_idDateTime::Locale::Base::territory_id
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
3321µs219µs
# spent 16µs (14+3) within DateTime::Locale::Base::BEGIN@3 which was called # once (14µs+3µs) by DateTime::Locale::BEGIN@10 at line 3
use strict;
# spent 16µs making 1 call to DateTime::Locale::Base::BEGIN@3 # spent 3µs making 1 call to strict::import
4320µs225µs
# spent 16µs (8+8) within DateTime::Locale::Base::BEGIN@4 which was called # once (8µs+8µs) by DateTime::Locale::BEGIN@10 at line 4
use warnings;
# spent 16µs making 1 call to DateTime::Locale::Base::BEGIN@4 # spent 8µs making 1 call to warnings::import
5
63101µs1550µs
# spent 550µs (417+133) within DateTime::Locale::Base::BEGIN@6 which was called # once (417µs+133µs) by DateTime::Locale::BEGIN@10 at line 6
use Class::ISA;
# spent 550µs making 1 call to DateTime::Locale::Base::BEGIN@6
7323µs18µs
# spent 8µs within DateTime::Locale::Base::BEGIN@7 which was called # once (8µs+0s) by DateTime::Locale::BEGIN@10 at line 7
use DateTime::Locale;
# spent 8µs making 1 call to DateTime::Locale::Base::BEGIN@7
8321µs14µs
# spent 4µs within DateTime::Locale::Base::BEGIN@8 which was called # once (4µs+0s) by DateTime::Locale::BEGIN@10 at line 8
use List::MoreUtils ();
# spent 4µs making 1 call to DateTime::Locale::Base::BEGIN@8
9367µs266µs
# spent 37µs (7+30) within DateTime::Locale::Base::BEGIN@9 which was called # once (7µs+30µs) by DateTime::Locale::BEGIN@10 at line 9
use Params::Validate qw( validate_pos );
# spent 37µs making 1 call to DateTime::Locale::Base::BEGIN@9 # spent 30µs making 1 call to Exporter::import
10
11BEGIN
12
# spent 91µs (81+10) within DateTime::Locale::Base::BEGIN@12 which was called # once (81µs+10µs) by DateTime::Locale::BEGIN@10 at line 28
{
1314µs foreach my $field ( 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
201129µs116µs (my $meth_name = $field) =~ s/^en_//;
# spent 6µs making 11 calls to DateTime::Locale::Base::CORE:subst, avg 527ns/call
21
22 # also remove 'complete_'
231118µs114µs $meth_name =~ s/complete_//;
# spent 4µs making 11 calls to DateTime::Locale::Base::CORE:subst, avg 364ns/call
24
25353µs229µs
# spent 18µs (7+11) within DateTime::Locale::Base::BEGIN@25 which was called # once (7µs+11µs) by DateTime::Locale::BEGIN@10 at line 25
no strict 'refs';
# spent 18µs making 1 call to DateTime::Locale::Base::BEGIN@25 # spent 11µs making 1 call to strict::unimport
262490µs
# spent 46µs within DateTime::Locale::Base::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/DateTime/Locale/Base.pm:26] which was called 13 times, avg 4µs/call: # 13 times (46µs+0s) by DateTime::Locale::Base::STORABLE_freeze at line 350, avg 4µs/call
*{$meth_name} = sub { $_[0]->{$field} };
27 }
281524µs191µs}
# spent 91µs making 1 call to DateTime::Locale::Base::BEGIN@12
29
30sub new
31
# spent 66µs (59+7) within DateTime::Locale::Base::new which was called 2 times, avg 33µs/call: # 2 times (59µs+7µs) by DateTime::Locale::_load_class_from_id at line 305 of DateTime/Locale.pm, avg 33µs/call
{
3222µs my $class = shift;
33
34 # By making the default format lengths part of the object's hash
35 # key, it allows them to be settable.
36249µs47µs return bless { @_,
# spent 4µs making 2 calls to DateTime::Locale::root::_default_date_format_length, avg 2µs/call # spent 3µs making 2 calls to DateTime::Locale::root::_default_time_format_length, avg 1µs/call
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
# spent 75µs (55+21) within DateTime::Locale::Base::date_format_default which was called 5 times, avg 15µs/call: # 5 times (55µs+21µs) by DateTime::Locale::Base::default_date_format at line 243, avg 15µs/call
{
51519µs512µs my $meth = 'date_format_' . $_[0]->default_date_format_length();
# spent 12µs making 5 calls to DateTime::Locale::Base::default_date_format_length, avg 2µs/call
52526µs59µs $_[0]->$meth();
# spent 9µs making 5 calls to DateTime::Locale::en::date_format_medium, avg 2µs/call
53}
54
55sub date_formats
56{
57 return
58 { map { my $meth = 'date_format_' . $_;
59 $_ => $_[0]->$meth() } @FormatLengths }
60}
61
62sub time_format_default
63
# spent 74µs (54+21) within DateTime::Locale::Base::time_format_default which was called 5 times, avg 15µs/call: # 5 times (54µs+21µs) by DateTime::Locale::Base::default_time_format at line 249, avg 15µs/call
{
64519µs511µs my $meth = 'time_format_' . $_[0]->default_time_format_length();
# spent 11µs making 5 calls to DateTime::Locale::Base::default_time_format_length, avg 2µs/call
65525µs59µs $_[0]->$meth();
# spent 9µs making 5 calls to DateTime::Locale::en::time_format_medium, avg 2µs/call
66}
67
68sub time_formats
69{
70 return
71 { map { my $meth = 'time_format_' . $_;
72 $_ => $_[0]->$meth() } @FormatLengths }
73}
74
75sub format_for
76{
77 my $self = shift;
78 my $for = shift;
79
80 my $meth = '_format_for_' . $for;
81
82 return unless $self->can($meth);
83
84 return $self->$meth();
85}
86
87sub available_formats
88{
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 = List::MoreUtils::uniq( map { keys %{ $_->_available_formats() || {} } }
94 Class::ISA::self_and_super_path( ref $self ) );
95
96 # Doing the sort in the same expression doesn't work under 5.6.x.
97 return sort @uniq;
98}
99
100# Just needed for the above method.
101sub _available_formats { }
102
1031032µs
# spent 19µs within DateTime::Locale::Base::default_date_format_length which was called 10 times, avg 2µs/call: # 5 times (12µs+0s) by DateTime::Locale::Base::date_format_default at line 51, avg 2µs/call # 5 times (7µs+0s) by DateTime::Locale::Base::datetime_format_default at line 146, avg 1µs/call
sub default_date_format_length { $_[0]->{default_date_format_length} }
104
105sub set_default_date_format_length
106{
107 my $self = shift;
108 my ($l) = validate_pos( @_, { regex => qr/^(?:full|long|medium|short)$/i } );
109
110 $self->{default_date_format_length} = lc $l;
111}
112
1131030µs
# spent 18µs within DateTime::Locale::Base::default_time_format_length which was called 10 times, avg 2µs/call: # 5 times (11µs+0s) by DateTime::Locale::Base::time_format_default at line 64, avg 2µs/call # 5 times (6µs+0s) by DateTime::Locale::Base::datetime_format_default at line 147, avg 1µs/call
sub default_time_format_length { $_[0]->{default_time_format_length} }
114
115sub set_default_time_format_length
116{
117 my $self = shift;
118 my ($l) = validate_pos( @_, { regex => qr/^(?:full|long|medium|short)/i } );
119
120 $self->{default_time_format_length} = lc $l;
121}
122
1231900nsfor my $length ( qw( full long medium short ) )
124{
12542µs my $key = 'datetime_format_' . $length;
126
127 my $sub =
128 sub { my $self = shift;
129
130 return $self->{$key} if exists $self->{$key};
131
132 my $date_meth = 'date_format_' . $length;
133 my $time_meth = 'time_format_' . $length;
134
135 return $self->{$key} = $self->_make_datetime_format( $date_meth, $time_meth );
13647µs };
137
13831.45ms230µs
# spent 19µs (8+11) within DateTime::Locale::Base::BEGIN@138 which was called # once (8µs+11µs) by DateTime::Locale::BEGIN@10 at line 138
no strict 'refs';
# spent 19µs making 1 call to DateTime::Locale::Base::BEGIN@138 # spent 11µs making 1 call to strict::unimport
13947µs *{$key} = $sub;
140}
141
142sub datetime_format_default
143
# spent 228µs (71+157) within DateTime::Locale::Base::datetime_format_default which was called 5 times, avg 46µs/call: # 5 times (71µs+157µs) by DateTime::Locale::Base::default_datetime_format at line 255, avg 46µs/call
{
14453µs my $self = shift;
145
146512µs57µs my $date_meth = 'date_format_' . $self->default_date_format_length();
# spent 7µs making 5 calls to DateTime::Locale::Base::default_date_format_length, avg 1µs/call
147510µs56µs my $time_meth = 'time_format_' . $self->default_time_format_length();
# spent 6µs making 5 calls to DateTime::Locale::Base::default_time_format_length, avg 1µs/call
148
149526µs5144µs return $self->_make_datetime_format( $date_meth, $time_meth );
# spent 144µs making 5 calls to DateTime::Locale::Base::_make_datetime_format, avg 29µs/call
150}
151
152sub _make_datetime_format
153
# spent 144µs (96+48) within DateTime::Locale::Base::_make_datetime_format which was called 5 times, avg 29µs/call: # 5 times (96µs+48µs) by DateTime::Locale::Base::datetime_format_default at line 149, avg 29µs/call
{
15452µs my $self = shift;
15551µs my $date_meth = shift;
15652µs my $time_meth = shift;
157
158517µs512µs my $dt_format = $self->datetime_format();
# spent 12µs making 5 calls to DateTime::Locale::en::datetime_format, avg 2µs/call
159
16059µs55µs my $time = $self->$time_meth();
# spent 5µs making 5 calls to DateTime::Locale::en::time_format_medium, avg 940ns/call
16157µs55µs my $date = $self->$date_meth();
# spent 5µs making 5 calls to DateTime::Locale::en::date_format_medium, avg 920ns/call
162
163529µs515µs $dt_format =~ s/\{0\}/$time/g;
# spent 15µs making 5 calls to DateTime::Locale::Base::CORE:subst, avg 3µs/call
164521µs511µs $dt_format =~ s/\{1\}/$date/g;
# spent 11µs making 5 calls to DateTime::Locale::Base::CORE:subst, avg 2µs/call
165
166517µs return $dt_format;
167}
168
169sub prefers_24_hour_time
170{
171 my $self = shift;
172
173 return $self->{prefers_24_hour_time}
174 if exists $self->{prefers_24_hour_time};
175
176 $self->{prefers_24_hour_time} =
177 $self->time_format_short() =~ /h|K/ ? 0 : 1;
178}
179
180# Backwards compat for DateTime.pm version <= 0.42
181sub month_name { $_[0]->month_format_wide()-> [ $_[1]->month_0 ] }
182sub month_abbreviation { $_[0]->month_format_abbreviated()->[ $_[1]->month_0 ] }
183sub month_narrow { $_[0]->month_format_narrow()-> [ $_[1]->month_0 ] }
184
185520µs58µs
# spent 34µs (26+8) within DateTime::Locale::Base::month_names which was called 5 times, avg 7µs/call: # 5 times (26µs+8µs) by DateTime::Format::Strptime::_build_parser at line 682 of DateTime/Format/Strptime.pm, avg 7µs/call
sub month_names { $_[0]->month_format_wide() }
# spent 8µs making 5 calls to DateTime::Locale::en::month_format_wide, avg 2µs/call
186522µs59µs
# spent 33µs (24+9) within DateTime::Locale::Base::month_abbreviations which was called 5 times, avg 7µs/call: # 5 times (24µs+9µs) by DateTime::Format::Strptime::_build_parser at line 682 of DateTime/Format/Strptime.pm, avg 7µs/call
sub month_abbreviations { $_[0]->month_format_abbreviated() }
# spent 9µs making 5 calls to DateTime::Locale::en::month_format_abbreviated, avg 2µs/call
187sub month_narrows { $_[0]->month_format_narrow() }
188
189sub day_name { $_[0]->day_format_wide()-> [ $_[1]->day_of_week_0 ] }
190sub day_abbreviation { $_[0]->day_format_abbreviated()->[ $_[1]->day_of_week_0 ] }
191sub day_narrow { $_[0]->day_format_narrow()-> [ $_[1]->day_of_week_0 ] }
192
193521µs510µs
# spent 36µs (27+10) within DateTime::Locale::Base::day_names which was called 5 times, avg 7µs/call: # 5 times (27µs+10µs) by DateTime::Format::Strptime::_build_parser at line 671 of DateTime/Format/Strptime.pm, avg 7µs/call
sub day_names { $_[0]->day_format_wide() }
# spent 10µs making 5 calls to DateTime::Locale::en::day_format_wide, avg 2µs/call
194521µs58µs
# spent 32µs (24+8) within DateTime::Locale::Base::day_abbreviations which was called 5 times, avg 6µs/call: # 5 times (24µs+8µs) by DateTime::Format::Strptime::_build_parser at line 671 of DateTime/Format/Strptime.pm, avg 6µs/call
sub day_abbreviations { $_[0]->day_format_abbreviated() }
# spent 8µs making 5 calls to DateTime::Locale::en::day_format_abbreviated, avg 2µs/call
195sub day_narrows { $_[0]->day_format_narrow() }
196
197sub quarter_name { $_[0]->quarter_format_wide()-> [ $_[1]->quarter - 1 ] }
198sub quarter_abbreviation { $_[0]->quarter_format_abbreviated()->[ $_[1]->quarter - 1 ] }
199sub quarter_narrow { $_[0]->quarter_format_narrow()-> [ $_[1]->quarter - 1 ] }
200
201sub quarter_names { $_[0]->quarter_format_wide() }
202sub quarter_abbreviations { $_[0]->quarter_format_abbreviated() }
203
204sub am_pm { $_[0]->am_pm_abbreviated()->[ $_[1]->hour < 12 ? 0 : 1 ] }
2051044µs1018µs
# spent 70µs (52+18) within DateTime::Locale::Base::am_pms which was called 10 times, avg 7µs/call: # 5 times (31µs+11µs) by DateTime::Format::Strptime::_build_parser at line 610 of DateTime/Format/Strptime.pm, avg 8µs/call # 5 times (21µs+7µs) by DateTime::Format::Strptime::parse_datetime at line 469 of DateTime/Format/Strptime.pm, avg 6µs/call
sub am_pms { $_[0]->am_pm_abbreviated() }
# spent 18µs making 10 calls to DateTime::Locale::en::am_pm_abbreviated, avg 2µs/call
206
207sub era_name { $_[0]->era_wide()-> [ $_[1]->ce_year < 0 ? 0 : 1 ] }
208sub era_abbreviation { $_[0]->era_abbreviated()->[ $_[1]->ce_year < 0 ? 0 : 1 ] }
209sub era_narrow { $_[0]->era_narrow()-> [ $_[1]->ce_year < 0 ? 0 : 1 ] }
210
211sub era_names { $_[0]->era_wide() }
212sub era_abbreviations { $_[0]->era_abbreviated() }
213
214# ancient backwards compat
215sub era { $_[0]->era_abbreviation }
216sub eras { $_[0]->era_abbreviations }
217
218sub date_before_time
219{
220 my $self = shift;
221
222 my $dt_format = $self->datetime_format();
223
224 return $dt_format =~ /\{1\}.*\{0\}/ ? 1 : 0;
225}
226
227sub date_parts_order
228{
229 my $self = shift;
230
231 my $short = $self->date_format_short();
232
233 $short =~ tr{dmyDMY}{}cd;
234 $short =~ tr{dmyDMY}{dmydmy}s;
235
236 return $short;
237}
238
239sub full_date_format { $_[0]->_convert_to_strftime( $_[0]->date_format_full() ) }
240sub long_date_format { $_[0]->_convert_to_strftime( $_[0]->date_format_long() ) }
241sub medium_date_format { $_[0]->_convert_to_strftime( $_[0]->date_format_medium() ) }
242sub short_date_format { $_[0]->_convert_to_strftime( $_[0]->date_format_short() ) }
243541µs10296µs
# spent 344µs (48+296) within DateTime::Locale::Base::default_date_format which was called 5 times, avg 69µs/call: # 5 times (48µs+296µs) by DateTime::Format::Strptime::_build_parser at line 613 of DateTime/Format/Strptime.pm, avg 69µs/call
sub default_date_format { $_[0]->_convert_to_strftime( $_[0]->date_format_default() ) }
# spent 221µs making 5 calls to DateTime::Locale::Base::_convert_to_strftime, avg 44µs/call # spent 75µs making 5 calls to DateTime::Locale::Base::date_format_default, avg 15µs/call
244
245sub full_time_format { $_[0]->_convert_to_strftime( $_[0]->time_format_full() ) }
246sub long_time_format { $_[0]->_convert_to_strftime( $_[0]->time_format_long() ) }
247sub medium_time_format { $_[0]->_convert_to_strftime( $_[0]->time_format_medium() ) }
248sub short_time_format { $_[0]->_convert_to_strftime( $_[0]->time_format_short() ) }
249532µs10553µs
# spent 595µs (42+553) within DateTime::Locale::Base::default_time_format which was called 5 times, avg 119µs/call: # 5 times (42µs+553µs) by DateTime::Format::Strptime::_build_parser at line 617 of DateTime/Format/Strptime.pm, avg 119µs/call
sub default_time_format { $_[0]->_convert_to_strftime( $_[0]->time_format_default() ) }
# spent 479µs making 5 calls to DateTime::Locale::Base::_convert_to_strftime, avg 96µs/call # spent 74µs making 5 calls to DateTime::Locale::Base::time_format_default, avg 15µs/call
250
251sub full_datetime_format { $_[0]->_convert_to_strftime( $_[0]->datetime_format_full() ) }
252sub long_datetime_format { $_[0]->_convert_to_strftime( $_[0]->datetime_format_long() ) }
253sub medium_datetime_format { $_[0]->_convert_to_strftime( $_[0]->datetime_format_medium() ) }
254sub short_datetime_format { $_[0]->_convert_to_strftime( $_[0]->datetime_format_short() ) }
255533µs10774µs
# spent 814µs (40+774) within DateTime::Locale::Base::default_datetime_format which was called 5 times, avg 163µs/call: # 5 times (40µs+774µs) by DateTime::Format::Strptime::_build_parser at line 621 of DateTime/Format/Strptime.pm, avg 163µs/call
sub default_datetime_format { $_[0]->_convert_to_strftime( $_[0]->datetime_format_default() ) }
# spent 546µs making 5 calls to DateTime::Locale::Base::_convert_to_strftime, avg 109µs/call # spent 228µs making 5 calls to DateTime::Locale::Base::datetime_format_default, avg 46µs/call
256
257# Older versions of DateTime.pm will not pass in the $cldr_ok flag, so
258# we will give them the converted-to-strftime pattern (bugs and all).
259sub _convert_to_strftime
260
# spent 1.25ms (84µs+1.16) within DateTime::Locale::Base::_convert_to_strftime which was called 15 times, avg 83µs/call: # 5 times (19µs+526µs) by DateTime::Locale::Base::default_datetime_format at line 255, avg 109µs/call # 5 times (21µs+457µs) by DateTime::Locale::Base::default_time_format at line 249, avg 96µs/call # 5 times (43µs+178µs) by DateTime::Locale::Base::default_date_format at line 243, avg 44µs/call
{
261156µs my $self = shift;
262154µs my $pattern = shift;
263153µs my $cldr_ok = shift;
264
265152µs return $pattern if $cldr_ok;
266
2671550µs return $self->{_converted_patterns}{$pattern}
268 if exists $self->{_converted_patterns}{$pattern};
269
270325µs31.16ms return $self->{_converted_patterns}{$pattern} = $self->_cldr_to_strftime($pattern);
# spent 1.16ms making 3 calls to DateTime::Locale::Base::_cldr_to_strftime, avg 387µs/call
271}
272
273{
274269µs2924µs my @JavaPatterns =
# spent 24µs making 29 calls to DateTime::Locale::Base::CORE:qr, avg 817ns/call
275 ( qr/G/ => '{era}',
276 qr/yyyy/ => '{ce_year}',
277 qr/y/ => 'y',
278 qr/u/ => 'Y',
279 qr/MMMM/ => 'B',
280 qr/MMM/ => 'b',
281 qr/MM/ => 'm',
282 qr/M/ => '{month}',
283 qr/dd/ => 'd',
284 qr/d/ => '{day}',
285 qr/hh/ => 'l',
286 qr/h/ => '{hour_12}',
287 qr/HH/ => 'H',
288 qr/H/ => '{hour}',
289 qr/mm/ => 'M',
290 qr/m/ => '{minute}',
291 qr/ss/ => 'S',
292 qr/s/ => '{second}',
293 qr/S/ => 'N',
294 qr/EEEE/ => 'A',
295 qr/E/ => 'a',
296 qr/D/ => 'j',
297 qr/F/ => '{weekday_of_month}',
298 qr/w/ => 'V',
299 qr/W/ => '{week_month}',
300 qr/a/ => 'p',
301 qr/k/ => '{hour_1}',
302 qr/K/ => '{hour_12_0}',
303 qr/z/ => '{time_zone_long_name}',
304 );
305
306 sub _cldr_to_strftime
307
# spent 1.16ms (104µs+1.06) within DateTime::Locale::Base::_cldr_to_strftime which was called 3 times, avg 387µs/call: # 3 times (104µs+1.06ms) by DateTime::Locale::Base::_convert_to_strftime at line 270, avg 387µs/call
{
3083600ns shift;
30931µs my $simple = shift;
310
311 $simple =~
3123105µs2057µs s/(G+|y+|u+|M+|d+|h+|H+|m+|s+|S+|E+|D+|F+|w+|W+|a+|k+|K+|z+)|'((?:[^']|'')*)'/
# spent 47µs making 17 calls to DateTime::Locale::Base::CORE:substcont, avg 3µs/call # spent 10µs making 3 calls to DateTime::Locale::Base::CORE:subst, avg 3µs/call
3131431µs141.00ms $2 ? _stringify($2) : $1 ? _convert($1) : "'"/eg;
# spent 1.00ms making 14 calls to DateTime::Locale::Base::_convert, avg 71µs/call
314
315310µs return $simple;
316 }
317
318 sub _convert
319
# spent 1.00ms (779µs+221µs) within DateTime::Locale::Base::_convert which was called 14 times, avg 71µs/call: # 14 times (779µs+221µs) by DateTime::Locale::Base::_cldr_to_strftime at line 313, avg 71µs/call
{
320149µs my $simple = shift;
321
3221493µs for ( my $x = 0; $x < @JavaPatterns; $x += 2 )
323 {
324178866µs356221µs return '%' . $JavaPatterns[ $x + 1 ] if $simple =~ /$JavaPatterns[$x]/;
# spent 171µs making 178 calls to DateTime::Locale::Base::CORE:regcomp, avg 963ns/call # spent 50µs making 178 calls to DateTime::Locale::Base::CORE:match, avg 278ns/call
325142µs }
326
327 die "**Dont know $simple***";
328 }
329
330 sub _stringify
331 {
332 my $string = shift;
333
334 $string =~ s/%(?:[^%])/%%/g;
335 $string =~ s/\'\'/\'/g;
336
337 return $string;
338 }
339}
340
341# end backwards compat
342
343sub STORABLE_freeze
344
# spent 139µs (93+46) within DateTime::Locale::Base::STORABLE_freeze which was called 13 times, avg 11µs/call: # 13 times (93µs+46µs) by Storable::net_mstore at line 339 of Storable.pm, avg 11µs/call
{
345139µs my $self = shift;
346136µs my $cloning = shift;
347
348132µs return if $cloning;
349
3501364µs1346µs return $self->id();
# spent 46µs making 13 calls to DateTime::Locale::Base::__ANON__[DateTime/Locale/Base.pm:26], avg 4µs/call
351}
352
353sub STORABLE_thaw
354
# spent 1.30ms (454µs+849µs) within DateTime::Locale::Base::STORABLE_thaw which was called 17 times, avg 77µs/call: # 17 times (454µs+849µs) by Storable::mretrieve at line 415 of Storable.pm, avg 77µs/call
{
3551714µs my $self = shift;
356179µs my $cloning = shift;
357177µs my $serialized = shift;
358
3591760µs17849µs my $obj = DateTime::Locale->load( $serialized );
# spent 849µs making 17 calls to DateTime::Locale::load, avg 50µs/call
360
36117256µs %$self = %$obj;
362
3631766µs return $self;
364}
365
366
367119µs1;
368
369__END__
370
371=head1 NAME
372
373DateTime::Locale::Base - Base class for individual locale objects
374
375=head1 SYNOPSIS
376
377 use base 'DateTime::Locale::Base';
378
379=head1 DEFAULT FORMATS
380
381Each locale has a set of four default date and time formats. They are
382distinguished by length, and are called "full", "long", "medium", and
383"short". Each locale may have a different default length which it uses
384when its C<< $locale->date_format_default() >>, C<<
385$locale->time_format_default() >>, or C<<
386$locale->datetime_format_default() >> methods are called.
387
388This can be changed by calling the C<<
389$locale->set_default_date_format() >> or C<<
390$locale->set_default_time_format() >> methods. These methods accept a
391string which must be one of "full", "long", "medium", or "short".
392
393=head1 NAME FORMS
394
395Most names come in a number of variations. First, they may vary based
396on length, with wide, abbreviated, and narrow forms. The wide form is
397typically the full name, while the narrow form is often a single
398character. The narrow forms may not be unique. For example, "T" may be
399used for Tuesday and Thursday in the English narrow forms.
400
401Many names also distinguish between "format" and "stand-alone" forms
402of a pattern. The format pattern is used when the thing in question is
403being placed into a larger string. The stand-alone form is used when
404displaying that item by itself, for example in a calendar.
405
406=head1 METHODS
407
408All locales provide the following methods:
409
410=over 4
411
412=item * $locale->id()
413
414The locale's id.
415
416=item * $locale->language_id()
417
418The language portion of the id.
419
420=item * $locale->script_id()
421
422The script portion of the id, if any.
423
424=item * $locale->territory_id()
425
426The territory portion of the id, if any.
427
428=item * $locale->variant_id()
429
430The variant portion of the id, if any.
431
432=item * $locale->name()
433
434The full name for the locale in English.
435
436=item * $locale->language()
437
438The language name for the locale in English.
439
440=item * $locale->script()
441
442The script name for the locale in English, if any.
443
444=item * $locale->territory()
445
446The territory name for the locale in English, if any.
447
448=item * $locale->variant()
449
450The variant name for the locale in English, if any.
451
452=item * $locale->native_name()
453
454The full name for the locale in its native language, if any.
455
456=item * $locale->native_language()
457
458The language name for the locale in its native language, if any.
459
460=item * $locale->native_script()
461
462The script name for the locale in its native language, if any.
463
464=item * $locale->native_territory()
465
466The territory name for the locale in its native language, if any.
467
468=item * $locale->native_variant()
469
470The variant name for the locale in its native language, if any.
471
472=item * $locale->month_format_wide()
473
474Returns an array reference containing the wide format names of the
475months, with January as the first month.
476
477=item * $locale->month_format_abbreviated()
478
479Returns an array reference containing the abbreviated format names of
480the months, with January as the first month.
481
482=item * $locale->month_format_narrow()
483
484Returns an array reference containing the narrow format names of the
485months, with January as the first month.
486
487=item * $locale->month_stand_alone_wide()
488
489Returns an array reference containing the wide stand-alone names of
490the months, with January as the first month.
491
492=item * $locale->month_stand_alone_abbreviated()
493
494Returns an array reference containing the abbreviated stand-alone
495names of the months, with January as the first month.
496
497=item * $locale->month_stand_alone_narrow()
498
499Returns an array reference containing the narrow stand-alone names of the
500months, with January as the first month.
501
502=item * $locale->day_format_wide()
503
504Returns an array reference containing the wide format names of the
505days, with Monday as the first day.
506
507=item * $locale->day_format_abbreviated()
508
509Returns an array reference containing the abbreviated format names of
510the days, with Monday as the first day.
511
512=item * $locale->day_format_narrow()
513
514Returns an array reference containing the narrow format names of the
515days, with Monday as the first day.
516
517=item * $locale->day_stand_alone_wide()
518
519Returns an array reference containing the wide stand-alone names of
520the days, with Monday as the first day.
521
522=item * $locale->day_stand_alone_abbreviated()
523
524Returns an array reference containing the abbreviated stand-alone
525names of the days, with Monday as the first day.
526
527=item * $locale->day_stand_alone_narrow()
528
529Returns an array reference containing the narrow stand-alone names of
530the days, with Monday as the first day.
531
532=item * $locale->quarter_format_wide()
533
534Returns an array reference containing the wide format names of the
535quarters.
536
537=item * $locale->quarter_format_abbreviated()
538
539Returns an array reference containing the abbreviated format names of
540the quarters.
541
542=item * $locale->quarter_format_narrow()
543
544Returns an array reference containing the narrow format names of the
545quarters.
546
547=item * $locale->quarter_stand_alone_wide()
548
549Returns an array reference containing the wide stand-alone names of
550the quarters.
551
552=item * $locale->quarter_stand_alone_abbreviated()
553
554Returns an array reference containing the abbreviated stand-alone
555names of the quarters.
556
557=item * $locale->quarter_stand_alone_narrow()
558
559Returns an array reference containing the narrow stand-alone names of the
560quarters.
561
562=item * $locale->era_wide()
563
564Returns an array reference containing the wide names of the eras, with
565"BCE" first.
566
567=item * $locale->era_abbreviated()
568
569Returns an array reference containing the abbreviated names of the
570eras, with "BCE" first.
571
572=item * $locale->era_narrow()
573
574Returns an array reference containing the abbreviated names of the
575eras, with "BCE" first. However, most locales do not differ between
576the narrow and abbreviated length of the era.
577
578=item * $locale->am_pm_abbreviated()
579
580Returns an array reference containing the abbreviated names of "AM"
581and "PM".
582
583=item * $locale->date_format_long()
584
585=item * $locale->date_format_full()
586
587=item * $locale->date_format_medium()
588
589=item * $locale->date_format_short()
590
591Returns the CLDR date pattern of the appropriate length.
592
593=item * $locale->date_formats()
594
595Returns a hash reference of CLDR date patterns for the date formats,
596where the keys are "full", "long", "medium", and "short".
597
598=item * $locale->time_format_long()
599
600=item * $locale->time_format_full()
601
602=item * $locale->time_format_medium()
603
604=item * $locale->time_format_short()
605
606Returns the CLDR date pattern of the appropriate length.
607
608=item * $locale->time_formats()
609
610Returns a hash reference of CLDR date patterns for the time formats,
611where the keys are "full", "long", "medium", and "short".
612
613=item * $locale->datetime_format_long()
614
615=item * $locale->datetime_format_full()
616
617=item * $locale->datetime_format_medium()
618
619=item * $locale->datetime_format_short()
620
621Returns the CLDR date pattern of the appropriate length.
622
623=item * $locale->datetime_formats()
624
625Returns a hash reference of CLDR date patterns for the datetime
626formats, where the keys are "full", "long", "medium", and "short".
627
628=item * $locale->date_format_default()
629
630=item * $locale->time_format_default()
631
632=item * $locale->datetime_format_default()
633
634Returns the default CLDR date pattern. The length of this format is
635based on the value of C<< $locale->default_date_format_length() >>
636and/or C<< $locale->default_time_format_length() >>.
637
638=item * $locale->default_date_format_length()
639
640=item * $locale->default_time_format_length()
641
642Returns the default length for the format, one of "full", "long",
643"medium", or "short".
644
645=item * $locale->set_default_date_format_length()
646
647=item * $locale->set_default_time_format_length()
648
649Sets the default length for the format. This must be one of "full",
650"long", "medium", or "short".
651
652=item * $locale->prefers_24_hour_time()
653
654Returns a boolean indicating the preferred hour format for this
655locale.
656
657=item * $locale->first_day_of_week()
658
659Returns a number from 1 to 7 indicating the I<local> first day of the
660week. For example, for a US locale this returns 7.
661
662=item * $locale->available_formats()
663
664A list of format names, like "MMdd" or "yyyyMM". This should be the
665list directly supported by the subclass, not its parents.
666
667=item * $locale->format_for($key)
668
669Given a valid name, returns the CLDR date pattern for that thing, if
670one exists.
671
672=back
673
674=head1 SUPPORT
675
676See L<DateTime::Locale>.
677
678=head1 AUTHORS
679
680Richard Evans <rich@ridas.com>
681
682Dave Rolsky <autarch@urth.org>
683
684=head1 COPYRIGHT
685
686Copyright (c) 2003 Richard Evans. Copyright (c) 2004-2005 David
687Rolsky. All rights reserved. This program is free software; you can
688redistribute it and/or modify it under the same terms as Perl itself.
689
690This program is free software; you can redistribute it and/or modify
691it under the same terms as Perl itself.
692
693The full text of the license can be found in the LICENSE file included
694with this module.
695
696=cut
# spent 50µs within DateTime::Locale::Base::CORE:match which was called 178 times, avg 278ns/call: # 178 times (50µs+0s) by DateTime::Locale::Base::_convert at line 324 of DateTime/Locale/Base.pm, avg 278ns/call
sub DateTime::Locale::Base::CORE:match; # xsub
# spent 24µs within DateTime::Locale::Base::CORE:qr which was called 29 times, avg 817ns/call: # 29 times (24µs+0s) by DateTime::Locale::BEGIN@10 at line 274 of DateTime/Locale/Base.pm, avg 817ns/call
sub DateTime::Locale::Base::CORE:qr; # xsub
# spent 171µs within DateTime::Locale::Base::CORE:regcomp which was called 178 times, avg 963ns/call: # 178 times (171µs+0s) by DateTime::Locale::Base::_convert at line 324 of DateTime/Locale/Base.pm, avg 963ns/call
sub DateTime::Locale::Base::CORE:regcomp; # xsub
# spent 47µs within DateTime::Locale::Base::CORE:subst which was called 35 times, avg 1µs/call: # 11 times (6µs+0s) by DateTime::Locale::Base::BEGIN@12 at line 20 of DateTime/Locale/Base.pm, avg 527ns/call # 11 times (4µs+0s) by DateTime::Locale::Base::BEGIN@12 at line 23 of DateTime/Locale/Base.pm, avg 364ns/call # 5 times (15µs+0s) by DateTime::Locale::Base::_make_datetime_format at line 163 of DateTime/Locale/Base.pm, avg 3µs/call # 5 times (11µs+0s) by DateTime::Locale::Base::_make_datetime_format at line 164 of DateTime/Locale/Base.pm, avg 2µs/call # 3 times (10µs+0s) by DateTime::Locale::Base::_cldr_to_strftime at line 312 of DateTime/Locale/Base.pm, avg 3µs/call
sub DateTime::Locale::Base::CORE:subst; # xsub
# spent 47µs within DateTime::Locale::Base::CORE:substcont which was called 17 times, avg 3µs/call: # 17 times (47µs+0s) by DateTime::Locale::Base::_cldr_to_strftime at line 312 of DateTime/Locale/Base.pm, avg 3µs/call
sub DateTime::Locale::Base::CORE:substcont; # xsub