summaryrefslogtreecommitdiff
path: root/lib/Time
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2003-01-01 21:43:24 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-01-16 20:40:58 +0000
commit13ef5feb3a8e2368992adc7df8455949512b60b3 (patch)
tree8fca53a5702768fef4c5a8699f352480504bf766 /lib/Time
parent88632417a970dff8f92718b0800b1aa1400cb4ae (diff)
downloadperl-13ef5feb3a8e2368992adc7df8455949512b60b3.tar.gz
Re: [perl #19393] Bug in Time::localtime?
Message-ID: <20030101214324.F12907@fdgroup.com> (integrated from change #18397 in maint-5.8) p4raw-link: @18397 on //depot/maint-5.8/perl: 7bc6bea4535085425366718a732073dd9f13e3fc p4raw-id: //depot/perl@18497 p4raw-integrated: from //depot/maint-5.8/perl@18496 'copy in' lib/Time/Local.pm lib/Time/Local.t (@17645..)
Diffstat (limited to 'lib/Time')
-rw-r--r--lib/Time/Local.pm13
-rwxr-xr-xlib/Time/Local.t16
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/Time/Local.pm b/lib/Time/Local.pm
index faef1d7869..51553b5cd4 100644
--- a/lib/Time/Local.pm
+++ b/lib/Time/Local.pm
@@ -132,7 +132,18 @@ sub timelocal {
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;
}
diff --git a/lib/Time/Local.t b/lib/Time/Local.t
index a384b171fd..68952c99aa 100755
--- a/lib/Time/Local.t
+++ b/lib/Time/Local.t
@@ -28,7 +28,7 @@ use Time::Local;
# 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) {
@@ -93,6 +93,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";
package test;