line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::PPExtra; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.61'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
425
|
use DateTime::LeapSecond; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
83
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
11
|
|
|
|
|
|
|
sub _normalize_tai_seconds { |
12
|
|
|
|
|
|
|
return |
13
|
|
|
|
|
|
|
if |
14
|
3
|
100
|
|
3
|
|
9
|
grep { $_ == DateTime::INFINITY() || $_ == DateTime::NEG_INFINITY() } |
|
6
|
100
|
|
|
|
34
|
|
15
|
|
|
|
|
|
|
@_[ 1, 2 ]; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# This must be after checking for infinity, because it breaks in |
18
|
|
|
|
|
|
|
# presence of use integer ! |
19
|
1
|
|
|
1
|
|
8
|
use integer; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
4
|
my $adj; |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
4
|
if ( $_[2] < 0 ) { |
24
|
0
|
|
|
|
|
0
|
$adj = ( $_[2] - 86399 ) / 86400; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
1
|
|
|
|
|
2
|
$adj = $_[2] / 86400; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
3
|
$_[1] += $adj; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
3
|
$_[2] -= $adj * 86400; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _normalize_leap_seconds { |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# args: 0 => days, 1 => seconds |
38
|
0
|
|
|
0
|
|
|
my $delta_days; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
88
|
use integer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# rough adjust - can adjust many days |
43
|
0
|
0
|
|
|
|
|
if ( $_[2] < 0 ) { |
44
|
0
|
|
|
|
|
|
$delta_days = ( $_[2] - 86399 ) / 86400; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
0
|
|
|
|
|
|
$delta_days = $_[2] / 86400; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $new_day = $_[1] + $delta_days; |
51
|
0
|
|
|
|
|
|
my $delta_seconds |
52
|
|
|
|
|
|
|
= ( 86400 * $delta_days ) |
53
|
|
|
|
|
|
|
+ DateTime::LeapSecond::leap_seconds($new_day) |
54
|
|
|
|
|
|
|
- DateTime::LeapSecond::leap_seconds( $_[1] ); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$_[2] -= $delta_seconds; |
57
|
0
|
|
|
|
|
|
$_[1] = $new_day; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# fine adjust - up to 1 day |
60
|
0
|
|
|
|
|
|
my $day_length = DateTime::LeapSecond::day_length($new_day); |
61
|
0
|
0
|
|
|
|
|
if ( $_[2] >= $day_length ) { |
|
|
0
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$_[2] -= $day_length; |
63
|
0
|
|
|
|
|
|
$_[1]++; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif ( $_[2] < 0 ) { |
66
|
0
|
|
|
|
|
|
$day_length = DateTime::LeapSecond::day_length( $new_day - 1 ); |
67
|
0
|
|
|
|
|
|
$_[2] += $day_length; |
68
|
0
|
|
|
|
|
|
$_[1]--; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my @subs = qw( |
73
|
|
|
|
|
|
|
_normalize_tai_seconds |
74
|
|
|
|
|
|
|
_normalize_leap_seconds |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
for my $sub (@subs) { |
78
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::ProhibitNoStrict) |
79
|
1
|
|
|
1
|
|
207
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
80
|
|
|
|
|
|
|
*{ 'DateTime::' . $sub } = __PACKAGE__->can($sub); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |