diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-04-26 22:33:45 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-04-26 22:33:45 +0000 |
commit | 67627c52ebaff7c8807f003541daf98ec69bc00b (patch) | |
tree | 75717d675de396d0a20c1a1e3ea84075515605c2 /lib/Time | |
parent | f55e507de7c660df4146d83969f0e0bed96e11d5 (diff) | |
download | perl-67627c52ebaff7c8807f003541daf98ec69bc00b.tar.gz |
Integrate changes #16199 and #16201 from macperl;
Time::Local compatibility patches, from Graham
MacPerl require() portability patches
p4raw-link: @16199 on //depot/macperl: 029195cc16ed49b9d6f99746bf12dad919bcab76
p4raw-id: //depot/perl@16204
p4raw-integrated: from //depot/macperl@16203 'copy in'
lib/Time/Local.pm (@16123..) 'merge in' pp_ctl.c (@16123..)
Diffstat (limited to 'lib/Time')
-rw-r--r-- | lib/Time/Local.pm | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/Time/Local.pm b/lib/Time/Local.pm index a8f2e490a3..faef1d7869 100644 --- a/lib/Time/Local.pm +++ b/lib/Time/Local.pm @@ -19,25 +19,36 @@ my $Breakpoint = ($ThisYear + 50) % 100; my $NextCentury = $ThisYear - $ThisYear % 100; $NextCentury += 100 if $Breakpoint < 50; my $Century = $NextCentury - 100; +my $SecOff = 0; my (%Options, %Cheat); +my $MaxInt = ((1<<(8 * $Config{intsize} - 2))-1)*2 + 1; +my $MaxDay = int(($MaxInt-43200)/86400)-1; + # Determine the EPOC day for this machine my $Epoc = 0; if ($^O eq 'vos') { # work around posix-977 -- VOS doesn't handle dates in # the range 1970-1980. $Epoc = _daygm((0, 0, 0, 1, 0, 70, 4, 0)); -} else { +} +elsif ($^O eq 'MacOS') { + no integer; + + $MaxDay *=2 if $^O eq 'MacOS'; # time_t unsigned ... quick hack? + # MacOS time() is seconds since 1 Jan 1904, localtime + # so we need to calculate an offset to apply later + $Epoc = 693901; + $SecOff = timelocal(localtime(0)) - timelocal(gmtime(0)); + $Epoc += _daygm(gmtime(0)); +} +else { $Epoc = _daygm(gmtime(0)); } %Cheat=(); # clear the cache as epoc has changed -my $MaxInt = ((1<<(8 * $Config{intsize} - 2))-1)*2 + 1; -my $MaxDay = int(($MaxInt-43200)/86400)-1; - - sub _daygm { $_[3] + ($Cheat{pack("ss",@_[4,5])} ||= do { my $month = ($_[4] + 10) % 12; @@ -48,7 +59,11 @@ sub _daygm { sub _timegm { - $_[0] + 60 * $_[1] + 3600 * $_[2] + 86400 * &_daygm; + my $sec = $SecOff + $_[0] + 60 * $_[1] + 3600 * $_[2]; + + no integer; + + $sec + 86400 * &_daygm; } @@ -86,7 +101,11 @@ sub timegm { croak "Cannot handle date ($sec, $min, $hour, $mday, $month, $year)"; } - $sec + 60*$min + 3600*$hour + 86400*$days; + $sec += $SecOff + 60*$min + 3600*$hour; + + no integer; + + $sec + 86400*$days; } @@ -97,6 +116,7 @@ sub timegm_nocheck { sub timelocal { + no integer; my $ref_t = &timegm; my $loc_t = _timegm(localtime($ref_t)); |