Subject: | gmtime/localtime on Time::Piece objects |
Hi,
I have just started using Time::Piece and stumbled over unexpected
behavior of the localtime / gmtime methods:
1. $oo->style invocation does not work on the Time::Piece object, but
does just return the current time, not the time stored in the object.
haggis:~$ perl -e 'use Time::Piece; $t =
Time::Piece->strptime("2011-02-22-12:30:00_GMT", "%Y-%m-%d-%T_%Z");
print $t->localtime->strftime."\n"; print $t->gmtime->strftime."\n";'
Wed, 23 Feb 2011 11:39:11 CET
Wed, 23 Feb 2011 10:39:11 UTC
2. function(style) invocation works on the Time::Piece object, but it
does not get the time zone conversion right:
haggis:~$ perl -e 'use Time::Piece; $t =
Time::Piece->strptime("2011-02-22-12:30:00_GMT", "%Y-%m-%d-%T_%Z");
print localtime($t)->strftime."\n"; print gmtime($t)->strftime."\n";'
Tue, 22 Feb 2011 12:30:00 CET
Tue, 22 Feb 2011 12:30:00 UTC
Taking a de-tour via epoch gives the expected result:
haggis:~$ perl -e 'use Time::Piece; $t =
Time::Piece->strptime("2011-02-22-12:30:00_GMT", "%Y-%m-%d-%T_%Z");
print localtime($t->epoch)->strftime."\n"; print
gmtime($t->epoch)->strftime."\n";'
Tue, 22 Feb 2011 13:30:00 CET
Tue, 22 Feb 2011 12:30:00 UTC
Thank you for this module!
Nils