Subject: | bug in DateTime::Format::Strptime 1.0601 when using %s |
Date: | Mon, 14 Mar 2005 08:52:03 -0000 |
From: | "Don Simonetta" <DSimonetta [...] glasshouse.com> |
To: | <bug-datetime-format-strptime [...] rt.cpan.org> |
There is a bug in this module when dealing with seconds since epoch. The following piece of code, when run, illustrates the problem. It appears that the minutes & seconds of the final result are always set to 0.
use strict;
use DateTime::Format::Strptime;
my $iDt = time;
my $Strp = new DateTime::Format::Strptime(pattern => '%s');
my $dt = $Strp->parse_datetime($iDt);
print "converted $iDt to " .
DateTime::Format::Strptime::strftime("%Y-%m-%d %H:%M:%S", $dt) .
"\n";
my($sec,$min,$hour,$mday,$month,$year);
($sec,$min,$hour,$mday,$month,$year,undef) = localtime($iDt);
printf("Instead of %4d-%02d-%02d %02d:%02d:%02d \n",
$year+1900, $month+1, $mday, $hour, $min, $sec);