DateTimeX/Lite/Util.pm

filter: Statementstmt 90.3% 177 / 196 Branchbran 86.3% 76 / 88 Conditioncond 75.0% 30 / 40 MC/DCmcdc 66.6% 16 / 24 Subroutinesub 96.0% 24 / 25 Podpod 0.0% 0 / 13 totaltotal 83.6% 323 / 386 CC 62 SCAR 20.9
CC
62
Cov
87%
_seconds_as_components
32.2
offset_as_seconds
15.4
rd2ymd
7.0
CRAP 8.1
« DateTimeX/Lite/TimeZone/Local.pm ↑ Summary DateTimeX/Lite/TimeZone.pm »
1 # $Id: Util.pm 27589 2008-12-29 23:51:35Z daisuke $
2  
3 package DateTimeX::Lite::Util;
4 57 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 57 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 57 my (@MonthLengths, @LeapYearMonthLengths);
8 57 my (@EndOfLastMonthDayOfYear, @EndOfLastMonthDayOfLeapYear);
9 57 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=11.0
10 57 @MonthLengths = qw(31 28 31 30 31 30 31 31 30 31 30 31);
11 57 @LeapYearMonthLengths = @MonthLengths;
12 57 $LeapYearMonthLengths[1]++;
13  
14 {
15 57 my $x = 0;
16 57 foreach my $length (@MonthLengths)
17 {
18 684 push @EndOfLastMonthDayOfYear, $x;
19 684 $x += $length;
20 }
21 }
22  
23 57 @EndOfLastMonthDayOfLeapYear = @EndOfLastMonthDayOfYear;
24 57 $EndOfLastMonthDayOfLeapYear[$_]++ for 2..11;
25 }
26  
27  
28 42267 ▶sub month_length {
Subroutine month_length: called CC=2 SCAR=6.9
Pod undocumented
29 42267 my ($year, $month) = @_;
30 42267 ▶ return is_leap_year($year) ?
Branch: 1 branch
BranchTrueFalseTotal
is_leap_year($year) ? : 24740 17527 42267
31 $LeapYearMonthLengths[$month - 1] :
32 $MonthLengths[$month - 1]
33 ;
34 }
35  
36 101144 ▶sub is_leap_year {
Subroutine is_leap_year: called CC=6 SCAR=17.9
Pod undocumented
37 101144 my $year = shift;
38  
39 # According to Bjorn Tackmann, this line prevents an infinite loop
40 # when running the tests under Qemu. I cannot reproduce this on
41 # Ubuntu or with Strawberry Perl on Win2K.
42 101144 ▶ return 0 if $year == DateTimeX::Lite::INFINITY() || $year == DateTimeX::Lite::NEG_INFINITY();
Branch: 1 branch
BranchTrueFalseTotal
if $year == "Inf" or $year == "-Inf" 1 101143 101144
Condition66%2/3
$year == "Inf" or $year == "-Inf"
l!l&&r!l&&!r
10101143
MC/DC50%1/2
$year == "Inf" or $year == "-Inf"
$year == "Inf" $year == "-Inf"
Truth table66%2/3
A or B
A= $year == "Inf"B= $year == "-Inf"
ABresult
1X1
011
000
43 101143 ▶ return 0 if $year % 4;
Branch: 1 branch
BranchTrueFalseTotal
if $year % 4 35511 65632 101143
44 65632 ▶ return 1 if $year % 100;
Branch: 1 branch
BranchTrueFalseTotal
if $year % 100 7810 57822 65632
45 57822 ▶ return 0 if $year % 400;
Branch: 1 branch
BranchTrueFalseTotal
if $year % 400 120 57702 57822
46  
47 57702 return 1;
48 }
49  
50 261055 ▶sub ymd2rd {
Subroutine ymd2rd: called CC=4 SCAR=13.9
Pod undocumented
51 57 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 261055 my ( $y, $m, $d ) = @_;
53 261055 my $adj;
54  
55 # make month in range 3..14 (treat Jan & Feb as months 13..14 of
56 # prev year)
57 261055 ▶ if ( $m <= 2 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($m <= 2) { } 41995 219060 261055
elsif ($m > 14) { } 406 218654 219060
58 41995 $y -= ( $adj = ( 14 - $m ) / 12 );
59 41995 $m += 12 * $adj;
60 } elsif ( $m > 14 ) {
61 406 $y += ( $adj = ( $m - 3 ) / 12 );
62 406 $m -= 12 * $adj;
63 }
64  
65 # make year positive (oh, for a use integer 'sane_div'!)
66 261055 ▶ if ( $y < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($y < 0) 115647 145408 261055
67 115647 $d -= 146097 * ( $adj = ( 399 - $y ) / 400 );
68 115647 $y += 400 * $adj;
69 }
70  
71 # add: day of month, days of previous 0-11 month period that began
72 # w/March, days of previous 0-399 year period that began w/March
73 # of a 400-multiple year), days of any 400-year periods before
74 # that, and finally subtract 306 days to adjust from Mar 1, year
75 # 0-relative to Jan 1, year 1-relative (whew)
76  
77 261055 $d += ( $m * 367 - 1094 ) / 12 + $y % 100 * 1461 / 4 +
78 ( $y / 100 * 36524 + $y / 400 ) - 306;
79 261055 return $d;
80 }
81  
82 28627 ▶sub time_as_seconds {
Subroutine time_as_seconds: called CC=4 SCAR=13.9
Pod undocumented
83 28627 my ( $hour, $min, $sec ) = @_;
84  
85 28627 ▶ $hour ||= 0;
Condition100%2/2
$hour ||= 0
l!l
411724510
MC/DC100%1/1
$hour ||= 0
$hour
Truth table100%2/2
A
A= $hour
Aresult
11
00
86 28627 ▶ $min ||= 0;
Condition100%2/2
$min ||= 0
l!l
156627061
MC/DC100%1/1
$min ||= 0
$min
Truth table100%2/2
A
A= $min
Aresult
11
00
87 28627 ▶ $sec ||= 0;
Condition100%2/2
$sec ||= 0
l!l
25828369
MC/DC100%1/1
$sec ||= 0
$sec
Truth table100%2/2
A
A= $sec
Aresult
11
00
88  
89 28627 my $secs = $hour * 3600 + $min * 60 + $sec;
90 28627 return $secs;
91 }
92  
93 28630 ▶sub normalize_nanoseconds {
Subroutine normalize_nanoseconds: called CC=3 SCAR=11.0
Pod undocumented
94 57 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
95  
96 # seconds, nanoseconds
97 28630 ▶ if ( $_[1] < 0 )
Branch: 2 branches
BranchTrueFalseTotal
if ($_[1] < 0) { } 1 28629 28630
elsif ($_[1] >= 1000000000) { } 1 28628 28629
98 {
99 1 my $overflow = 1 + $_[1] / DateTimeX::Lite::MAX_NANOSECONDS();
100 1 $_[1] += $overflow * DateTimeX::Lite::MAX_NANOSECONDS();
101 1 $_[0] -= $overflow;
102 }
103 elsif ( $_[1] >= DateTimeX::Lite::MAX_NANOSECONDS() )
104 {
105 1 my $overflow = $_[1] / DateTimeX::Lite::MAX_NANOSECONDS();
106 1 $_[1] -= $overflow * DateTimeX::Lite::MAX_NANOSECONDS();
107 1 $_[0] += $overflow;
108 }
109 }
110  
111 sub normalize_seconds
112 2495 ▶{
Subroutine normalize_seconds: called CC=4 SCAR=13.9
Pod undocumented
113 2495 my $dt = shift;
114  
115 2495 ▶ return if $dt->{utc_rd_secs} >= 0 && $dt->{utc_rd_secs} <= 86399;
Branch: 1 branch
BranchTrueFalseTotal
if $dt->{"utc_rd_secs"} >= 0 and $dt->{"utc_rd_secs"} <= 86399 2333 162 2495
Condition100%3/3
$dt->{"utc_rd_secs"} >= 0 and $dt->{"utc_rd_secs"} <= 86399
!ll&&!rl&&r
100622333
MC/DC100%2/2
$dt->{"utc_rd_secs"} >= 0 and $dt->{"utc_rd_secs"} <= 86399
$dt->{"utc_rd_secs"} >= 0 $dt->{"utc_rd_secs"} <= 86399
Truth table100%3/3
A and B
A= $dt->{"utc_rd_secs"} >= 0B= $dt->{"utc_rd_secs"} <= 86399
ABresult
0X0
100
111
116  
117 162 ▶ if ( $dt->{tz}->is_floating )
Branch: 1 branch
BranchTrueFalseTotal
if ($dt->{'tz'}->is_floating) { } 92 70 162
118 {
119 92 normalize_tai_seconds( $dt->{utc_rd_days}, $dt->{utc_rd_secs} );
120 }
121 else
122 {
123 70 normalize_leap_seconds( $dt->{utc_rd_days}, $dt->{utc_rd_secs} );
124 }
125 }
126  
127  
128 39790 ▶sub normalize_tai_seconds {
Subroutine normalize_tai_seconds: called CC=4 SCAR=13.9
Pod undocumented
129 39790 ▶ return if grep { $_ == DateTimeX::Lite::INFINITY() || $_ == DateTimeX::Lite::NEG_INFINITY() } @_[0,1];
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == "Inf" or $_ == "-Inf";} @_[0, 1] 4 39786 39790
Condition100%3/3
$_ == 9**9**9 || $_ == -9**9**9
l!l&&r!l&&!r
4479572
MC/DC100%2/2
$_ == 9**9**9 || $_ == -9**9**9
$_ == 9**9**9 $_ == -9**9**9
Truth table100%3/3
A || B
A= $_ == 9**9**9B= $_ == -9**9**9
ABresult
1X1
011
000
130
131 # This must be after checking for infinity, because it breaks in
132 # presence of use integer !
133 57 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
134
135 39786 my $adj;
136
137 39786 ▶ if ( $_[1] < 0 )
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1] < 0) { } 101 39685 39786
138 {
139 101 $adj = ( $_[1] - 86399 ) / 86400;
140 }
141 else
142 {
143 39685 $adj = $_[1] / 86400;
144 }
145
146 39786 $_[0] += $adj;
147
148 39786 $_[1] -= $adj * 86400;
149 }
150  
151 sub rd2ymd
152 266859 ▶{
Subroutine rd2ymd: called CC=7 SCAR=19.5
Pod undocumented
153 57 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
154 266859 my $d = shift;
155 266859 my $rd = $d;
156  
157 266859 my $yadj = 0;
158 266859 my ( $c, $y, $m );
159  
160 # add 306 days to make relative to Mar 1, 0; also adjust $d to be
161 # within a range (1..2**28-1) where our calculations will work
162 # with 32bit ints
163 266859 ▶ if ( $d > 2**28 - 307 )
Branch: 2 branches
BranchTrueFalseTotal
if ($d > 268435149) { } 0 266859 266859
elsif (($d += 306) <= 0) { } 115643 151216 266859
164 {
165 # avoid overflow if $d close to maxint $yadj = ( $d - 146097 + 306 ) / 146097 + 1;
166 0 $d -= $yadj * 146097 - 306;
167 }
168 elsif ( ( $d += 306 ) <= 0 )
169 115643 { $yadj =
170 -( -$d / 146097 + 1 ); # avoid ambiguity in C division of negatives
171 115643 $d -= $yadj * 146097;
172 }
173  
174 266859 $c = ( $d * 4 - 1 ) / 146097; # calc # of centuries $d is after 29 Feb of yr 0
175 266859 $d -= $c * 146097 / 4; # (4 centuries = 146097 days)
176 266859 $y = ( $d * 4 - 1 ) / 1461; # calc number of years into the century,
177 266859 $d -= $y * 1461 / 4; # again March-based (4 yrs =~ 146[01] days)
178 266859 $m = ( $d * 12 + 1093 ) / 367; # get the month (3..14 represent March through
179 266859 $d -= ( $m * 367 - 1094 ) / 12; # February of following year)
180 266859 $y += $c * 100 + $yadj * 400; # get the real year, which is off by
181 266859 ▶ ++$y, $m -= 12 if $m > 12; # one if month is January or February
Branch: 1 branch
BranchTrueFalseTotal
if $m > 12 41523 225336 266859
182  
183 266859 ▶ if ( $_[0] )
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) 28871 237988 266859
184 {
185 28871 my $dow;
186  
187 28871 ▶ if ( $rd < -6 )
Branch: 1 branch
BranchTrueFalseTotal
if ($rd < -6) { } 731 28140 28871
188 {
189 731 $dow = ( $rd + 6 ) % 7;
190 731 ▶ $dow += $dow ? 8 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$dow ? : 626 105 731
191 }
192 else
193 {
194 28140 $dow = ( ( $rd + 6 ) % 7 ) + 1;
195 }
196  
197 28871 my $doy = end_of_last_month_day_of_year( $y, $m );
198  
199 28871 $doy += $d;
200  
201 28871 my $quarter;
202 {
203 57 ▶ no integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
204 28871 $quarter = int( ( 1 / 3.1 ) * $m ) + 1;
205 }
206  
207 28871 my $qm = ( 3 * $quarter ) - 2;
208  
209 28871 my $doq = $doy - end_of_last_month_day_of_year( $y, $qm );
210  
211 28871 return ( $y, $m, $d, $dow, $doy, $quarter, $doq );
212 }
213  
214 237988 return ( $y, $m, $d );
215 }
216  
217 sub end_of_last_month_day_of_year
218 57742 ▶{
Subroutine end_of_last_month_day_of_year: called CC=2 SCAR=6.9
Pod undocumented
219 57742 my ($y, $m) = @_;
220 57742 $m--;
221 return
222 57742 ▶ ( is_leap_year($y) ?
Branch: 1 branch
BranchTrueFalseTotal
is_leap_year($y) ? : 40386 17356 57742
223 $EndOfLastMonthDayOfLeapYear[$m] :
224 $EndOfLastMonthDayOfYear[$m]
225 );
226 }
227  
228 sub _seconds_as_components
229 0 ▶{
Subroutine _seconds_as_components: not called CC=6 SCAR=34.7
230 0 shift;
231 0 my $secs = shift;
232 0 my $utc_secs = shift;
233 0 ▶ my $modifier = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
234  
235 57 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
236  
237 0 $secs -= $modifier;
238  
239 0 my $hour = $secs / 3600;
240 0 $secs -= $hour * 3600;
241  
242 0 my $minute = $secs / 60;
243  
244 0 my $second = $secs - ( $minute * 60 );
245  
246 0 ▶ if ( $utc_secs && $utc_secs >= 86400 )
Branch: 1 branch
BranchTrueFalseTotal
if ($utc_secs and $utc_secs >= 86400) 0 0 0
Condition0%0/3
$utc_secs and $utc_secs >= 86400
!ll&&!rl&&r
000
MC/DC0%0/2
$utc_secs and $utc_secs >= 86400
$utc_secs $utc_secs >= 86400
Truth table0%0/3
A and B
A= $utc_secsB= $utc_secs >= 86400
ABresult
0X0
100
111
247 {
248 # there is no such thing as +3 or more leap seconds!
249 0 ▶ die "Invalid UTC RD seconds value: $utc_secs"
Branch: 1 branch
BranchTrueFalseTotal
if $utc_secs > 86401 0 0 0
250 if $utc_secs > 86401;
251  
252 0 $second += $utc_secs - 86400 + 60;
253  
254 0 $minute = 59;
255  
256 0 $hour--;
257 0 ▶ $hour = 23 if $hour < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $hour < 0 0 0 0
258 }
259  
260 0 return ( $hour, $minute, $second );
261 }
262  
263 70 ▶sub normalize_leap_seconds {
Subroutine normalize_leap_seconds: called CC=4 SCAR=13.9
Pod undocumented
264 # args: 0 => days, 1 => seconds
265 70 my $delta_days;
266  
267 57 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
268  
269 # rough adjust - can adjust many days
270 70 ▶ if ( $_[1] < 0 )
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1] < 0) { } 52 18 70
271 {
272 52 $delta_days = ($_[1] - 86399) / 86400;
273 }
274 else
275 {
276 18 $delta_days = $_[1] / 86400;
277 }
278  
279 70 my $new_day = $_[0] + $delta_days;
280 70 my $delta_seconds = ( 86400 * $delta_days ) +
281 DateTimeX::Lite::LeapSecond::leap_seconds( $new_day ) -
282 DateTimeX::Lite::LeapSecond::leap_seconds( $_[0] );
283  
284 70 $_[1] -= $delta_seconds;
285 70 $_[0] = $new_day;
286  
287 # fine adjust - up to 1 day
288 70 my $day_length = DateTimeX::Lite::LeapSecond::day_length( $new_day );
289 70 ▶ if ( $_[1] >= $day_length )
Branch: 2 branches
BranchTrueFalseTotal
if ($_[1] >= $day_length) { } 0 70 70
elsif ($_[1] < 0) { } 3 67 70
290 {
291 0 $_[1] -= $day_length;
292 0 $_[0]++;
293 }
294 elsif ( $_[1] < 0 )
295 {
296 3 $day_length = DateTimeX::Lite::LeapSecond::day_length( $new_day - 1 );
297 3 $_[1] += $day_length;
298 3 $_[0]--;
299 }
300 }
301  
302  
303 sub seconds_as_components
304 35845 ▶{
Subroutine seconds_as_components: called CC=6 SCAR=17.9
Pod undocumented
305 35845 my $secs = shift;
306 35845 my $utc_secs = shift;
307 35845 ▶ my $modifier = shift || 0;
Condition100%2/2
shift() || 0
l!l
1635829
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
308  
309 57 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
310  
311 35845 $secs -= $modifier;
312  
313 35845 my $hour = $secs / 3600;
314 35845 $secs -= $hour * 3600;
315  
316 35845 my $minute = $secs / 60;
317  
318 35845 my $second = $secs - ( $minute * 60 );
319  
320 35845 ▶ if ( $utc_secs && $utc_secs >= 86400 )
Branch: 1 branch
BranchTrueFalseTotal
if ($utc_secs and $utc_secs >= 86400) 50 35795 35845
Condition100%3/3
$utc_secs and $utc_secs >= 86400
!ll&&!rl&&r
31437435850
MC/DC100%2/2
$utc_secs and $utc_secs >= 86400
$utc_secs $utc_secs >= 86400
Truth table100%3/3
A and B
A= $utc_secsB= $utc_secs >= 86400
ABresult
0X0
100
111
321 {
322 # there is no such thing as +3 or more leap seconds!
323 50 ▶ die "Invalid UTC RD seconds value: $utc_secs"
Branch: 1 branch
BranchTrueFalseTotal
if $utc_secs > 86401 0 50 50
324 if $utc_secs > 86401;
325  
326 50 $second += $utc_secs - 86400 + 60;
327  
328 50 $minute = 59;
329  
330 50 $hour--;
331 50 ▶ $hour = 23 if $hour < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $hour < 0 1 49 50
332 }
333  
334 35845 return ( $hour, $minute, $second );
335 }
336  
337 224 ▶sub offset_as_seconds {
Subroutine offset_as_seconds: called CC=15 SCAR=27.4
Pod undocumented
338 224 my $offset = shift;
339  
340 224 ▶ return undef unless defined $offset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $offset 0 224 224
341  
342 224 ▶ return 0 if $offset eq '0';
Branch: 1 branch
BranchTrueFalseTotal
if $offset eq 0 3 221 224
343  
344 221 my ( $sign, $hours, $minutes, $seconds );
345 221 ▶ if ( $offset =~ /^([\+\-])?(\d\d?):(\d\d)(?::(\d\d))?$/ )
Branch: 2 branches
BranchTrueFalseTotal
if ($offset =~ /^([\+\-])?(\d\d?):(\d\d)(?::(\d\d))?$/) { } 38 183 221
elsif ($offset =~ /^([\+\-])?(\d\d)(\d\d)(\d\d)?$/) { } 50 133 183
346 {
347 38 ( $sign, $hours, $minutes, $seconds ) = ( $1, $2, $3, $4 );
348 }
349 elsif ( $offset =~ /^([\+\-])?(\d\d)(\d\d)(\d\d)?$/ )
350 {
351 50 ( $sign, $hours, $minutes, $seconds ) = ( $1, $2, $3, $4 );
352 }
353 else
354 {
355 133 return undef;
356 }
357  
358 88 ▶ $sign = '+' unless defined $sign;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sign 15 73 88
359 88 ▶ return undef unless $hours >= 0 && $hours <= 99;
Branch: 1 branch
BranchTrueFalseTotal
unless $hours >= 0 and $hours <= 99 0 88 88
Condition33%1/3
$hours >= 0 and $hours <= 99
!ll&&!rl&&r
0088
MC/DC0%0/2
$hours >= 0 and $hours <= 99
$hours >= 0 $hours <= 99
Truth table33%1/3
A and B
A= $hours >= 0B= $hours <= 99
ABresult
0X0
100
111
360 88 ▶ return undef unless $minutes >= 0 && $minutes <= 59;
Branch: 1 branch
BranchTrueFalseTotal
unless $minutes >= 0 and $minutes <= 59 18 70 88
Condition66%2/3
$minutes >= 0 and $minutes <= 59
!ll&&!rl&&r
01870
MC/DC50%1/2
$minutes >= 0 and $minutes <= 59
$minutes >= 0 $minutes <= 59
Truth table66%2/3
A and B
A= $minutes >= 0B= $minutes <= 59
ABresult
0X0
100
111
361 70 ▶ return undef unless ! defined( $seconds ) || ( $seconds >= 0 && $seconds <= 59 );
Branch: 1 branch
BranchTrueFalseTotal
unless not defined $seconds or $seconds >= 0 and $seconds <= 59 6 64 70
Condition83%5/6
not defined $seconds or $seconds >= 0 and $seconds <= 59
l!l&&r!l&&!r
41236
$seconds >= 0 and $seconds <= 59
!ll&&!rl&&r
0623
MC/DC66%2/3
not defined $seconds or $seconds >= 0 and $seconds <= 59
not defined $seconds $seconds >= 0 $seconds <= 59
Truth table75%3/4
not(A) or B and C
A= not defined $secondsB= $seconds >= 0C= $seconds <= 59
ABCresult
1XX1
0111
00X0
0100
362  
363 64 my $total = $hours * 3600 + $minutes * 60;
364 64 ▶ $total += $seconds if $seconds;
Branch: 1 branch
BranchTrueFalseTotal
if $seconds 23 41 64
365 64 ▶ $total *= -1 if $sign eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $sign eq "-" 27 37 64
366  
367 64 return $total;
368 }
369  
370 74 ▶sub offset_as_string {
Subroutine offset_as_string: called CC=6 SCAR=17.9
Pod undocumented
371 74 my $offset = shift;
372  
373 74 ▶ return undef unless defined $offset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $offset 0 74 74
374 74 ▶ return undef unless $offset >= -359999 && $offset <= 359999;
Branch: 1 branch
BranchTrueFalseTotal
unless $offset >= -359999 and $offset <= 359999 2 72 74
Condition100%3/3
$offset >= -359999 and $offset <= 359999
!ll&&!rl&&r
1172
MC/DC100%2/2
$offset >= -359999 and $offset <= 359999
$offset >= -359999 $offset <= 359999
Truth table100%3/3
A and B
A= $offset >= -359999B= $offset <= 359999
ABresult
0X0
100
111
375  
376 72 ▶ my $sign = $offset < 0 ? '-' : '+';
Branch: 1 branch
BranchTrueFalseTotal
$offset < 0 ? : 31 41 72
377  
378 72 $offset = abs($offset);
379  
380 72 my $hours = int( $offset / 3600 );
381 72 $offset %= 3600;
382 72 my $mins = int( $offset / 60 );
383 72 $offset %= 60;
384 72 my $secs = int( $offset );
385  
386 72 ▶ return ( $secs ?
Branch: 1 branch
BranchTrueFalseTotal
$secs ? : 22 50 72
387 sprintf( '%s%02d%02d%02d', $sign, $hours, $mins, $secs ) :
388 sprintf( '%s%02d%02d', $sign, $hours, $mins )
389 );
390 }
391
392 57 1;
« DateTimeX/Lite/TimeZone/Local.pm ↑ Summary DateTimeX/Lite/TimeZone.pm »