summaryrefslogtreecommitdiff
path: root/lib/Time/Local.pm
diff options
context:
space:
mode:
authorMathias Koerber <mathias@dnssec1.singnet.com.sg>1997-08-07 00:00:00 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commit9bb8015a4914839fa5051d366d06f5db5176a8c9 (patch)
tree0f570f339484a781f3ae7a29acb06b8373fb7b3d /lib/Time/Local.pm
parentd704f39a0db2dc23790dfd9d7bd59ce9928a6e2c (diff)
downloadperl-9bb8015a4914839fa5051d366d06f5db5176a8c9.tar.gz
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
Diffstat (limited to 'lib/Time/Local.pm')
-rw-r--r--lib/Time/Local.pm34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/Time/Local.pm b/lib/Time/Local.pm
index 0119f9ddb8..8d3e49a4a1 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];