TimeZone/OlsonDB/Change.pm

filter: Statementstmt 18.6% 11 / 59 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 20.0% 3 / 15 Podpod 0.0% 0 / 11 totaltotal 11.2% 14 / 124 CC 17 SCAR 40.3
CC
17
Cov
12%
new
132.0
_debug_output
42.0
two_changes_as_span
6.0
CRAP 56.0
« TimeZone.pm ↑ Summary TimeZone/OlsonDB/Zone.pm »
1 package DateTime::TimeZone::OlsonDB::Change;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $VERSION = '2.72';
8  
9 0 ▶sub new {
Subroutine new: not called CC=11 SCAR=48.8
Pod undocumented
10 0 my $class = shift;
11 0 my %p = @_;
12  
13 # These are almost always mutually exclusive, except when adding
14 # an observance change and the last rule has no offset, but the
15 # new observance has an anonymous rule. In that case, prefer the
16 # offset from std defined in the observance to that in the
17 # previous rule (what a mess!).
18 0 ▶ if ( $p{type} eq 'observance' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'type'} eq 'observance') { } 0 0 0
19 0 ▶ $p{offset_from_std} = $p{rule}->offset_from_std if defined $p{rule};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p{"rule"} 0 0 0
20 $p{offset_from_std} = $p{observance}->offset_from_std
21 0 ▶ if $p{observance}->offset_from_std;
Branch: 1 branch
BranchTrueFalseTotal
if $p{"observance"}->offset_from_std 0 0 0
22 0 ▶ $p{offset_from_std} ||= 0;
Condition0%0/2
$p{"offset_from_std"} ||= 0
l!l
00
MC/DC0%0/1
$p{"offset_from_std"} ||= 0
$p{"offset_from_std"}
Truth table0%0/2
A
A= $p{"offset_from_std"}
Aresult
11
00
23 }
24 else {
25 0 $p{offset_from_std} = $p{observance}->offset_from_std;
26 0 ▶ $p{offset_from_std} = $p{rule}->offset_from_std if defined $p{rule};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p{"rule"} 0 0 0
27 }
28  
29 0 $p{offset_from_utc} = $p{observance}->offset_from_utc;
30  
31 0 $p{is_dst} = 0;
32 0 ▶ $p{is_dst} = 1 if $p{rule} && $p{rule}->offset_from_std;
Branch: 1 branch
BranchTrueFalseTotal
if $p{"rule"} and $p{"rule"}->offset_from_std 0 0 0
Condition0%0/3
$p{"rule"} and $p{"rule"}->offset_from_std
!ll&&!rl&&r
000
MC/DC0%0/2
$p{"rule"} and $p{"rule"}->offset_from_std
$p{"rule"} $p{"rule"}->offset_from_std
Truth table0%0/3
A and B
A= $p{"rule"}B= $p{"rule"}->offset_from_std
ABresult
0X0
100
111
33 0 ▶ $p{is_dst} = 1 if $p{observance}->offset_from_std;
Branch: 1 branch
BranchTrueFalseTotal
if $p{"observance"}->offset_from_std 0 0 0
34  
35 0 ▶ if ( $p{short_name} =~ m{([\-\+\w]+)/([\-\+\w]+)} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p{"short_name"} =~ m[([\-\+\w]+)/([\-\+\w]+)]) 0 0 0
36 0 ▶ $p{short_name} = $p{is_dst} ? $2 : $1;
Branch: 1 branch
BranchTrueFalseTotal
$p{'is_dst'} ? : 0 0 0
37 }
38  
39 0 return bless \%p, $class;
40 }
41  
42 0 ▶sub utc_start_datetime { $_[0]->{utc_start_datetime} }
Subroutine utc_start_datetime: not called CC=1 SCAR=6.9
Pod undocumented
43 0 ▶sub local_start_datetime { $_[0]->{local_start_datetime} }
Subroutine local_start_datetime: not called CC=1 SCAR=6.9
Pod undocumented
44 0 ▶sub short_name { $_[0]->{short_name} }
Subroutine short_name: not called CC=1 SCAR=6.9
Pod undocumented
45 0 ▶sub is_dst { $_[0]->{is_dst} }
Subroutine is_dst: not called CC=1 SCAR=6.9
Pod undocumented
46 0 ▶sub observance { $_[0]->{observance} }
Subroutine observance: not called CC=1 SCAR=6.9
Pod undocumented
47 0 ▶sub rule { $_[0]->{rule} }
Subroutine rule: not called CC=1 SCAR=6.9
Pod undocumented
48 0 ▶sub offset_from_utc { $_[0]->{offset_from_utc} }
Subroutine offset_from_utc: not called CC=1 SCAR=6.9
Pod undocumented
49 0 ▶sub offset_from_std { $_[0]->{offset_from_std} }
Subroutine offset_from_std: not called CC=1 SCAR=6.9
Pod undocumented
50 0 ▶sub total_offset { $_[0]->offset_from_utc + $_[0]->offset_from_std }
Subroutine total_offset: not called CC=1 SCAR=6.9
Pod undocumented
51  
52 0 ▶sub two_changes_as_span {
Subroutine two_changes_as_span: not called CC=2 SCAR=17.9
Pod undocumented
53 0 my ( $c1, $c2 ) = @_;
54  
55 0 my ( $utc_start, $local_start );
56  
57 0 ▶ if ( defined $c1->utc_start_datetime ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c1->utc_start_datetime) { } 0 0 0
58 0 $utc_start = $c1->utc_start_datetime->utc_rd_as_seconds;
59 0 $local_start = $c1->local_start_datetime->utc_rd_as_seconds;
60 }
61 else {
62 0 $utc_start = $local_start = '-inf';
63 }
64  
65 0 my $utc_end = $c2->utc_start_datetime->utc_rd_as_seconds;
66 0 my $local_end = $utc_end + $c1->total_offset;
67  
68 return {
69 0 utc_start => $utc_start,
70 utc_end => $utc_end,
71 local_start => $local_start,
72 local_end => $local_end,
73 short_name => $c1->short_name,
74 offset => $c1->total_offset,
75 is_dst => $c1->is_dst,
76 };
77 }
78  
79 ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines, InputOutput::RequireCheckedSyscalls)
80 0 ▶sub _debug_output {
Subroutine _debug_output: not called CC=6 SCAR=37.4
81 0 my $self = shift;
82  
83 0 my $obs = $self->observance;
84  
85 0 ▶ if ( $self->utc_start_datetime ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->utc_start_datetime) { } 0 0 0
86 0 print ' UTC: ', $self->utc_start_datetime->datetime, "\n";
87 0 print ' Local: ', $self->local_start_datetime->datetime, "\n";
88 }
89 else {
90 0 print " First change (starts at -inf)\n";
91 }
92  
93 0 print ' Short name: ', $self->short_name, "\n";
94 0 printf " UTC offset: %s (%s)\n", $obs->offset_from_utc,
95 $obs->offset_from_utc_as_hm;
96  
97 0 ▶ if ( $obs->offset_from_std || $self->rule ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obs->offset_from_std or $self->rule) { } 0 0 0
Condition0%0/3
$obs->offset_from_std or $self->rule
l!l&&r!l&&!r
000
MC/DC0%0/2
$obs->offset_from_std or $self->rule
$obs->offset_from_std $self->rule
Truth table0%0/3
A or B
A= $obs->offset_from_stdB= $self->rule
ABresult
1X1
011
000
98 0 ▶ if ( $obs->offset_from_std ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obs->offset_from_std) 0 0 0
99 0 printf " Std offset: %s (%s)\n", $obs->offset_from_std,
100 $obs->offset_from_std_as_hm;
101 }
102  
103 0 ▶ if ( $self->rule ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->rule) 0 0 0
104 0 printf " Std offset: %s (%s) - %s rule\n",
105 $self->rule->offset_from_std,
106 $self->rule->offset_from_std_as_hm,
107 $self->rule->name;
108 }
109 }
110 else {
111 0 print " Std offset: 0 - no rule\n";
112 }
113  
114 0 print "\n";
115 }
116 ## use critic
117  
118 3 1;
« TimeZone.pm ↑ Summary TimeZone/OlsonDB/Zone.pm »