Date/Language.pm

filter: Statementstmt 98.7% 76 / 77 Branchbran 55.0% 11 / 20 Conditioncond 64.2% 9 / 14 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 92.3% 12 / 13 Podpod 33.3% 1 / 3 totaltotal 82.9% 112 / 135 CC 17 SCAR 16.9
CC
17
Cov
86%
str2time
11.3
new
4.2
AUTOLOAD
3.1
CRAP 5.4
« Time/Zone.pm ↑ Summary Date/Language/Hungarian.pm »
1  
2 package Date::Language;
3  
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use Time::Local;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 require Date::Format;
9  
10 9 our $VERSION = '2.35'; # VERSION: generated
11 # ABSTRACT: Language specific date formatting and parsing
12  
13 9 ▶use base qw(Date::Format::Generic);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 sub _build_lookups
16 99 ▶{
Subroutine _build_lookups: called CC=1 SCAR=0.0
17 99 my $pkg = caller;
18 9 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 99 @{"${pkg}::MoY"}{@{"${pkg}::MoY"}} = (0 .. scalar(@{"${pkg}::MoY"}));
20 99 @{"${pkg}::MoY"}{@{"${pkg}::MoYs"}} = (0 .. scalar(@{"${pkg}::MoYs"}));
21 99 @{"${pkg}::DoW"}{@{"${pkg}::DoW"}} = (0 .. scalar(@{"${pkg}::DoW"}));
22 99 @{"${pkg}::DoW"}{@{"${pkg}::DoWs"}} = (0 .. scalar(@{"${pkg}::DoWs"}));
23 }
24  
25 sub new
26 103 ▶{
Subroutine new: called CC=4 SCAR=14.3
Pod undocumented
27 103 my $self = shift;
28 103 ▶ my $type = shift || $self;
Condition33%1/3
shift() || $self
l!l&&r!l&&!r
10300
MC/DC0%0/2
shift() || $self
shift() $self
Truth table33%1/3
A || B
A= shift()B= $self
ABresult
1X1
011
000
29  
30 103 $type =~ s/^(\w+)$/Date::Language::$1/;
31  
32 103 ▶ croak "Bad language"
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^[\w:]+$/ 0 103 103
33 unless $type =~ /^[\w:]+$/;
34  
35 103 ▶ eval "require $type"
Branch: 1 branch
BranchTrueFalseTotal
eval "require $type" or croak($@) 102 1 103
36 or croak $@;
37  
38 102 bless [], $type;
39 }
40  
41 # Stop AUTOLOAD being called ;-)
42 0 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
43  
44 sub AUTOLOAD
45 21 ▶{
Subroutine AUTOLOAD: called CC=3 SCAR=11.2
46 21 our $AUTOLOAD;
47 21 ▶ if($AUTOLOAD =~ /::strptime\Z/o)
Branch: 1 branch
BranchTrueFalseTotal
if ($Date::Language::AUTOLOAD =~ /::strptime\Z/o) 21 0 21
48 {
49 21 my $self = $_[0];
50 21 ▶ my $type = ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
2100
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
51 21 require Date::Parse;
52  
53 9 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
54 21 *{"${type}::strptime"} = Date::Parse::gen_parser(
55 21 \%{"${type}::DoW"},
56 21 \%{"${type}::MoY"},
57 21 \@{"${type}::Dsuf"},
58 1);
59  
60 21 goto &{"${type}::strptime"};
61 }
62  
63 0 croak "Undefined method &$AUTOLOAD called";
64 }
65  
66 20 ▶sub format_Z {
Subroutine format_Z: called CC=3 SCAR=11.0
Pod undocumented
67 20 my $tz = Date::Format::Generic::format_Z(@_);
68 20 ▶ my $pkg = ref($_[0]) || 'Date::Language';
Condition50%1/2
ref $_[0] || 'Date::Language'
l!l
200
MC/DC0%0/1
ref $_[0] || 'Date::Language'
ref $_[0]
Truth table50%1/2
A
A= ref $_[0]
Aresult
11
00
69 9 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
70 20 my $tz_map = \%{"${pkg}::TZ"};
71 20 ▶ return exists $tz_map->{$tz} ? $tz_map->{$tz} : $tz;
Branch: 1 branch
BranchTrueFalseTotal
exists $tz_map->{$tz} ? : 5 15 20
72 }
73  
74 sub str2time
75 26 ▶{
Subroutine str2time: called CC=10 SCAR=24.2
Pod documented
76 26 my $me = shift;
77 26 my @t = $me->strptime(@_);
78  
79 return undef
80 26 ▶ unless @t;
Branch: 1 branch
BranchTrueFalseTotal
unless @t 0 26 26
81  
82 26 my($ss,$mm,$hh,$day,$month,$year,$zone) = @t;
83 26 my @lt = localtime(time);
84  
85 26 ▶ $hh ||= 0;
Condition100%2/2
$hh ||= 0
l!l
188
MC/DC100%1/1
$hh ||= 0
$hh
Truth table100%2/2
A
A= $hh
Aresult
11
00
86 26 ▶ $mm ||= 0;
Condition100%2/2
$mm ||= 0
l!l
188
MC/DC100%1/1
$mm ||= 0
$mm
Truth table100%2/2
A
A= $mm
Aresult
11
00
87 26 ▶ $ss ||= 0;
Condition100%2/2
$ss ||= 0
l!l
188
MC/DC100%1/1
$ss ||= 0
$ss
Truth table100%2/2
A
A= $ss
Aresult
11
00
88  
89 26 ▶ $month = $lt[4]
Branch: 1 branch
BranchTrueFalseTotal
unless defined $month 0 26 26
90 unless(defined $month);
91  
92 26 ▶ $day = $lt[3]
Branch: 1 branch
BranchTrueFalseTotal
unless defined $day 0 26 26
93 unless(defined $day);
94  
95 26 ▶ $year = ($month > $lt[4]) ? ($lt[5] - 1) : $lt[5]
Branch: 2 branches
BranchTrueFalseTotal
unless defined $year 0 26 26
$month > $lt[4] ? : 0 0 0
96 unless(defined $year);
97  
98 26 ▶ return defined $zone ? timegm($ss,$mm,$hh,$day,$month,$year) - $zone
Branch: 1 branch
BranchTrueFalseTotal
defined $zone ? : 0 26 26
99 : timelocal($ss,$mm,$hh,$day,$month,$year);
100 }
101  
102 9 1;
103  
104 __END__
« Time/Zone.pm ↑ Summary Date/Language/Hungarian.pm »