lamina.time documentation

advance

fn

[_]

Advances to the next task. Returns false if there are no remaining tasks.

advance-until

fn

[_ timestamp]

Advances across all tasks that occur before or on the given timestamp.

days

fn

[n]

Converts days -> milliseconds

format-duration

fn

[n]

Returns a formatted string describing an interval, i.e. '5d 3h 1m'

hours

fn

[n]

Converts hours -> milliseconds

hz

fn

[n]

Converts frequency -> period in milliseconds

invoke-at

fn

[timestamp f]
[task-queue timestamp f]

Delays invocation of a function until timestamp.

invoke-in

fn

[delay f]
[task-queue delay f]

Delays invocation of a function by delay milliseconds.

invoke-lazily

fn

[f]
[task-queue f]

Provides a function that will be invoked whenever the task-queue begins processing events.

invoke-repeatedly

fn

[period f]
[task-queue period f]

Repeatedly invokes a function every period milliseconds, but ensures that the function cannot overlap its own invocation if it takes more than the period to complete.

The function will be given a single parameter, which is a callback that can be invoked to cancel future invocations.

microseconds

fn

[n]

Converts microseconds -> milliseconds

milliseconds

fn

[n]

Converts milliseconds -> milliseconds

minutes

fn

[n]

Converts minutes -> milliseconds

nanoseconds

fn

[n]

Converts nanoseconds -> milliseconds

non-realtime-task-queue

fn

[]
[start-time discard-past-events?]

A task queue which can be used to schedule timed or periodic tasks at something other than realtime.

now

fn

[]
[clock]

Returns the current time, in milliseconds since the epoch.

period

fn

[]

Returns the current default period for recurring actions.

seconds

fn

[n]

Converts seconds -> milliseconds

task-queue

fn

[]

Returns the current task queue. Defaults to a real-time task queue.

with-period

macro

[period & body]

Sets the default period within the inner context.

with-task-queue

macro

[q & body]

Executes the body within a context where q is the task-queue.