Skip Menu |

This queue is for tickets about the Time-modules CPAN distribution.

Report information
The Basics
Id: 85738
Status: resolved
Priority: 0/
Queue: Time-modules

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

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



Subject: Time::Timezone caching in tz_local_offset causes parsedate to return wrong values.
Date: Thu, 30 May 2013 20:34:15 +0200
To: bug-Time-modules [...] rt.cpan.org
From: Adam Schobelock <schobes [...] gmail.com>
Time zone Europe/Moscow decided to permentantly move to DST<http://en.wikipedia.org/wiki/Time_in_Russia#Daylight_saving_time> on 2011-03-27. This was implemented in the IANA time zone database by changing the UTC offset instead of leaving the UTC offset the same and leaving in DST indefinitely. In Time::Timezone sub tz_local_offset has a caching mechanism that saves the offset for a time zone by caching it by the key of "TIMEZONE + ISDST". This results in different UNIX timestamps being returned depending on which non-dst definition is cached first. Example: Returns proper UNIX timestamps for Europe/Moscow. use strict; use POSIX; use Time::ParseDate; $ENV{TZ} = 'Europe/Moscow'; POSIX::tzset(); print parsedate('2009-11-01').' 2009-11-01'."\n"; print parsedate('2013-05-30').' 2013-05-30'."\n"; This produces the following results. $ perl correct_results.pl 1257022800 2009-11-01 1369861200 2013-05-30 Example: Returns the incorrect UNIX timestamps for Europe/Moscow. #!/usr/bin/perl use strict; use POSIX; use Time::ParseDate; $ENV{TZ} = 'Europe/Moscow'; POSIX::tzset(); print parsedate('2013-05-30').' 2013-05-30'."\n"; print parsedate('2009-11-01').' 2009-11-01'."\n"; This produces the following results. $ perl incorrect_results.pl 1369857600 2013-05-30 1257019200 2009-11-01 As you can see from the above when 2009-11-01 is ran through parsedate before 2013-05-30 it results in a UNIX timestamp of 1257022800, but when called after 2013-05-30, 1257019200 is returned. Because of this behavior, I don't think it is possible to cache the "TIMEZONE + ISDST" offset as it doesn't always result in the same offset from UTC.
Fixed and released.