Subject: | Daylight Savings transition wrong for Europe/London |
During the ambiguous period when London is switching from BST back to
GMT, localtime returns the later of the two possible values, contrary
to the documented behavior.
Program to demonstrate:
use Time::Local;
$ENV{'TZ'} = ':Europe/London';
my @ambiguous_time = (0,0,1,31,9,110); # 1am on Oct 31 2010.
my $timegm = timegm(@ambiguous_time);
my $timelocal = $timegm - 3600; # Expected value for timelocal
print "timelocal = " . timelocal(@ambiguous_time) . " (should be
$timelocal)\n";
print "localtime($timegm) = " . localtime($timegm) . "\n";
print "localtime($timelocal) = " . localtime($timelocal) . "\n";
Output in 1.1901:
timelocal = 1288486800 (should be 1288483200)
localtime(1288486800) = Sun Oct 31 01:00:00 2010
localtime(1288483200) = Sun Oct 31 01:00:00 2010
This patch seems to fix it:
--- Time-Local-1.1901/lib/Time/Local.pm.orig 2008-11-02
03:55:50.000000000 +0000
+++ Time-Local-1.1901/lib/Time/Local.pm 2010-09-10
04:31:41.000000000 +0000
@@ -149,8 +149,7 @@
my $ref_t = &timegm;
my $loc_for_ref_t = _timegm( localtime($ref_t) );
- my $zone_off = $loc_for_ref_t - $ref_t
- or return $loc_for_ref_t;
+ my $zone_off = $loc_for_ref_t - $ref_t;
# Adjust for timezone
my $loc_t = $ref_t - $zone_off;