Subject: | Duration minutes incorrect on DST boundary |
I was attempting to subtract one datetime object from another with
different timezones. One being America/New_York and the other being
Asia/Hong_Kong this was for March 9, 2009 with hour = 0 minute = 0 and
second = 0. I expected to see a delta_minutes value of 720 since New
York is a 12 hour time difference on that day. On the other half of the
year it is a 13 hour difference. The result was 660 minutes which was
only 11 hour. Below is the test code.
#!/usr/bin/perl -w
use strict;
use DateTime;
my ($ey,$sy,$em,$sm,$ed,$sd) = ('2009','2009','03','03','09','09');
my $tz1 = 'America/New_York';
my $tz2 = 'Asia/Hong_Kong';
my ($begintz,$endtz) = ($tz1,$tz2);
my $z1d = DateTime->new(year => $sy, month => $sm, day => $sd, hour =>
0, minute => 0, second => 0, time_zone => $begintz );
my $z2d = DateTime->new(year => $sy, month => $sm, day => $sd, hour =>
0, minute => 0, second => 0, time_zone => $endtz );
my $d = $z1d - $z2d;
print $d->delta_minutes . "\n";