line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
10
|
|
|
10
|
|
59
|
use strict; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
306
|
|
2
|
10
|
|
|
10
|
|
47
|
use warnings; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
409
|
|
3
|
|
|
|
|
|
|
package Time::C::Util; |
4
|
|
|
|
|
|
|
$Time::C::Util::VERSION = '0.024'; |
5
|
|
|
|
|
|
|
# ABSTRACT: Utility functions for Time::C and friends. |
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
48
|
use Carp qw/ croak /; |
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
383
|
|
8
|
10
|
|
|
10
|
|
45
|
use Data::Munge qw/ slurp /; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
437
|
|
9
|
10
|
|
|
10
|
|
3535
|
use File::Share qw/ dist_file /; |
|
10
|
|
|
|
|
57914
|
|
|
10
|
|
|
|
|
548
|
|
10
|
10
|
|
|
10
|
|
72
|
use Function::Parameters qw/ :strict /; |
|
10
|
|
|
|
|
37
|
|
|
10
|
|
|
|
|
82
|
|
11
|
10
|
|
|
10
|
|
4414
|
use Exporter qw/ import /; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
244
|
|
12
|
10
|
|
|
10
|
|
4294
|
use JSON::MaybeXS; |
|
10
|
|
|
|
|
47481
|
|
|
10
|
|
|
|
|
2283
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ get_fmt_tok get_locale /; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $loc_db; |
17
|
|
|
|
|
|
|
|
18
|
3816
|
50
|
|
3816
|
0
|
8542
|
fun get_fmt_tok ($fmt, $pos) { |
|
3816
|
50
|
|
|
|
7176
|
|
|
3816
|
|
|
|
|
6266
|
|
|
3816
|
|
|
|
|
4938
|
|
19
|
3816
|
100
|
|
|
|
8466
|
return undef if $pos >= length $fmt; |
20
|
|
|
|
|
|
|
|
21
|
3270
|
100
|
|
|
|
6966
|
my $tok_len = substr($fmt, $pos, 1) eq '%' ? 2 : 1; |
22
|
|
|
|
|
|
|
|
23
|
3270
|
|
|
|
|
5186
|
my $tok = substr $fmt, $pos, $tok_len; |
24
|
|
|
|
|
|
|
|
25
|
3270
|
|
66
|
|
|
17441
|
while (($tok eq '%O') or ($tok eq '%E') or ($tok eq '%-')) { |
|
|
|
100
|
|
|
|
|
26
|
26
|
|
|
|
|
60
|
$tok .= substr($fmt, $pos + $tok_len, 1); $tok_len++; |
|
26
|
|
|
|
|
135
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
3270
|
|
|
|
|
5076
|
$_[1] = $pos + $tok_len; |
30
|
3270
|
|
|
|
|
9975
|
return $tok; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
71
|
50
|
|
71
|
0
|
197
|
fun get_locale($type, $locale) { |
|
71
|
50
|
|
|
|
168
|
|
|
71
|
|
|
|
|
152
|
|
|
71
|
|
|
|
|
99
|
|
34
|
71
|
100
|
|
|
|
172
|
if (not defined $loc_db) { |
35
|
4
|
|
|
|
|
30
|
my $fn = dist_file('Time-C', 'locale.db'); |
36
|
4
|
50
|
|
|
|
1143
|
open my $fh, '<', $fn |
37
|
|
|
|
|
|
|
or croak "Could not open $fn: $!"; |
38
|
4
|
|
|
|
|
32
|
$loc_db = decode_json slurp $fh; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
71
|
|
|
|
|
19411
|
my $ret; |
42
|
71
|
100
|
|
|
|
305
|
if ($type eq 'weekdays') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
43
|
12
|
|
|
|
|
28
|
$ret = $loc_db->{days}->{$locale}; |
44
|
|
|
|
|
|
|
} elsif ($type eq 'weekdays_abbr') { |
45
|
19
|
|
|
|
|
61
|
$ret = $loc_db->{days_abbr}->{$locale}; |
46
|
|
|
|
|
|
|
} elsif ($type eq 'months') { |
47
|
12
|
|
|
|
|
24
|
$ret = $loc_db->{months}->{$locale}; |
48
|
|
|
|
|
|
|
} elsif ($type eq 'months_abbr') { |
49
|
14
|
|
|
|
|
39
|
$ret = $loc_db->{months_abbr}->{$locale}; |
50
|
|
|
|
|
|
|
} elsif ($type eq 'am_pm') { |
51
|
0
|
|
|
|
|
0
|
$ret = $loc_db->{am_pm}->{$locale}; |
52
|
|
|
|
|
|
|
} elsif ($type eq 'datetime') { |
53
|
5
|
|
|
|
|
23
|
$ret = $loc_db->{d_t_fmt}->{$locale}; |
54
|
|
|
|
|
|
|
} elsif ($type eq 'date') { |
55
|
0
|
|
|
|
|
0
|
$ret = $loc_db->{d_fmt}->{$locale}; |
56
|
|
|
|
|
|
|
} elsif ($type eq 'time') { |
57
|
2
|
|
|
|
|
6
|
$ret = $loc_db->{t_fmt}->{$locale}; |
58
|
|
|
|
|
|
|
} elsif ($type eq 'time_ampm') { |
59
|
0
|
|
|
|
|
0
|
$ret = $loc_db->{r_fmt}->{$locale}; |
60
|
|
|
|
|
|
|
} elsif ($type eq 'era') { |
61
|
7
|
|
50
|
|
|
26
|
$ret = $loc_db->{era}->{$locale} // []; |
62
|
|
|
|
|
|
|
} elsif ($type eq 'era_datetime') { |
63
|
0
|
|
0
|
|
|
0
|
$ret = $loc_db->{era_d_t_fmt}->{$locale} // $loc_db->{d_t_fmt}->{$locale}; |
64
|
|
|
|
|
|
|
} elsif ($type eq 'era_time') { |
65
|
0
|
|
0
|
|
|
0
|
$ret = $loc_db->{era_t_fmt}->{$locale} // $loc_db->{t_fmt}->{$locale}; |
66
|
|
|
|
|
|
|
} elsif ($type eq 'era_date') { |
67
|
0
|
|
0
|
|
|
0
|
$ret = $loc_db->{era_d_fmt}->{$locale} // $loc_db->{d_fmt}->{$locale}; |
68
|
|
|
|
|
|
|
} elsif ($type eq 'digits') { |
69
|
0
|
|
0
|
|
|
0
|
$ret = $loc_db->{alt_digits}->{$locale} // []; |
70
|
0
|
|
|
|
|
0
|
} else { croak "Unknown locale type: $type."; } |
71
|
|
|
|
|
|
|
|
72
|
71
|
50
|
|
|
|
167
|
croak "Value for locale type $type in locale $locale is undefined." |
73
|
|
|
|
|
|
|
if not defined $ret; |
74
|
|
|
|
|
|
|
|
75
|
71
|
|
|
|
|
312
|
return $ret; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |