mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
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.
This commit is contained in:
parent
54f8700ba1
commit
d53e84fc21
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user