| 1 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Time::C::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | $Time::C::Util::VERSION = '0.024'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: Utility functions for Time::C and friends. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use Carp qw/ croak /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use Data::Munge qw/ slurp /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use File::Share qw/ dist_file /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use Function::Parameters qw/ :strict /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use Exporter qw/ import /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 9 | our @EXPORT_OK = qw/ get_fmt_tok get_locale /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 9 | my $loc_db; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | fun get_fmt_tok ($fmt, $pos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_fmt_tok: not called CC=8 SCAR=42.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | return undef if $pos >= length $fmt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | my $tok_len = substr($fmt, $pos, 1) eq '%' ? 2 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $tok = substr $fmt, $pos, $tok_len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | while (($tok eq '%O') or ($tok eq '%E') or ($tok eq '%-')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$tok eq "%O" or $tok eq "%E" or $tok eq "%-"
$tok eq "%O" or $tok eq "%E"
MC/DC0%0/3
$tok eq "%O" or $tok eq "%E" or $tok eq "%-"
$tok eq "%O"
$tok eq "%E"
$tok eq "%-"
Truth table0%0/4
A or B or C
A= $tok eq "%O"B= $tok eq "%E"C= $tok eq "%-"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $tok .= substr($fmt, $pos + $tok_len, 1); $tok_len++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $_[1] = $pos + $tok_len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | return $tok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 9 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | fun get_locale($type, $locale) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_locale: not called CC=25 SCAR=64.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if (not defined $loc_db) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $fn = dist_file('Time-C', 'locale.db'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | open my $fh, '<', $fn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | or croak "Could not open $fn: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $loc_db = decode_json slurp $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ($type eq 'weekdays') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 14 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $ret = $loc_db->{days}->{$locale}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } elsif ($type eq 'weekdays_abbr') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $ret = $loc_db->{days_abbr}->{$locale}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } elsif ($type eq 'months') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $ret = $loc_db->{months}->{$locale}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } elsif ($type eq 'months_abbr') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $ret = $loc_db->{months_abbr}->{$locale}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } elsif ($type eq 'am_pm') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $ret = $loc_db->{am_pm}->{$locale}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } elsif ($type eq 'datetime') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $ret = $loc_db->{d_t_fmt}->{$locale}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } elsif ($type eq 'date') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $ret = $loc_db->{d_fmt}->{$locale}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } elsif ($type eq 'time') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $ret = $loc_db->{t_fmt}->{$locale}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } elsif ($type eq 'time_ampm') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $ret = $loc_db->{r_fmt}->{$locale}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } elsif ($type eq 'era') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $ret = $loc_db->{era}->{$locale} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$loc_db->{"era"}{$locale} // []
MC/DC0%0/1
$loc_db->{"era"}{$locale} // []
$loc_db->{"era"}{$locale}
Truth table0%0/2
A
A= $loc_db->{"era"}{$locale}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } elsif ($type eq 'era_datetime') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | $ret = $loc_db->{era_d_t_fmt}->{$locale} // $loc_db->{d_t_fmt}->{$locale}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$loc_db->{"era_d_t_fmt"}{$locale} // $loc_db->{"d_t_fmt"}{$locale}
MC/DC0%0/2
$loc_db->{"era_d_t_fmt"}{$locale} // $loc_db->{"d_t_fmt"}{$locale}
$loc_db->{"era_d_t_fmt"}{$locale}
$loc_db->{"d_t_fmt"}{$locale}
Truth table0%0/3
A // B
A= $loc_db->{"era_d_t_fmt"}{$locale}B= $loc_db->{"d_t_fmt"}{$locale}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } elsif ($type eq 'era_time') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $ret = $loc_db->{era_t_fmt}->{$locale} // $loc_db->{t_fmt}->{$locale}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$loc_db->{"era_t_fmt"}{$locale} // $loc_db->{"t_fmt"}{$locale}
MC/DC0%0/2
$loc_db->{"era_t_fmt"}{$locale} // $loc_db->{"t_fmt"}{$locale}
$loc_db->{"era_t_fmt"}{$locale}
$loc_db->{"t_fmt"}{$locale}
Truth table0%0/3
A // B
A= $loc_db->{"era_t_fmt"}{$locale}B= $loc_db->{"t_fmt"}{$locale}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } elsif ($type eq 'era_date') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $ret = $loc_db->{era_d_fmt}->{$locale} // $loc_db->{d_fmt}->{$locale}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$loc_db->{"era_d_fmt"}{$locale} // $loc_db->{"d_fmt"}{$locale}
MC/DC0%0/2
$loc_db->{"era_d_fmt"}{$locale} // $loc_db->{"d_fmt"}{$locale}
$loc_db->{"era_d_fmt"}{$locale}
$loc_db->{"d_fmt"}{$locale}
Truth table0%0/3
A // B
A= $loc_db->{"era_d_fmt"}{$locale}B= $loc_db->{"d_fmt"}{$locale}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } elsif ($type eq 'digits') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $ret = $loc_db->{alt_digits}->{$locale} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$loc_db->{"alt_digits"}{$locale} // []
MC/DC0%0/1
$loc_db->{"alt_digits"}{$locale} // []
$loc_db->{"alt_digits"}{$locale}
Truth table0%0/2
A
A= $loc_db->{"alt_digits"}{$locale}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | } else { croak "Unknown locale type: $type."; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | croak "Value for locale type $type in locale $locale is undefined." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | if not defined $ret; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 9 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||