Skip Menu |

This queue is for tickets about the Time-Piece CPAN distribution.

Report information
The Basics
Id: 66079
Status: resolved
Priority: 0/
Queue: Time-Piece

People
Owner: Nobody in particular
Requestors: nils.goroll [...] uplex.de
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.20
Fixed in: (no value)



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
localtime and gmtime are not meant to be called as methods on these objects, but are instead constructor-helpers. I will look at improving either the documentation, implementation, or both, but don't hold your breath. (Given the long delay for this reply, if you were holding your breath, you won't read this advice anyway…) ;) -- rjbs
Thanks, documented in git repo. -- rjbs