Subject: | Issues with DateMath on DST change over day(s) |
Trying to perform what we think is a valid subtraction on April 3, 2005
causes DateTime to report unusual values.
The attached test subtracts 7am from 8am which should yield 60 minute
difference, but instead reports 0 minutes.
It then attempts to subtract 7am from 7am, expecting to get 0 minute
duration but instead gets 1380 minutes.
Something clearly isn't right with either our understanding of the docs,
or with DateTime on Daylight Savings Time changeover days.
Subject: | spring_ahead.pl |
#!/usr/local/bin/perl5
use strict;
use warnings;
use DateTime;
use Test::More qw(no_plan);
diag "DateTime version ", $DateTime::VERSION, "\n";
my $dt1 = DateTime->new( year => 2005, month => 4, day => 3,
hour => 7, minute => 0,
time_zone => "America/New_York" )
or die "DateTime object creation failed";
my $dt2 = DateTime->new( year => 2005, month => 4, day => 3,
hour => 8, minute => 0,
time_zone => "America/New_York" )
or die "DateTime object creation failed";
diag "dt1 is ", $dt1->strftime("%Y-%b-%d %T %Z"), "\n";
diag "dt2 is ", $dt2->strftime("%Y-%b-%d %T %Z"), "\n";
{
my $dur = $dt2 - $dt1;
my ($minutes, $seconds) = $dur->in_units('minutes','seconds');
#diag "dt2 - dt1 = $minutes minutes, $seconds seconds\n";
is($minutes, 60);
is($seconds, 0);
}
{
my $dur = $dt1 - $dt1;
my ($minutes, $seconds) = $dur->in_units('minutes','seconds');
#diag "dt1 - dt1 = $minutes minutes, $seconds seconds\n";
is($minutes, 0);
is($seconds, 0);
}