Subject: | time2str gets timezone wrong for times in "fall back" hour |
perl 5.8.0
Red Hat Enterprise Linux AS release 3 (Taroon Update 3)
Running in the US Eastern timezone (in mid january 2006)
For datetimes within the one hour ambiguity zone (between 1am EDT and 1am EST on the
last Sunday in October), the timezone displayed by the %Z option is "MNT" instead of "EST".
Before and after this period it is correct ("EDT" and "EST" respectively). There is no such
problem with the "spring forward" time.
Sample code:
-------------------------
#!/usr/bin/perl -w
use strict;
use Date::Parse;
use Date::Format;
my @test_input = (
"04/03/05 5:00 GMT",
"04/03/05 6:00 GMT",
"04/03/05 6:59 GMT",
"04/03/05 7:00 GMT",
"04/03/05 7:01 GMT",
"04/03/05 7:59 GMT",
"04/03/05 8:00 GMT",
"04/03/05 8:01 GMT",
"10/30/05 4:00 GMT",
"10/30/05 5:00 GMT",
"10/30/05 5:59 GMT",
"10/30/05 6:00 GMT",
"10/30/05 6:01 GMT",
"10/30/05 6:59 GMT",
"10/30/05 7:00 GMT",
"10/30/05 7:01 GMT",
);
for my $datein (@test_input) {
my $tm = str2time($datein);
my $tmstr = time2str("%c %Z", $tm);
print "$datein\t$tmstr\n";
}
---------------------
output
---------------------
04/03/05 5:00 GMT 04/03/05 00:00:00 EST
04/03/05 6:00 GMT 04/03/05 01:00:00 EST
04/03/05 6:59 GMT 04/03/05 01:59:00 EST
04/03/05 7:00 GMT 04/03/05 03:00:00 EDT
04/03/05 7:01 GMT 04/03/05 03:01:00 EDT
04/03/05 7:59 GMT 04/03/05 03:59:00 EDT
04/03/05 8:00 GMT 04/03/05 04:00:00 EDT
04/03/05 8:01 GMT 04/03/05 04:01:00 EDT
10/30/05 4:00 GMT 10/30/05 00:00:00 EDT
10/30/05 5:00 GMT 10/30/05 01:00:00 EDT
10/30/05 5:59 GMT 10/30/05 01:59:00 EDT
10/30/05 6:00 GMT 10/30/05 01:00:00 MNT
10/30/05 6:01 GMT 10/30/05 01:01:00 MNT
10/30/05 6:59 GMT 10/30/05 01:59:00 MNT
10/30/05 7:00 GMT 10/30/05 02:00:00 EST
10/30/05 7:01 GMT 10/30/05 02:01:00 EST