Dave Rolsky wrote:
On Fri, 23 Oct 2009, Ronald J Kimball wrote:
I have a subroutine that uses two DateTime objects. It calls
delta_ms() to get the delta between the two objects, does a bit of
math, then calls add() to add the delta to one of the objects.
Although both objects are created with time_zone => local,
occasionally the result is 4 hours ahead of what I expect (which would
correspond to UTC).
Can you break this down to a _much_ smaller example that demonstrates
the problem (ideally, just 2-4 lines)? I'm too lazy to wade through all
the irrelevant code here.
That's fair. Unfortunately, I haven't been able to reproduce the
problem outside the actual application. However, I added some logging
and got some additional info.
When I get the wrong result, the first DateTime object has its time zone
set to UTC, rather than to America/New York (my local time zone).
The object is created like so:
my %tmp;
@tmp{qw/ year month day hour minute second /} =
$current_delivery_date =~ /(\d+)/g;
my $dt = DateTime->new(%tmp, time_zone => 'local');
Then, I check the name of the time zone with:
$dt->time_zone->name
and sometimes it's UTC.
Do you have any guesses as to why this could be happening?
Here's the version info I forgot to include originally:
DateTime 0.50
DateTime::TimeZone 0.90
perl 5.10.0
OS Ubuntu Hardy x64
thanks,
Ronald