Filename | /home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/DateTime/Locale/FromData.pm |
Statements | Executed 138 statements in 2.00ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 706µs | 830µs | BEGIN@6 | DateTime::Locale::FromData::
1 | 1 | 1 | 152µs | 152µs | BEGIN@13 | DateTime::Locale::FromData::
1 | 1 | 1 | 34µs | 34µs | new | DateTime::Locale::FromData::
1 | 1 | 1 | 32µs | 37µs | BEGIN@3 | DateTime::Locale::FromData::
1 | 1 | 1 | 14µs | 39µs | BEGIN@7 | DateTime::Locale::FromData::
1 | 1 | 1 | 12µs | 24µs | BEGIN@4 | DateTime::Locale::FromData::
1 | 1 | 1 | 9µs | 26µs | BEGIN@70 | DateTime::Locale::FromData::
1 | 1 | 1 | 8µs | 20µs | BEGIN@89 | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | STORABLE_freeze | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | STORABLE_thaw | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | __ANON__[:68] | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | __ANON__[:86] | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | _available_formats | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | _make_datetime_format | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | available_formats | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | date_format_default | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | date_formats | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | datetime_format | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | datetime_format_default | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | format_for | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | id | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | language_code | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | language_id | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | prefers_24_hour_time | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | script_code | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | script_id | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | set_default_date_format_length | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | set_default_time_format_length | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | territory_code | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | territory_id | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | time_format_default | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | time_formats | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | variant_code | DateTime::Locale::FromData::
0 | 0 | 0 | 0s | 0s | variant_id | DateTime::Locale::FromData::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package DateTime::Locale::FromData; | ||||
2 | |||||
3 | 2 | 41µs | 2 | 43µs | # spent 37µs (32+6) within DateTime::Locale::FromData::BEGIN@3 which was called:
# once (32µs+6µs) by DateTime::Locale::BEGIN@11 at line 3 # spent 37µs making 1 call to DateTime::Locale::FromData::BEGIN@3
# spent 6µs making 1 call to strict::import |
4 | 2 | 38µs | 2 | 35µs | # spent 24µs (12+11) within DateTime::Locale::FromData::BEGIN@4 which was called:
# once (12µs+11µs) by DateTime::Locale::BEGIN@11 at line 4 # spent 24µs making 1 call to DateTime::Locale::FromData::BEGIN@4
# spent 11µs making 1 call to warnings::import |
5 | |||||
6 | 2 | 396µs | 2 | 886µs | # spent 830µs (706+125) within DateTime::Locale::FromData::BEGIN@6 which was called:
# once (706µs+125µs) by DateTime::Locale::BEGIN@11 at line 6 # spent 830µs making 1 call to DateTime::Locale::FromData::BEGIN@6
# spent 56µs making 1 call to Exporter::import |
7 | 2 | 145µs | 2 | 65µs | # spent 39µs (14+26) within DateTime::Locale::FromData::BEGIN@7 which was called:
# once (14µs+26µs) by DateTime::Locale::BEGIN@11 at line 7 # spent 39µs making 1 call to DateTime::Locale::FromData::BEGIN@7
# spent 26µs making 1 call to Exporter::import |
8 | |||||
9 | 1 | 600ns | our $VERSION = '1.03'; | ||
10 | |||||
11 | 1 | 200ns | my @FormatLengths; | ||
12 | |||||
13 | # spent 152µs within DateTime::Locale::FromData::BEGIN@13 which was called:
# once (152µs+0s) by DateTime::Locale::BEGIN@11 at line 92 | ||||
14 | 1 | 6µs | my @methods = qw( | ||
15 | code | ||||
16 | name | ||||
17 | language | ||||
18 | script | ||||
19 | territory | ||||
20 | variant | ||||
21 | native_name | ||||
22 | native_language | ||||
23 | native_script | ||||
24 | native_territory | ||||
25 | native_variant | ||||
26 | am_pm_abbreviated | ||||
27 | date_format_full | ||||
28 | date_format_long | ||||
29 | date_format_medium | ||||
30 | date_format_short | ||||
31 | time_format_full | ||||
32 | time_format_long | ||||
33 | time_format_medium | ||||
34 | time_format_short | ||||
35 | day_format_abbreviated | ||||
36 | day_format_narrow | ||||
37 | day_format_wide | ||||
38 | day_stand_alone_abbreviated | ||||
39 | day_stand_alone_narrow | ||||
40 | day_stand_alone_wide | ||||
41 | month_format_abbreviated | ||||
42 | month_format_narrow | ||||
43 | month_format_wide | ||||
44 | month_stand_alone_abbreviated | ||||
45 | month_stand_alone_narrow | ||||
46 | month_stand_alone_wide | ||||
47 | quarter_format_abbreviated | ||||
48 | quarter_format_narrow | ||||
49 | quarter_format_wide | ||||
50 | quarter_stand_alone_abbreviated | ||||
51 | quarter_stand_alone_narrow | ||||
52 | quarter_stand_alone_wide | ||||
53 | era_abbreviated | ||||
54 | era_narrow | ||||
55 | era_wide | ||||
56 | default_date_format_length | ||||
57 | default_time_format_length | ||||
58 | first_day_of_week | ||||
59 | version | ||||
60 | glibc_datetime_format | ||||
61 | glibc_date_format | ||||
62 | glibc_date_1_format | ||||
63 | glibc_time_format | ||||
64 | glibc_time_12_format | ||||
65 | ); | ||||
66 | |||||
67 | 1 | 600ns | for my $meth (@methods) { | ||
68 | 50 | 46µs | my $sub = sub { $_[0]->{$meth} }; | ||
69 | ## no critic (TestingAndDebugging::ProhibitNoStrict) | ||||
70 | 2 | 122µs | 2 | 42µs | # spent 26µs (9+16) within DateTime::Locale::FromData::BEGIN@70 which was called:
# once (9µs+16µs) by DateTime::Locale::BEGIN@11 at line 70 # spent 26µs making 1 call to DateTime::Locale::FromData::BEGIN@70
# spent 16µs making 1 call to strict::unimport |
71 | 50 | 78µs | *{$meth} = $sub; | ||
72 | } | ||||
73 | |||||
74 | 1 | 1µs | @FormatLengths = qw( short medium long full ); | ||
75 | |||||
76 | 1 | 6µs | for my $length (@FormatLengths) { | ||
77 | 4 | 2µs | my $meth = 'datetime_format_' . $length; | ||
78 | 4 | 2µs | my $key = 'computed_' . $meth; | ||
79 | |||||
80 | my $sub = sub { | ||||
81 | my $self = shift; | ||||
82 | |||||
83 | return $self->{$key} if exists $self->{$key}; | ||||
84 | |||||
85 | return $self->{$key} = $self->_make_datetime_format($length); | ||||
86 | 4 | 4µs | }; | ||
87 | |||||
88 | ## no critic (TestingAndDebugging::ProhibitNoStrict) | ||||
89 | 2 | 43µs | 2 | 32µs | # spent 20µs (8+12) within DateTime::Locale::FromData::BEGIN@89 which was called:
# once (8µs+12µs) by DateTime::Locale::BEGIN@11 at line 89 # spent 20µs making 1 call to DateTime::Locale::FromData::BEGIN@89
# spent 12µs making 1 call to strict::unimport |
90 | 4 | 7µs | *{$meth} = $sub; | ||
91 | } | ||||
92 | 1 | 1.02ms | 1 | 152µs | } # spent 152µs making 1 call to DateTime::Locale::FromData::BEGIN@13 |
93 | |||||
94 | # spent 34µs within DateTime::Locale::FromData::new which was called:
# once (34µs+0s) by DateTime::Locale::_locale_object_for at line 282 of DateTime/Locale.pm | ||||
95 | 1 | 700ns | my $class = shift; | ||
96 | 1 | 400ns | my $data = shift; | ||
97 | |||||
98 | return bless { | ||||
99 | 1 | 36µs | %{$data}, | ||
100 | default_date_format_length => 'medium', | ||||
101 | default_time_format_length => 'medium', | ||||
102 | }, $class; | ||||
103 | } | ||||
104 | |||||
105 | sub date_format_default { | ||||
106 | return $_[0]->date_format_medium; | ||||
107 | } | ||||
108 | |||||
109 | sub time_format_default { | ||||
110 | return $_[0]->time_format_medium; | ||||
111 | } | ||||
112 | |||||
113 | sub datetime_format { | ||||
114 | return $_[0]->{datetime_format_medium}; | ||||
115 | } | ||||
116 | |||||
117 | sub datetime_format_default { | ||||
118 | return $_[0]->datetime_format_medium; | ||||
119 | } | ||||
120 | |||||
121 | sub _make_datetime_format { | ||||
122 | my $self = shift; | ||||
123 | my $length = shift; | ||||
124 | |||||
125 | my $dt_key = 'datetime_format_' . $length; | ||||
126 | my $date_meth = 'date_format_' . $length; | ||||
127 | my $time_meth = 'time_format_' . $length; | ||||
128 | |||||
129 | my $dt_format = $self->{$dt_key}; | ||||
130 | $dt_format =~ s/\{0\}/$self->$time_meth/eg; | ||||
131 | $dt_format =~ s/\{1\}/$self->$date_meth/eg; | ||||
132 | |||||
133 | return $dt_format; | ||||
134 | } | ||||
135 | |||||
136 | sub set_default_date_format_length { | ||||
137 | my $self = shift; | ||||
138 | my ($l) | ||||
139 | = validate_pos( @_, { regex => qr/^(?:full|long|medium|short)$/i } ); | ||||
140 | |||||
141 | $self->{default_date_format_length} = lc $l; | ||||
142 | } | ||||
143 | |||||
144 | sub set_default_time_format_length { | ||||
145 | my $self = shift; | ||||
146 | my ($l) | ||||
147 | = validate_pos( @_, { regex => qr/^(?:full|long|medium|short)/i } ); | ||||
148 | |||||
149 | $self->{default_time_format_length} = lc $l; | ||||
150 | } | ||||
151 | |||||
152 | sub date_formats { | ||||
153 | my %formats; | ||||
154 | for my $length (@FormatLengths) { | ||||
155 | my $meth = 'date_format_' . $length; | ||||
156 | $formats{$length} = $_[0]->$meth; | ||||
157 | } | ||||
158 | return \%formats; | ||||
159 | } | ||||
160 | |||||
161 | sub time_formats { | ||||
162 | my %formats; | ||||
163 | for my $length (@FormatLengths) { | ||||
164 | my $meth = 'time_format_' . $length; | ||||
165 | $formats{$length} = $_[0]->$meth; | ||||
166 | } | ||||
167 | return \%formats; | ||||
168 | } | ||||
169 | |||||
170 | sub available_formats { | ||||
171 | my $self = shift; | ||||
172 | |||||
173 | $self->{computed_available_formats} | ||||
174 | ||= [ sort keys %{ $self->_available_formats } ]; | ||||
175 | |||||
176 | return @{ $self->{computed_available_formats} }; | ||||
177 | } | ||||
178 | |||||
179 | sub format_for { | ||||
180 | my $self = shift; | ||||
181 | my $for = shift; | ||||
182 | |||||
183 | return $self->_available_formats->{$for}; | ||||
184 | } | ||||
185 | |||||
186 | sub _available_formats { $_[0]->{available_formats} } | ||||
187 | |||||
188 | sub prefers_24_hour_time { | ||||
189 | my $self = shift; | ||||
190 | |||||
191 | return $self->{prefers_24_hour_time} | ||||
192 | if exists $self->{prefers_24_hour_time}; | ||||
193 | |||||
194 | $self->{prefers_24_hour_time} = $self->time_format_short =~ /h|K/ ? 0 : 1; | ||||
195 | } | ||||
196 | |||||
197 | sub language_code { | ||||
198 | my $self = shift; | ||||
199 | return ( $self->{parsed_code} ||= { parse_locale_code( $self->code ) } ) | ||||
200 | ->{language}; | ||||
201 | } | ||||
202 | |||||
203 | sub script_code { | ||||
204 | my $self = shift; | ||||
205 | return ( $self->{parsed_code} ||= { parse_locale_code( $self->code ) } ) | ||||
206 | ->{script}; | ||||
207 | } | ||||
208 | |||||
209 | sub territory_code { | ||||
210 | my $self = shift; | ||||
211 | return ( $self->{parsed_code} ||= { parse_locale_code( $self->code ) } ) | ||||
212 | ->{territory}; | ||||
213 | } | ||||
214 | |||||
215 | sub variant_code { | ||||
216 | my $self = shift; | ||||
217 | return ( $self->{parsed_code} ||= { parse_locale_code( $self->code ) } ) | ||||
218 | ->{variant}; | ||||
219 | } | ||||
220 | |||||
221 | sub id { | ||||
222 | $_[0]->code; | ||||
223 | } | ||||
224 | |||||
225 | sub language_id { | ||||
226 | $_[0]->language_code; | ||||
227 | } | ||||
228 | |||||
229 | sub script_id { | ||||
230 | $_[0]->script_code; | ||||
231 | } | ||||
232 | |||||
233 | sub territory_id { | ||||
234 | $_[0]->territory_code; | ||||
235 | } | ||||
236 | |||||
237 | sub variant_id { | ||||
238 | $_[0]->variant_code; | ||||
239 | } | ||||
240 | |||||
241 | sub STORABLE_freeze { | ||||
242 | my $self = shift; | ||||
243 | my $cloning = shift; | ||||
244 | |||||
245 | return if $cloning; | ||||
246 | |||||
247 | return $self->code; | ||||
248 | } | ||||
249 | |||||
250 | sub STORABLE_thaw { | ||||
251 | my $self = shift; | ||||
252 | shift; | ||||
253 | my $serialized = shift; | ||||
254 | |||||
255 | my $obj = DateTime::Locale->load($serialized); | ||||
256 | |||||
257 | %{$self} = %{$obj}; | ||||
258 | |||||
259 | return $self; | ||||
260 | } | ||||
261 | |||||
262 | 1 | 4µs | 1; | ||
263 | |||||
264 | # ABSTRACT: Class for locale objects instantiated from pre-defined data | ||||
265 | |||||
266 | __END__ |