Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 79061
Status: rejected
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: tvmaly [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.50
  • 0.70
  • 0.76
Fixed in: (no value)



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);
Subject: Re: [rt.cpan.org #79061] DateTime from_epoch timezone issue
Date: Fri, 17 Aug 2012 15:08:07 -0500 (CDT)
To: "tvmaly [...] gmail.com via RT" <bug-DateTime [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Fri, 17 Aug 2012, tvmaly@gmail.com via RT wrote: Show quoted text
> 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.
The epoch is the current time _in the UTC time zone_. The from_epoch method creates a new object in UTC. If you pass a time zone into it, it then sets the object to that time zone, which means that both objects have the same UTC time, but different local times. The subtraction is based on UTC times, so it doesn't show a difference. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/