5 use DateTime::LeapSecond;
8 sub _normalize_tai_seconds
10 return if grep { $_ == INFINITY() || $_ == NEG_INFINITY() } @_[1,2];
12 # This must be after checking for infinity, because it breaks in
13 # presence of use integer !
20 $adj = ( $_[2] - 86399 ) / 86400;
29 $_[2] -= $adj * 86400;
32 sub _normalize_leap_seconds
34 # args: 0 => days, 1 => seconds
39 # rough adjust - can adjust many days
42 $delta_days = ($_[2] - 86399) / 86400;
46 $delta_days = $_[2] / 86400;
49 my $new_day = $_[1] + $delta_days;
50 my $delta_seconds = ( 86400 * $delta_days ) +
51 DateTime::LeapSecond::leap_seconds( $new_day ) -
52 DateTime::LeapSecond::leap_seconds( $_[1] );
54 $_[2] -= $delta_seconds;
57 # fine adjust - up to 1 day
58 my $day_length = DateTime::LeapSecond::day_length( $new_day );
59 if ( $_[2] >= $day_length )
66 $day_length = DateTime::LeapSecond::day_length( $new_day - 1 );