Subject: | DateTime::Format::Strptime 1.0601 bug converting %s |
Date: | Fri, 2 Sep 2005 17:11:09 +0100 |
From: | "Don Simonetta" <DSimonetta [...] glasshouse.com> |
To: | <bug-datetime-format-strptime [...] rt.cpan.org> |
CC: | <datetime [...] perl.org> |
The following code snippet demonstrates a bug in version 1.0601. The problem is that the minutes & seconds are truncated to 0 when converting from epoch time. I have attached a patch for this.
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) = gmtime($iDt);
printf("Instead of GMT: %4d-%02d-%02d %02d:%02d:%02d \n",
$year+1900, $month+1, $mday, $hour, $min, $sec);
<<Strptime.pm>>
Message body is not shown because sender requested not to inline it.