Miscalculation of when we're in a leap minute.
Andrew
--- lib/DateTime.pm.orig2004-01-07 17:39:02.0 -0500
+++ lib/DateTime.pm 2004-02-09 22:19:24.0 -0500
@@ -908,7 +908,7 @@
{
my ( $utc_rd_days, $utc_rd_secs ) = $smaller-utc_rd_values;
-if ( $utc_rd_secs 86340 ! $is_floating )
+if ( $utc_rd_secs = 86340 ! $is_floating )
{
# If the bigger of the two datetimes occurs in the last UTC minute
# of the UTC day, then that minute may not be 60 seconds long. If
--- t/19leap_second.t.orig 2004-02-09 22:20:09.0 -0500
+++ t/19leap_second.t 2004-02-09 22:20:13.0 -0500
@@ -2,7 +2,7 @@
use strict;
-use Test::More tests = 71;
+use Test::More tests = 74;
use DateTime;
@@ -299,3 +299,23 @@
is( $neg_dur-delta_minutes, 0, 'delta_minutes is 0' );
is( $neg_dur-delta_seconds, -36, 'delta_seconds is -36' );
}
+
+# catch off-by-one when carrying a leap second
+{
+my $dt1 = DateTime-new( year = 1998, month = 12, day = 31,
+ hour = 23, minute = 59, second = 0,
+ nanosecond = 1,
+ time_zone = 'UTC',
+ );
+
+my $dt2 = DateTime-new( year = 1999, month = 1, day = 1,
+ hour = 0, minute = 0, second = 0,
+ time_zone = 'UTC',
+ );
+
+my $pos_dur = $dt2 - $dt1;
+
+is( $pos_dur-delta_minutes, 0, 'delta_minutes is 0' );
+is( $pos_dur-delta_seconds, 60, 'delta_seconds is 60' );
+is( $pos_dur-delta_nanoseconds, 9, 'delta_nanoseconds is 999...' );
+}