blib/lib/DateTime/Locale/Base.pm

filter: Statementstmt 30.0% 63 / 210 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 17.6% 15 / 85 Podpod 84.2% 16 / 19 totaltotal 25.8% 94 / 364 CC 25 SCAR 18.3
CC
25
Cov
25%
_self_and_super_path
42.7
prefers_24_hour_time
12.0
_convert_to_strftime
12.0
CRAP 6.2
« blib/lib/DateTime/Locale.pm ↑ Summary blib/lib/DateTime/Locale/Data.pm »
1 package DateTime::Locale::Base;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '1.47';
8  
9 2 ▶use Carp qw( carp );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use DateTime::Locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use List::Util 1.45 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Params::ValidationCompiler 0.13 qw( validation_for );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Specio::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
16 2 foreach my $field (
17 qw( id en_complete_name native_complete_name
18 en_language en_script en_territory en_variant
19 native_language native_script native_territory native_variant
20 )
21 ) {
22  
23 # remove leading 'en_' for method name
24 22 ( my $meth_name = $field ) =~ s/^en_//;
25  
26 # also remove 'complete_'
27 22 $meth_name =~ s/complete_//;
28  
29 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 22 ▶ *{$meth_name} = sub { $_[0]->{$field} };
Subroutine __ANON__: called CC=1 SCAR=0.0
31 }
32 }
33  
34 7 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
35 7 my $class = shift;
36  
37 # By making the default format lengths part of the object's hash
38 # key, it allows them to be settable.
39 7 return bless {
40 @_,
41 default_date_format_length => 'long',
42 default_time_format_length => 'long',
43 }, $class;
44 }
45  
46 0 ▶sub language_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[0] }
Subroutine language_id: not called CC=1 SCAR=6.9
Pod documented
47 0 ▶sub script_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[1] }
Subroutine script_id: not called CC=1 SCAR=6.9
Pod documented
48 0 ▶sub territory_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[2] }
Subroutine territory_id: not called CC=1 SCAR=6.9
Pod documented
49 0 ▶sub variant_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[3] }
Subroutine variant_id: not called CC=1 SCAR=6.9
Pod documented
50  
51 2 my @FormatLengths = qw( short medium long full );
52  
53 0 ▶sub date_format_default {
Subroutine date_format_default: not called CC=1 SCAR=6.9
Pod documented
54 0 my $meth = 'date_format_' . $_[0]->default_date_format_length();
55 0 $_[0]->$meth();
56 }
57  
58 0 ▶sub date_formats {
Subroutine date_formats: not called CC=1 SCAR=6.9
Pod documented
59 return {
60 map {
61 0 my $meth = 'date_format_' . $_;
62 0 $_ => $_[0]->$meth()
63 } @FormatLengths
64 };
65 }
66  
67 0 ▶sub time_format_default {
Subroutine time_format_default: not called CC=1 SCAR=6.9
Pod documented
68 0 my $meth = 'time_format_' . $_[0]->default_time_format_length();
69 0 $_[0]->$meth();
70 }
71  
72 0 ▶sub time_formats {
Subroutine time_formats: not called CC=1 SCAR=6.9
Pod documented
73 return {
74 map {
75 0 my $meth = 'time_format_' . $_;
76 0 $_ => $_[0]->$meth()
77 } @FormatLengths
78 };
79 }
80  
81 0 ▶sub format_for {
Subroutine format_for: not called CC=2 SCAR=17.9
Pod documented
82 0 my $self = shift;
83 0 my $for = shift;
84  
85 0 my $meth = '_format_for_' . $for;
86  
87 0 ▶ return unless $self->can($meth);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can($meth) 0 0 0
88  
89 0 return $self->$meth();
90 }
91  
92 0 ▶sub available_formats {
Subroutine available_formats: not called CC=2 SCAR=17.9
Pod documented
93 0 my $self = shift;
94  
95 # The various parens seem to be necessary to force uniq() to see
96 # the caller's list context. Go figure.
97 my @uniq
98 0 ▶ = List::Util::uniq( map { keys %{ $_->_available_formats() || {} } }
Condition0%0/2
$_->_available_formats || {}
l!l
00
MC/DC0%0/1
$_->_available_formats || {}
$_->_available_formats
Truth table0%0/2
A
A= $_->_available_formats
Aresult
11
00
99 _self_and_super_path( ref $self ) );
100  
101 # Doing the sort in the same expression doesn't work under 5.6.x.
102 0 return sort @uniq;
103 }
104  
105 # Copied wholesale from Class::ISA, because said module warns as deprecated
106 # with perl 5.11.0+, which is kind of annoying.
107 0 ▶sub _self_and_super_path {
Subroutine _self_and_super_path: not called CC=7 SCAR=37.5
108  
109 # Assumption: searching is depth-first.
110 # Assumption: '' (empty string) can't be a class package name.
111 # Note: 'UNIVERSAL' is not given any special treatment.
112 0 ▶ return () unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
113  
114 0 my @out = ();
115  
116 0 my @in_stack = ( $_[0] );
117 0 my %seen = ( $_[0] => 1 );
118  
119 0 my $current;
120 0 ▶ while (@in_stack) {
Branch: 1 branch
BranchTrueFalseTotal
if (@in_stack) 0 0 0
121 0 ▶ next unless defined( $current = shift @in_stack ) && length($current);
Branch: 1 branch
BranchTrueFalseTotal
unless defined($current = shift @in_stack) and length $current 0 0 0
Condition0%0/3
defined($current = shift @in_stack) and length $current
!ll&&!rl&&r
000
MC/DC0%0/2
defined($current = shift @in_stack) and length $current
defined($current = shift @in_stack) length $current
Truth table0%0/3
A and B
A= defined($current = shift @in_stack)B= length $current
ABresult
0X0
100
111
122 0 push @out, $current;
123 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
124 unshift @in_stack, map {
125 0 my $c = $_; # copy, to avoid being destructive
126 0 ▶ substr( $c, 0, 2 ) = "main::" if substr( $c, 0, 2 ) eq '::';
Branch: 1 branch
BranchTrueFalseTotal
if substr($c, 0, 2) eq "::" 0 0 0
127  
128 # Canonize the :: -> main::, ::foo -> main::foo thing.
129 # Should I ever canonize the Foo'Bar = Foo::Bar thing?
130 0 ▶ $seen{$c}++ ? () : $c;
Branch: 1 branch
BranchTrueFalseTotal
$seen{$c}++ ? : 0 0 0
131 0 } @{"$current\::ISA"};
132  
133 # I.e., if this class has any parents (at least, ones I've never seen
134 # before), push them, in order, onto the stack of classes I need to
135 # explore.
136 }
137  
138 0 return @out;
139 }
140  
141 # Just needed for the above method.
142 0 ▶sub _available_formats { }
Subroutine _available_formats: not called CC=1 SCAR=0.0
143  
144 0 ▶sub default_date_format_length { $_[0]->{default_date_format_length} }
Subroutine default_date_format_length: not called CC=1 SCAR=6.9
Pod documented
145  
146 2 my $length = enum( values => [qw( full long medium short )] );
147 2 my $validator = validation_for(
148 name => '_check_length_parameter',
149 name_is_optional => 1,
150 params => [ { type => $length } ],
151 );
152  
153 0 ▶sub set_default_date_format_length {
Subroutine set_default_date_format_length: not called CC=1 SCAR=6.9
Pod documented
154 0 my $self = shift;
155 0 my ($l) = $validator->(@_);
156  
157 0 $self->{default_date_format_length} = lc $l;
158 }
159  
160 0 ▶sub default_time_format_length { $_[0]->{default_time_format_length} }
Subroutine default_time_format_length: not called CC=1 SCAR=6.9
Pod documented
161  
162 0 ▶sub set_default_time_format_length {
Subroutine set_default_time_format_length: not called CC=1 SCAR=6.9
Pod documented
163 0 my $self = shift;
164 0 my ($l) = $validator->(@_);
165  
166 0 $self->{default_time_format_length} = lc $l;
167 }
168  
169 2 for my $length (qw( full long medium short )) {
170 8 my $key = 'datetime_format_' . $length;
171  
172 0 ▶ my $sub = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
173 0 my $self = shift;
174  
175 0 ▶ return $self->{$key} if exists $self->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{$key} 0 0 0
176  
177 0 my $date_meth = 'date_format_' . $length;
178 0 my $time_meth = 'time_format_' . $length;
179  
180 0 return $self->{$key}
181 = $self->_make_datetime_format( $date_meth, $time_meth );
182 8 };
183  
184 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
185 8 *{$key} = $sub;
186 }
187  
188 0 ▶sub datetime_format_default {
Subroutine datetime_format_default: not called CC=1 SCAR=6.9
Pod documented
189 0 my $self = shift;
190  
191 0 my $date_meth = 'date_format_' . $self->default_date_format_length();
192 0 my $time_meth = 'time_format_' . $self->default_time_format_length();
193  
194 0 return $self->_make_datetime_format( $date_meth, $time_meth );
195 }
196  
197 0 ▶sub _make_datetime_format {
Subroutine _make_datetime_format: not called CC=1 SCAR=6.9
198 0 my $self = shift;
199 0 my $date_meth = shift;
200 0 my $time_meth = shift;
201  
202 0 my $dt_format = $self->datetime_format();
203  
204 0 my $time = $self->$time_meth();
205 0 my $date = $self->$date_meth();
206  
207 0 $dt_format =~ s/\{0\}/$time/g;
208 0 $dt_format =~ s/\{1\}/$date/g;
209  
210 0 return $dt_format;
211 }
212  
213 0 ▶sub prefers_24_hour_time {
Subroutine prefers_24_hour_time: not called CC=3 SCAR=24.8
Pod documented
214 0 my $self = shift;
215  
216 return $self->{prefers_24_hour_time}
217 0 ▶ if exists $self->{prefers_24_hour_time};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"prefers_24_hour_time"} 0 0 0
218  
219 $self->{prefers_24_hour_time}
220 0 ▶ = $self->time_format_short() =~ /h|K/ ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->time_format_short =~ /h|K/ ? : 0 0 0
221 }
222  
223 # Backwards compat for DateTime.pm version <= 0.42
224 {
225 2 my %subs = (
226 0 ▶ month_name => sub { $_[0]->month_format_wide()->[ $_[1]->month_0 ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
227  
228 0 ▶ month_abbreviation => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
229 0 $_[0]->month_format_abbreviated()->[ $_[1]->month_0 ];
230 },
231 month_narrow =>
232 0 ▶ sub { $_[0]->month_format_narrow()->[ $_[1]->month_0 ]; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
233  
234 0 ▶ month_names => sub { $_[0]->month_format_wide() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
235 0 ▶ month_abbreviations => sub { $_[0]->month_format_abbreviated() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
236 0 ▶ month_narrows => sub { $_[0]->month_format_narrow() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
237  
238 day_name =>
239 0 ▶ sub { $_[0]->day_format_wide()->[ $_[1]->day_of_week_0 ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
240  
241 0 ▶ day_abbreviation => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
242 0 $_[0]->day_format_abbreviated()->[ $_[1]->day_of_week_0 ];
243 },
244 day_narrow =>
245 0 ▶ sub { $_[0]->day_format_narrow()->[ $_[1]->day_of_week_0 ]; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
246  
247 0 ▶ day_names => sub { $_[0]->day_format_wide() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
248 0 ▶ day_abbreviations => sub { $_[0]->day_format_abbreviated() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
249 0 ▶ day_narrows => sub { $_[0]->day_format_narrow() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
250  
251 quarter_name =>
252 0 ▶ sub { $_[0]->quarter_format_wide()->[ $_[1]->quarter - 1 ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
253  
254 0 ▶ quarter_abbreviation => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
255 0 $_[0]->quarter_format_abbreviated()->[ $_[1]->quarter - 1 ];
256 },
257 quarter_narrow =>
258 0 ▶ sub { $_[0]->quarter_format_narrow()->[ $_[1]->quarter - 1 ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
259  
260 0 ▶ quarter_names => sub { $_[0]->quarter_format_wide() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
261 0 ▶ quarter_abbreviations => sub { $_[0]->quarter_format_abbreviated() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
262  
263 am_pm =>
264 0 ▶ sub { $_[0]->am_pm_abbreviated()->[ $_[1]->hour < 12 ? 0 : 1 ] },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->hour < 12 ? : 0 0 0
265 0 ▶ am_pms => sub { $_[0]->am_pm_abbreviated() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
266  
267 0 ▶ era_name => sub { $_[0]->era_wide()->[ $_[1]->ce_year < 0 ? 0 : 1 ] },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->ce_year < 0 ? : 0 0 0
268  
269 0 ▶ era_abbreviation => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
270 0 ▶ $_[0]->era_abbreviated()->[ $_[1]->ce_year < 0 ? 0 : 1 ];
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->ce_year < 0 ? : 0 0 0
271 },
272 era_narrow =>
273 0 ▶ sub { $_[0]->era_narrow()->[ $_[1]->ce_year < 0 ? 0 : 1 ] },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->ce_year < 0 ? : 0 0 0
274  
275 0 ▶ era_names => sub { $_[0]->era_wide() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
276 0 ▶ era_abbreviations => sub { $_[0]->era_abbreviated() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
277  
278 # ancient backwards compat
279 0 ▶ era => sub { $_[0]->era_abbreviation },
Subroutine __ANON__: not called CC=1 SCAR=6.9
280 0 ▶ eras => sub { $_[0]->era_abbreviations },
Subroutine __ANON__: not called CC=1 SCAR=6.9
281  
282 0 ▶ date_before_time => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
283 0 my $self = shift;
284  
285 0 my $dt_format = $self->datetime_format();
286  
287 0 ▶ return $dt_format =~ /\{1\}.*\{0\}/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$dt_format =~ /\{1\}.*\{0\}/ ? : 0 0 0
288 },
289  
290 0 ▶ date_parts_order => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
291 0 my $self = shift;
292  
293 0 my $short = $self->date_format_short();
294  
295 0 $short =~ tr{dmyDMY}{}cd;
296 0 $short =~ tr{dmyDMY}{dmydmy}s;
297  
298 0 return $short;
299 },
300  
301 0 ▶ full_date_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
302 0 $_[0]->_convert_to_strftime( $_[0]->date_format_full() );
303 },
304  
305 0 ▶ long_date_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
306 0 $_[0]->_convert_to_strftime( $_[0]->date_format_long() );
307 },
308  
309 0 ▶ medium_date_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
310 0 $_[0]->_convert_to_strftime( $_[0]->date_format_medium() );
311 },
312  
313 0 ▶ short_date_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
314 0 $_[0]->_convert_to_strftime( $_[0]->date_format_short() );
315 },
316  
317 0 ▶ default_date_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
318 0 $_[0]->_convert_to_strftime( $_[0]->date_format_default() );
319 },
320  
321 0 ▶ full_time_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
322 0 $_[0]->_convert_to_strftime( $_[0]->time_format_full() );
323 },
324  
325 0 ▶ long_time_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
326 0 $_[0]->_convert_to_strftime( $_[0]->time_format_long() );
327 },
328  
329 0 ▶ medium_time_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
330 0 $_[0]->_convert_to_strftime( $_[0]->time_format_medium() );
331 },
332  
333 0 ▶ short_time_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
334 0 $_[0]->_convert_to_strftime( $_[0]->time_format_short() );
335 },
336  
337 0 ▶ default_time_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
338 0 $_[0]->_convert_to_strftime( $_[0]->time_format_default() );
339 },
340  
341 0 ▶ full_datetime_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
342 0 $_[0]->_convert_to_strftime( $_[0]->datetime_format_full() );
343 },
344  
345 0 ▶ long_datetime_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
346 0 $_[0]->_convert_to_strftime( $_[0]->datetime_format_long() );
347 },
348  
349 0 ▶ medium_datetime_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
350 0 $_[0]->_convert_to_strftime( $_[0]->datetime_format_medium() );
351 },
352  
353 0 ▶ short_datetime_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
354 0 $_[0]->_convert_to_strftime( $_[0]->datetime_format_short() );
355 },
356  
357 0 ▶ default_datetime_format => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
358 0 $_[0]->_convert_to_strftime( $_[0]->datetime_format_default() );
359 },
360 2 );
361  
362 2 for my $name ( keys %subs ) {
363 86 my $real_sub = $subs{$name};
364  
365 0 ▶ my $sub = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
366 0 carp
367 "The $name method in DateTime::Locale::Base has been deprecated. Please see the DateTime::Locale distribution's Changes file for details";
368 0 return shift->$real_sub(@_);
369 86 };
370  
371 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
372 86 *{$name} = $sub;
373 }
374 }
375  
376 # Older versions of DateTime.pm will not pass in the $cldr_ok flag, so
377 # we will give them the converted-to-strftime pattern (bugs and all).
378 0 ▶sub _convert_to_strftime {
Subroutine _convert_to_strftime: not called CC=3 SCAR=24.8
379 0 my $self = shift;
380 0 my $pattern = shift;
381 0 my $cldr_ok = shift;
382  
383 0 ▶ return $pattern if $cldr_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $cldr_ok 0 0 0
384  
385 return $self->{_converted_patterns}{$pattern}
386 0 ▶ if exists $self->{_converted_patterns}{$pattern};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"_converted_patterns"}{$pattern} 0 0 0
387  
388 0 return $self->{_converted_patterns}{$pattern}
389 = $self->_cldr_to_strftime($pattern);
390 }
391  
392 {
393 2 my @JavaPatterns = (
394 qr/G/ => '{era}',
395 qr/yyyy/ => '{ce_year}',
396 qr/y/ => 'y',
397 qr/u/ => 'Y',
398 qr/MMMM/ => 'B',
399 qr/MMM/ => 'b',
400 qr/MM/ => 'm',
401 qr/M/ => '{month}',
402 qr/dd/ => 'd',
403 qr/d/ => '{day}',
404 qr/hh/ => 'l',
405 qr/h/ => '{hour_12}',
406 qr/HH/ => 'H',
407 qr/H/ => '{hour}',
408 qr/mm/ => 'M',
409 qr/m/ => '{minute}',
410 qr/ss/ => 'S',
411 qr/s/ => '{second}',
412 qr/S/ => 'N',
413 qr/EEEE/ => 'A',
414 qr/E/ => 'a',
415 qr/D/ => 'j',
416 qr/F/ => '{weekday_of_month}',
417 qr/w/ => 'V',
418 qr/W/ => '{week_month}',
419 qr/a/ => 'p',
420 qr/k/ => '{hour_1}',
421 qr/K/ => '{hour_12_0}',
422 qr/z/ => '{time_zone_long_name}',
423 );
424  
425 0 ▶ sub _cldr_to_strftime {
Subroutine _cldr_to_strftime: not called CC=3 SCAR=24.8
426 0 shift;
427 0 my $simple = shift;
428  
429 0 $simple
430 =~ s/(G+|y+|u+|M+|d+|h+|H+|m+|s+|S+|E+|D+|F+|w+|W+|a+|k+|K+|z+)|'((?:[^']|'')*)'/
431 0 ▶ $2 ? _stringify($2) : $1 ? _convert($1) : "'"/eg;
Branch: 2 branches
BranchTrueFalseTotal
$2 ? : 0 0 0
$1 ? : 0 0 0
432  
433 0 return $simple;
434 }
435  
436 0 ▶ sub _convert {
Subroutine _convert: not called CC=3 SCAR=24.8
437 0 my $simple = shift;
438  
439 0 ▶ for ( my $x = 0; $x < @JavaPatterns; $x += 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x < @JavaPatterns) 0 0 0
440 0 ▶ return '%' . $JavaPatterns[ $x + 1 ]
Branch: 1 branch
BranchTrueFalseTotal
if $simple =~ /$JavaPatterns[$x]/ 0 0 0
441 if $simple =~ /$JavaPatterns[$x]/;
442 }
443  
444 0 die "**Dont know $simple***";
445 }
446  
447 0 ▶ sub _stringify {
Subroutine _stringify: not called CC=1 SCAR=6.9
448 0 my $string = shift;
449  
450 0 $string =~ s/%(?:[^%])/%%/g;
451 0 $string =~ s/\'\'/\'/g;
452  
453 0 return $string;
454 }
455 }
456  
457 # end backwards compat
458  
459 2 ▶sub STORABLE_freeze {
Subroutine STORABLE_freeze: not called CC=2 SCAR=15.1
Pod undocumented
460 0 my $self = shift;
461 0 my $cloning = shift;
462  
463 0 ▶ return if $cloning;
Branch: 1 branch
BranchTrueFalseTotal
if $cloning 0 0 0
464  
465 0 return $self->id();
466 }
467  
468 0 ▶sub STORABLE_thaw {
Subroutine STORABLE_thaw: not called CC=1 SCAR=6.9
Pod undocumented
469 0 my $self = shift;
470 0 shift;
471 0 my $serialized = shift;
472  
473 0 my $obj = DateTime::Locale->load($serialized);
474  
475 0 %$self = %$obj;
476  
477 0 return $self;
478 }
479  
480 2 1;
481  
482 # ABSTRACT: Base class for individual locale objects (deprecated)
483  
484 __END__
« blib/lib/DateTime/Locale.pm ↑ Summary blib/lib/DateTime/Locale/Data.pm »