From da88816efcd6d55fcc063c52a6e27ca5caea72f8 Mon Sep 17 00:00:00 2001 From: "cyeh%netscape.com" Date: Tue, 1 Sep 1998 20:41:45 +0000 Subject: [PATCH] Dates are implemented in the non-standard way of starting from 1904 instead of 1970. As a result, we must add back those lost years in order to get cross platform compatibility with other perl time implementations. Special thanks to Chris Nandor (pudge@pobox.com) for unsticking my brain and providing a rough conversion routine. --- config/mac-set-timebomb.pl | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/config/mac-set-timebomb.pl b/config/mac-set-timebomb.pl index 9d78085d176..9d19440ec41 100644 --- a/config/mac-set-timebomb.pl +++ b/config/mac-set-timebomb.pl @@ -94,6 +94,14 @@ sub set_indirected_bomb { set_pref($secret, $bomb); } +sub time_diff { + use Time::Local; + my($time, $result) = @_; + my $diff = 2082830400 - (timegm(localtime) - time); + return $result =~ /mac/ ? + $time + $diff : $time - $diff; +} + sub set_bomb { my ($warning_days, $bomb_days) = @_; @@ -105,16 +113,23 @@ sub set_bomb { "bomb_days ($bomb_days)\n") unless ($warning_days < $bomb_days); - my $now = time; + my $mactime = time; + + print $mactime . "\n"; # MacPerl stores date and times from 1904 instead of 1970 -# Let's do the timewarp again! +# Conversion routine thanks to Chris Nandor (pudge@pobox.com) - $now = $now + (66 * 365 * 24 * 60 * 60); + $now = time_diff($mactime, 'unix'); + + print $now . "\n"; my $bomb = $now + ($bomb_days * 24 * 60 * 60); my $warn = $now + ($warning_days * 24 * 60 * 60); + print $bomb . "\n"; + print $warn . "\n"; + set_pref("timebomb.expiration_time", $bomb); set_pref("timebomb.warning_time", $warn); set_pref("timebomb.relative_timebomb_days", -1);