New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in Time::localtime? #6183
Comments
From j.pritchard@eso.orgThis is a bug report for perl from j.pritchard@eso.org, The following script: <--Start--> use Time::Local; my $dateda=timelocal(0,0,0,12,9,2002); <--End--> produces the following output... timelocal(0,0,0,12,9,2002) ==> 2002-09-12 Am I doing something wrong or is there a problem here? Thanks in advance... Flags: Site configuration information for perl v5.8.0: Configured by bhcompile at Sun Sep 1 23:55:07 EDT 2002. Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Locally applied patches: @INC for perl v5.8.0: Environment for perl v5.8.0: |
From @andk
> # New Ticket Created by j.pritchard@eso.org > This is a bug report for perl from j.pritchard@eso.org, > ----------------------------------------------------------------- > <--Start--> > use Time::Local; > my $dateda=timelocal(0,0,0,12,9,2002); > <--End--> > produces the following output... > timelocal(0,0,0,12,9,2002) ==> 2002-09-12 FWIW, I cannot reproduce this here, I get timelocal(0,0,0,12,9,2002) ==> 2002-09-12 Maybe it's time-zone or daylight-saving-time dependent? -- |
From j.pritchard@eso.org"Andreas Koenig (via RT)" wrote:
Seems you are right... encue: ~/tmp> setenv TZ Chile/Continental So does this make it a bug or a feature??? John -- + -- John Pritchard (2p2 Team, La Silla Observatory) |
From @iabynOn Thu, Dec 26, 2002 at 05:21:14PM -0300, John Pritchard wrote:
It's just the transition to DST - there are two hours that map to the same The following script: use Time::Local; for my $day (12..13) { outputs: [davem@percy davem]$ TZ=Chile/Continental perl5.8.0 /tmp/p -- |
From j.pritchard@eso.org"Dave Mitchell (via RT)" wrote:
Ahhhh, many thanks for the clarification and solution. Best regards -- + -- John Pritchard (Science Operations, La Silla Observatory) |
From @jhiI'm marking the problem ticket as resolved. |
@jhi - Status changed from 'new' to 'resolved' |
From perl5-porters@ton.iguana.beIn article <20021227215004.A28503@_dgroup.com>,
Well, not exactly: TZ=Chile/Continental perl -wle 'print join" ",localtime(1034477999)' So time actually skips 0:00 to 1:00, and there is no 0:00 really. So I'd call this a bug: It should be either an error or 1034481600 PS for the original poster: |
From @iabynOn Mon, Dec 30, 2002 at 09:58:51PM +0000, Ton Hospel wrote:
[ snip]
D'oh - I got confused by Chile's clocks going fowards in the autumn, So yes, its a bug. -- Inline Patch--- lib/Time/Local.pm- Wed Jan 1 21:24:34 2003
+++ lib/Time/Local.pm Wed Jan 1 22:29:54 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;
}
--- lib/Time/Local.t- Wed Jan 1 21:24:45 2003
+++ lib/Time/Local.t Wed Jan 1 22:47:17 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) {
@@ -93,6 +93,20 @@
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; |
From @jhiI think bug found, and patched, so I'm marking the problem ticket |
@jhi - Status changed from 'open' to 'resolved' |
From @iabynclosing (for 3rd time), since bug is fixed |
@iabyn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#19393 (status was 'resolved')
Searchable as RT19393$
The text was updated successfully, but these errors were encountered: