From: Ian Goodacre Date: Wed, 25 Mar 2009 13:39:11 +0000 (-0500) Subject: [perl #63914] Time::Piece reports timezone incorrectly X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=036055ae9ae83cd5b00514419663540cb13fc21a;p=p5sagit%2Fp5-mst-13.2.git [perl #63914] Time::Piece reports timezone incorrectly --- diff --git a/ext/Time-Piece/Piece.xs b/ext/Time-Piece/Piece.xs index e20b6d4..e65f20c 100644 --- a/ext/Time-Piece/Piece.xs +++ b/ext/Time-Piece/Piece.xs @@ -23,7 +23,7 @@ extern "C" { * support is added and NETaa14816 is considered in full. * It does not address tzname aspects of NETaa14816. */ -#if !defined(HAS_GNULIBC) +#if defined(HAS_GNULIBC) # ifndef STRUCT_TM_HASZONE # define STRUCT_TM_HASZONE # else diff --git a/ext/Time-Piece/t/02core.t b/ext/Time-Piece/t/02core.t index d020558..fb43038 100644 --- a/ext/Time-Piece/t/02core.t +++ b/ext/Time-Piece/t/02core.t @@ -1,4 +1,4 @@ -use Test::More tests => 93; +use Test::More tests => 95; my $is_win32 = ($^O =~ /Win32/); my $is_qnx = ($^O eq 'qnx'); @@ -47,6 +47,13 @@ cmp_ok($t->datetime, 'eq','2000-02-29T12:34:56'); cmp_ok($t->daylight_savings, '==', 0); # ->tzoffset? +{ + local $ENV{TZ} = "EST"; + my $lt = localtime; + cmp_ok(scalar($lt->tzoffset), 'eq', '-18000'); + cmp_ok($lt->strftime("%z"), 'eq', '-0500'); +} + cmp_ok(($t->julian_day / 2451604.0243 ) - 1, '<', 0.001); cmp_ok(($t->mjd / 51603.52426) - 1, '<', 0.001); cmp_ok($t->week, '==', 9);