Skip Menu |

This queue is for tickets about the TimeDate CPAN distribution.

Report information
The Basics
Id: 59298
Status: open
Priority: 0/
Queue: TimeDate

People
Owner: Nobody in particular
Requestors: steven.martin [...] cfl.rr.com
Cc:
AdminCc:

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



Subject: tz_name() reports incorrect offset when the name is not defined.
Date: Tue, 13 Jul 2010 12:53:00 +0530
To: <bug-TimeDate [...] rt.cpan.org>
From: "Steven Martin" <steven.martin [...] cfl.rr.com>
I am in India where the local time is GMT +530. I expected the script below to print "IST." Instead it printed "+33000." #!/usr/bin/perl use Date::Format; print time2str("%Z%n", time); On investigation, I found that the %Z format in Date::Format uses tz_name() from Time::Zone. In tz_name(), if the name of the offset is not defined, I believe tz_name() should return the offset in the standard numeric format with the sign, hours, and minutes. However, it appears that the offset is kept in seconds while the function is calculating as if it is in minutes. I corrected the problem by adding the following line before the sprintf() in tz_name() in Zone.pm line 288: $off /= 60; There is also a latent bug for negative offsets if they include a fractional part of an hour. I changed the sprintf() from: sprintf("%+05d\n", int($off / 60) * 100 + $off % 60); to: sprintf("%+03d%02d\n", int($off / 60), abs($off) % 60); (I also uncommented the offset for IST in the definition of @Zone but that's a different issue.) I don't think it matters, but I'm running Perl 5.10 under Cygwin and using Date::Format version 2.24. Please correct the package and/or its documentation. Regards, Steven