Subject: | Time::Piece 1.08: strptime and timezone bug? |
I faced the following problem with Time::Piece 1.08 module
(tp.pl is attached to this bug report):
$ env |grep TZ
TZ=JST-9
$ perl tp.pl
y Class::Date
time1: Wed, 12 Jan 2005 22:14:45 JST / 32400
time2: Wed, 12 Jan 2005 22:14:45 JST / 32400
delta: 0 hours (0 seconds)
By Time::Piece
time1: Wed, 12 Jan 2005 22:14:45 JST / 32400
time2: Wed, 12 Jan 2005 22:14:45 JST / 32400
delta: -9 hours (-32400 seconds)
#!/usr/bin/env perl
use Class::Date;
use Time::Piece;
print "By Class::Date\n";
my $cd_time1 = Class::Date::now;
my $cd_time2 = Class::Date::date($cd_time1->strftime('%Y%m%d%H%M%S'));
my $cd_delta = $cd_time1 - $cd_time2;
print "time1: ", $cd_time1->strftime, " / ", $cd_time1->tzoffset, "\n";
print "time2: ", $cd_time2->strftime, " / ", $cd_time2->tzoffset, "\n";
print "delta: ", $cd_delta->hour, ' hours (', $cd_delta->second, " seconds)\n";
print "\nBy Time::Piece\n";
my $tp_time1 = Time::Piece->new;
my $tp_time2 = Time::Piece->strptime($tp_time1->strftime('%Y%m%d%H%M%S'), '%Y%m%d%H%M%S');
my $tp_delta = $tp_time1 - $tp_time2;
print "time1: ", $tp_time1->strftime, " / ", $tp_time1->tzoffset, "\n";
print "time2: ", $tp_time2->strftime, " / ", $tp_time2->tzoffset, "\n";
print "delta: ", $tp_delta->hours, " hours (", $tp_delta->seconds, " seconds)\n";