Skip to content

Commit

Permalink
Deal with dates far in the future.
Browse files Browse the repository at this point in the history
  • Loading branch information
testcodespaceerfer committed Sep 13, 2023
1 parent 58eacef commit 6112799
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/tink/state/ObservableDate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,17 @@ class ObservableDate implements ObservableObject<Bool> {
if (passed) PASSED;
else {
var state = new State(false);
haxe.Timer.delay(() -> state.set(true), Std.int(stamp - now));
function schedule() {
if (now == null) now = Date.now().getTime();
switch Std.int(now - stamp) {
case _ < 0 => true: // overflow
now = null;
haxe.Timer.delay(schedule, 1 << 30);
case v:
haxe.Timer.delay(() -> state.set(true), v);
}
}
schedule();
state;
}
}
Expand Down

0 comments on commit 6112799

Please sign in to comment.