On Tue, 2009-04-14 at 22:37 -0430, Ernesto Hernández-Novich wrote: > Package: libtimedate-perl > Version: 1.1600-9 > Severity: important > Tags: patch > > Using Date::Format to format a date including the timezone as an > offset (%z) does not work correctly if the offset is 30 minutes. > I noticed the problem since I need VET (-4:30) and several mail > headers started to be very wrong. > > A simple test shows > > #!/usr/bin/perl > use Date::Format; > print time2str("%Y-%m-%d %T %Z %z", $^T, "+0400")."\n"; > print time2str("%Y-%m-%d %T %Z %z", $^T, "+0430")."\n"; > print time2str("%Y-%m-%d %T %Z %z", $^T, "+0000")."\n"; > print time2str("%Y-%m-%d %T %Z %z", $^T, "-0400")."\n"; > print time2str("%Y-%m-%d %T %Z %z", $^T, "-0430")."\n"; > > $ perl ~/z.pl > 2009-04-15 06:58:32 +0400 +0400 > 2009-04-15 07:28:32 +0430 +041800 > 2009-04-15 02:58:32 +0000 +0000 > 2009-04-14 22:58:32 -0400 -0400 > 2009-04-14 22:28:32 -0430 -041800 > > The problem is in function format_z in /usr/share/perl5/Date/Format.pm > line 239. I've replaced it with > > sprintf("%+05d", int($o/3600)*100 + ($o-int($o/3600)*3600)/60 ); > > and it seems to work out ok.
But after some thoughts and inputs from Gunnar Wolf on IRC, I think sprintf("%+03d%02d", int($o / 3600), int(abs($o) % 3600) / 60); would be better because is less of a change to the original line and its intentions are clearer. Besides, it also works for timezones with other weird offsets like +1245 (Catham Islands) +0545 (Kathmandu) and I even tried with things like -0417 Because I Can (tm). -- 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 -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org