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: 44061
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: erik [...] hollensbe.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: DateTime fails to set the timezone in a compared object when the compared object's time falls into the DST window
Here's a good test case: perl -MDateTime::Format::MySQL -e '$dt = DateTime->now; $dt->set_time_zone("America/Los_Angeles"); print $dt; $dt2 = DateTime::Format::MySQL->parse_datetime("2009-03-08 02:00:35"); print $dt > $dt2' Error is: Invalid local time for date in time zone: America/Los_Angeles change 2009 to 2008, no problems. I traced this down to the comparator setting the timezone from "floating" to "America/Los_Angeles" but didn't get much farther than that. Please let me know if I can be of further assistance.
On Thu Mar 12 05:10:15 2009, ERIKH wrote: Show quoted text
> Here's a good test case: > perl -MDateTime::Format::MySQL -e '$dt = DateTime->now; > $dt->set_time_zone("America/Los_Angeles"); print $dt; $dt2 = > DateTime::Format::MySQL->parse_datetime("2009-03-08 02:00:35"); print > $dt > $dt2' > > Error is: > Invalid local time for date in time zone: America/Los_Angeles > > change 2009 to 2008, no problems. > > I traced this down to the comparator setting the timezone from > "floating" to "America/Los_Angeles" but didn't get much farther than that. > > Please let me know if I can be of further assistance.
I thought I replied but apparently I didn't. Anyway, that's just the way this stuff works. Time zones are kind of messy, and there's no way for DateTime to know what you want. If you want to avoid this sort of issue, make sure that you convert to the floating or UTC time zone before doing comparisons. Both of those will compare cleanly without any errors. I'm going to close this ticket. If you have further questions, please discuss this on the datetime@perl.org list.