Modules

std.time

Duration math plus target-gated monotonic and wall-clock helpers.

Status

Runnable today:

APIReturnNotes
std.time.ms(value)DurationBuilds a millisecond duration.
std.time.seconds(value)DurationBuilds a second duration.
std.time.add(a, b)DurationAdds two durations.
std.time.sub(a, b)DurationSubtracts one duration from another.
std.time.min(a, b)DurationReturns the smaller duration.
std.time.max(a, b)DurationReturns the larger duration.
std.time.asMsFloor(value)i32Converts to whole milliseconds.
std.time.lessThan(a, b)BoolCompares two durations.
std.time.monotonic()DurationReads a monotonic target clock where available.
std.time.wallSeconds()i64Reads target wall-clock seconds where available.

Current limits:

  • Monotonic instants.
  • Deadlines and request budgets.
  • Target-specific clock availability diagnostics.

Metadata labels:

  • effects: time
  • allocation behavior: no allocation
  • target support: duration math is target-neutral; clock reads require a time-capable target
  • error behavior: infallible helpers
  • ownership notes: no ownership transfer
  • example: examples/std-platform.0

Example

pub fun main(world: World) -> Void raises {    let a = std.time.ms(250)    let b = std.time.seconds(1)    let total = std.time.add(a, b)    if std.time.asMsFloor(total) == 1250 {        check world.out.write("duration ok\n")    }}

Design Notes

Time is an effect when it observes the outside world.

Pure duration math can stay allocation-free and target-independent.