Subject: | Time/Zone.pm missing India Standard Time |
Date: | Mon, 18 Jun 2012 22:24:01 +0000 |
To: | "bug-TimeDate [...] rt.cpan.org" <bug-TimeDate [...] rt.cpan.org> |
From: | "Callas, Cathrin (HP-UX/MCLinux Quality)" <cathrin.callas [...] hp.com> |
Summary:
Specifying the timezone "IST" causes Date::Format's time2str() to return an "uninitialized value in addition" error, and returns UTC time labeled as IST.
Distribution name and version (For example, "DBIx-SearchBuilder-0.46")
TimeDate-1.20
from: http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/TimeDate-1.20.tar.gz
Perl version (Find this by running the command perl -v)
$ perl -v
This is perl, v5.6.0 built for 9000/777-hpux
Operating System vendor and version (Find this by running the command uname -a)
$ uname -a
HP-UX psweb1 B.11.11 U 9000/800 305419896 unlimited-user license
Details about your operating environment that might be related to the issue being described
I had been using Perl scripts on a system hosted in the United States for a long time, but when the code was copied to a server in India I noticed this issue. I downloaded the latest version available from CPAN and it still has the issue. The "ist" time zone is commented out in Time/Zone.pm. I installed the module into a custom location and uncommented that line, and it appears to work.
Exact cut and pasted error or warning messages:
The example code below gives this error message, and a time is returned but it is UTC time, even though the returned timezone is "IST":
Use of uninitialized value in addition (+) at /opt/perl/lib/site_perl/5.6.1/Date/Format.pm line 118.
The shortest, clearest code you can manage to write which reproduces the bug described:
#!/usr/local/bin/perl -w
use lib "/opt/perl/lib/site_perl/5.6.1";
use Date::Format;
use Time::Zone;
use Date::Parse;
my $timezone = "IST";
my $todays_date = time();
my $formatted_date
= time2str( "%Y-%m-%d %X %Z", $todays_date, "$timezone" );
print qq{"$todays_date" formatted, and converted to $timezone is: "$formatted_date"\n};
exit;
Output from the above script is:
$ test_tz.pl 2>&1
Use of uninitialized value in addition (+) at /opt/perl/lib/site_perl/5.6.1/Date/Format.pm line 118.
"1340058036" formatted, and converted to IST is: "2012-06-18 22:20:36 IST"
A patch against the latest released version of this distribution which fixes this bug:
$ diff latest/Zone.pm custom/Zone.pm
223c223
< # "ist" => +5*3600+1800,# Indian Standard
---
Show quoted text
> "ist" => +5*3600+1800,# Indian Standard
Regards,
Cathrin Callas