Skip Menu |
 

This queue is for tickets about the TimeDate CPAN distribution.

Report information
The Basics
Id: 31052
Status: resolved
Priority: 0/
Queue: TimeDate

People
Owner: Nobody in particular
Requestors: imacat [...] mail.imacat.idv.tw
Cc:
AdminCc:

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



Subject: Incorrect Half Hour %z (timezone) in time2str()
Download (untitled) / with headers
text/plain 1.1k
Dear Graham Barr, Hi. This is imacat from Taiwan. I found that time2str() in Date::Format outputs incorrect %z time zone with half hours. The problem is demostrated below: imacat@rinse ~ % cat /tmp/test.pl #! /usr/bin/perl -w use Date::Format; print time2str("%Y-%m-%d %T %Z %z", $^T, "+0130")."\n"; print time2str("%Y-%m-%d %T %Z %z", $^T, "+0100")."\n"; print time2str("%Y-%m-%d %T %Z %z", $^T, "+0030")."\n"; print time2str("%Y-%m-%d %T %Z %z", $^T, "+0000")."\n"; print time2str("%Y-%m-%d %T %Z %z", $^T, "-0000")."\n"; print time2str("%Y-%m-%d %T %Z %z", $^T, "-0030")."\n"; print time2str("%Y-%m-%d %T %Z %z", $^T, "-0100")."\n"; print time2str("%Y-%m-%d %T %Z %z", $^T, "-0130")."\n"; imacat@rinse ~ % /tmp/test.pl 2007-11-29 09:51:02 +0130 +011800 2007-11-29 09:21:02 +0100 +0100 2007-11-29 08:51:02 +0030 +001800 2007-11-29 08:21:02 +0000 +0000 2007-11-29 08:21:02 -0000 +0000 2007-11-29 07:51:02 -0030 +001800 2007-11-29 07:21:02 -0100 -0100 2007-11-29 06:51:02 -0130 -011800 imacat@rinse ~ % I attached a patch that shall fix this, in the hope that it helps. Please tell me if there is any problem, or if I could be of any help. Thank you.
Subject: TimeDate-1.16-fmtz.diff
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 diff -u -r TimeDate-1.16.orig/lib/Date/Format.pm TimeDate-1.16/lib/Date/Format.pm - --- TimeDate-1.16.orig/lib/Date/Format.pm 2003-06-03 01:16:42.000000000 +0800 +++ TimeDate-1.16/lib/Date/Format.pm 2007-11-29 14:39:07.000000000 +0800 @@ -236,7 +236,7 @@ sub format_z { my $t = timelocal(@{$_[0]}[0..5]); my $o = defined $tzname ? tz_offset($tzname, $t) : tz_offset(undef,$t); - - sprintf("%+03d%02d", int($o / 3600), abs(int($o % 3600))); + sprintf("%+05d", int($o / 3600) * 100 + ($o - int($o / 3600) * 3600) / 60); } sub format_c { &format_x . " " . &format_X } -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFHTl91i9gubzC5S1wRArhSAJ44FM7Dgq6kGYX/ZnUPkwv9n6Xb0ACfYOWR FEK9l85ECxt2LA0/OL7+KQU= =SJpw -----END PGP SIGNATURE-----


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.