Lyric v3.1.0

std.time

Duration struct

pub struct Duration

A distance between two instants, in whole milliseconds. May be negative: a.since(b) with b later than a says so rather than hiding it.

millis: int

The distance in milliseconds; the sign is the direction.

pub static fn ofMillis(value: int): Duration

A duration of whole milliseconds.

pub static fn ofSeconds(value: int): Duration

A duration of whole seconds.

pub static fn ofMinutes(value: int): Duration

A duration of whole minutes.

pub fn totalMillis(): int

The whole distance in milliseconds.

pub fn totalSeconds(): int

The whole distance in seconds, truncated towards zero.

pub fn plus(other: Duration): Duration

The two added.

pub fn minus(other: Duration): Duration

The other subtracted from this one.

stdlib/std/time.lyr:25

Instant struct

pub struct Instant

A point on the wall clock: milliseconds since 1970-01-01 UTC.

millis: int

Milliseconds since the epoch; negative is before 1970.

pub static fn now(): Instant

The wall clock, now.

pub static fn ofEpochMillis(value: int): Instant

The instant at these epoch milliseconds — for stored timestamps and for tests, which want a clock that stands still.

pub fn epochMillis(): int

Milliseconds since the epoch — the raw number back, for storing.

pub fn since(earlier: Instant): Duration

The distance from earlier to this instant. Negative when earlier is actually later.

pub fn plus(d: Duration): Instant

This instant moved by a duration; a negative one moves backwards.

pub fn iso(): string

ISO 8601 in UTC, millisecond precision: 1970-01-01T00:00:00.000Z.

divFloor/modFloor rather than / and %, so an instant BEFORE the epoch lands in the right day — truncation would round the day towards 1970 and hand the rest a negative time.

stdlib/std/time.lyr:66