From: Mathias Koerber Date: Wed, 6 Aug 1997 12:00:00 +0000 (+1200) Subject: perl5.004 Time::Local still broken X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9bb8015a4914839fa5051d366d06f5db5176a8c9;p=p5sagit%2Fp5-mst-13.2.git perl5.004 Time::Local still broken lib/Time/Local.pm is still broken under the new perl5.004. In effect, when starting up it assumes that the tzsec variable can be filled with the *current* time difference between localtime and gmtime. However, there are timezones where this p5p-msgid: 199706260452.MAA22647@dnssec1.singnet.com.sg --- diff --git a/lib/Time/Local.pm b/lib/Time/Local.pm index 0119f9d..8d3e49a 100644 --- a/lib/Time/Local.pm +++ b/lib/Time/Local.pm @@ -48,11 +48,22 @@ BEGIN { $YearFix = ((gmtime(946684800))[5] == 100) ? 100 : 0; - my $t = time; - my @lt = localtime($t); - my @gt = gmtime($t); +} + +sub timegm { + $ym = pack(C2, @_[5,4]); + $cheat = $cheat{$ym} || &cheat; + return -1 if $cheat<0 and $^O ne 'VMS'; + $cheat + $_[0] * $SEC + $_[1] * $MIN + $_[2] * $HR + ($_[3]-1) * $DAY; +} + +sub timelocal { + my $t = &timegm; + + my (@lt) = localtime($t); + my (@gt) = gmtime($t); - $tzsec = ($gt[1] - $lt[1]) * $MIN + ($gt[2] - $lt[2]) * $HR; + my $tzsec = ($gt[1] - $lt[1]) * $MIN + ($gt[2] - $lt[2]) * $HR; my($lday,$gday) = ($lt[7],$gt[7]); if($lt[5] > $gt[5]) { @@ -65,18 +76,9 @@ BEGIN { $tzsec += ($gt[7] - $lt[7]) * $DAY; } - $tzsec += $HR if($lt[8]); -} - -sub timegm { - $ym = pack(C2, @_[5,4]); - $cheat = $cheat{$ym} || &cheat; - return -1 if $cheat<0 and $^O ne 'VMS'; - $cheat + $_[0] * $SEC + $_[1] * $MIN + $_[2] * $HR + ($_[3]-1) * $DAY; -} - -sub timelocal { - $time = &timegm + $tzsec; + $tzsec += $HR if($lt[8]); + + $time = $t + $tzsec; return -1 if $cheat<0 and $^O ne 'VMS'; @test = localtime($time); $time -= $HR if $test[2] != $_[2];