Subject: | DateTime from_epoch timezone issue |
If I create two DateTime objects with epoch with different timezones,
the subtraction that yields the duration object does not show any
difference between the timezones.
Here is some test code
use strict;
use Data::Dumper;
use DateTime;
my $epoch = 1345231740;
my $d1 = DateTime->from_epoch( epoch => $epoch, time_zone =>
'America/New_York');
my $d2 = DateTime->from_epoch( epoch => $epoch, time_zone =>
'Asia/Hong_Kong');
my $dur1 = $d2 - $d1;
# no difference
print Dumper($dur1);
my $d3 = DateTime->new( year => $d1->year, month => $d1->month, day =>
$d1->day, hour => $d1->hour, minute => $d1->minute, second =>
$d1->second, time_zone => 'Asia/Hong_Kong');
my $dur2 = $d3 - $d1;
# shows proper difference
print Dumper($dur2);