Skip to content

Commit

Permalink
Dates are implemented in the non-standard way of starting from 1904 i…
Browse files Browse the repository at this point in the history
…nstead 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 ([email protected]) for unsticking my brain and providing a rough conversion routine.
  • Loading branch information
cyeh%netscape.com committed Sep 1, 1998
1 parent 54f8700 commit d53e84f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions config/mac-set-timebomb.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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) = @_;

Expand All @@ -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 ([email protected])

$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);
Expand Down

0 comments on commit d53e84f

Please sign in to comment.