Subject: | Time zones and strptime |
Date: | Thu, 16 Feb 2012 12:16:49 +1030 |
To: | bug-Time-Piece [...] rt.cpan.org |
From: | j v <darnlotusblossom [...] gmail.com> |
Hello,
I think this bug might be related to #66079 ?
- <http://search.cpan.org/%7Emsergeant/Time-Piece-1.20/>Time-Piece-1.20
- perl -v : v5.8.8
- uname -a : SunOS box 5.10 Generic_141445-09 i86pc i386 i86pc
Time::Piece is an invaluable module, but I'm having trouble getting
strptime to keep the correct time zone. The following test:
use strict;
use warnings;
use Test::More tests => 2;
use Time::Piece;
my $time_str = '2012-02-02 00:00:00 +0000';
my $format_str = '%Y-%m-%d %H:%M:%S %z';
my $timepiece = Time::Piece->strptime( $time_str, $format_str );
# Fails - but only the %z portion differs
is( $timepiece->strftime($format_str), $time_str, '%z returns correct time
zone' );
is( $timepiece->strftime, 'Thu, 02 Feb 2012 00:00:00 UTC', 'Default
strftime returns correct time zone' );
... produces this output for me:
$> perl t/TimePiece.pm.t
1..2
not ok 1 - %z returns correct time zone
# Failed test '%z returns correct time zone'
# at t/TimePiece.pm.t line 11.
# got: '2012-02-02 00:00:00 +0930'
# expected: '2012-02-02 00:00:00 +0000'
ok 2 - Default strftime returns correct time zone
# Looks like you failed 1 test of 2.
Thank you for your efforts!
Cheers,
Jill Vogel