Skip to content

Instantly share code, notes, and snippets.

@sethhall
Last active December 9, 2020 03:46
Show Gist options
  • Save sethhall/b23ebe5e73c9585fbbdff3628f53b6ae to your computer and use it in GitHub Desktop.
Save sethhall/b23ebe5e73c9585fbbdff3628f53b6ae to your computer and use it in GitHub Desktop.
A "next interval" function from Justin Azoff
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);
@duffy-ocraven
Copy link

Don't forget: "now what people are looking for is"
schedule next_interval(1 hr) { do_that_thing_once_an_hour() };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment