CC: | Graham Barr <gbarr [...] pobox.com> |
Subject: | Date::Format with %z gives wrong results for half-hour timezones |
Date: | Wed, 15 Apr 2009 17:30:01 -0430 |
To: | bug-timedate [...] rt.cpan.org |
From: | Ernesto Hernández-Novich <emhn [...] usb.ve> |
Using Date::Format to format a date including the timezone as an offset
(%z) does not work correctly if the offset is not an even number of
hours. I noticed the problem since I run my systems using VET (-4:30)
and several mail Date: headers built with Date::Format broke.
print time2str("%Z %z", $^T, "-0430")
gives
-0430 -041800
instead of
-0430 -0430
The bug is in line 239 of Date/Format.pm in function format_z, and I've
fixed it with
sprintf("%+03d%02d", int($o / 3600), int(abs($o) % 3600) / 60);
It also works for timezones with other weird offsets like
+1245 (Catham Islands)
+0545 (Kathmandu)
and I even tried with things like -0417. Attached a simple test for the bug.
This bus is breaking RequestTracker 3.6 and 3.8 if the system runs on
any timezone that's not a round number of hours.
This bug is also reported in Debian BTS [1].
[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=524136
--
Prof. Ernesto Hernández-Novich - MYS-220C
Geek by nature, Linux by choice, Debian of course.
If you can't aptitude it, it isn't useful or doesn't exist.
GPG Key Fingerprint = 438C 49A2 A8C7 E7D7 1500 C507 96D6 A3D6 2F4C 85E3
Message body is not shown because sender requested not to inline it.