Change 18497 by rgs@rgs-home on 2003/01/16 20:40:58
Subject: [PATCH] Re: [perl #19393] Bug in Time::localtime?
From: Dave Mitchell <[EMAIL PROTECTED]>
Date: Wed, 1 Jan 2003 21:43:24 +0000
Message-ID: <[EMAIL PROTECTED]>
(integrated from change #18397 in maint-5.8)
Affected files ...
... //depot/perl/lib/Time/Local.pm#27 integrate
... //depot/perl/lib/Time/Local.t#5 integrate
Differences ...
==== //depot/perl/lib/Time/Local.pm#27 (text) ====
Index: perl/lib/Time/Local.pm
--- perl/lib/Time/Local.pm#26~16204~ Fri Apr 26 15:33:45 2002
+++ perl/lib/Time/Local.pm Thu Jan 16 12:40:58 2003
@@ -132,7 +132,18 @@
or return $loc_t;
# Adjust for DST change
- $loc_t + $dst_off;
+ $loc_t += $dst_off;
+
+ # for a negative offset from GMT, and if the original date
+ # was a non-extent gap in a forward DST jump, we should
+ # now have the wrong answer - undo the DST adjust;
+
+ return $loc_t if $zone_off <= 0;
+
+ my ($s,$m,$h) = localtime($loc_t);
+ $loc_t -= $dst_off if $s != $_[0] || $m != $_[1] || $h != $_[2];
+
+ $loc_t;
}
==== //depot/perl/lib/Time/Local.t#5 (xtext) ====
Index: perl/lib/Time/Local.t
--- perl/lib/Time/Local.t#4~14342~ Sat Jan 19 08:08:19 2002
+++ perl/lib/Time/Local.t Thu Jan 16 12:40:58 2003
@@ -28,7 +28,7 @@
# use vmsish 'time' makes for oddness around the Unix epoch
if ($^O eq 'VMS') { $time[0][2]++ }
-print "1..", @time * 2 + 5, "\n";
+print "1..", @time * 2 + 6, "\n";
$count = 1;
for (@time) {
@@ -92,6 +92,20 @@
timegm(0,0,0, 1, 2, 80) - timegm(0,0,0, 1, 0, 80) == 60 * 24 * 3600
or print "not ";
print "ok ", $count++, "\n";
+
+# bugid #19393
+# At a DST transition, the clock skips forward, eg from 01:59:59 to
+# 03:00:00. In this case, 02:00:00 is an invalid time, and should be
+# treated like 03:00:00 rather than 01:00:00 - negative zone offsets used
+# to do the latter
+
+{
+ my $hour = (localtime(timelocal(0, 0, 2, 7, 3, 102)))[2];
+ # testers in US/Pacific should get 3,
+ # other testers should get 2
+ print "not " unless $hour == 2 || $hour == 3;
+ print "ok ", $main::count++, "\n";
+}
#print "Testing timelocal.pl module too...\n";
End of Patch.