Last active
December 9, 2020 03:46
-
-
Save sethhall/b23ebe5e73c9585fbbdff3628f53b6ae to your computer and use it in GitHub Desktop.
A "next interval" function from Justin Azoff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function next_interval(i: interval): interval | |
{ | |
local now = current_time(); | |
local ii = double_to_count(interval_to_double(i)); | |
local sofar = double_to_count(time_to_double(now)) % ii; | |
local togo = ii - sofar; | |
local dur = double_to_interval(togo); | |
return dur; | |
} | |
print next_interval(60 mins); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't forget: "now what people are looking for is"
schedule next_interval(1 hr) { do_that_thing_once_an_hour() };