std/instant
Import with import std/instant.
Exports
Section titled “Exports”Types
type Instant
Section titled “type Instant”type Instant Int
opaque — construction surface is private to its defining module
Opaque absolute point in time. Backed by Unix epoch nanoseconds.
Use Instant.to_seconds / Instant.from_seconds for the raw
seconds-grained representation (sufficient for whole-second
timestamps); Instant.add / Instant.between / Instant.before?
for the opaque-typed arithmetic.
Instant.now
Section titled “Instant.now”fn now(): Instant
type function on Instant
Read the current wall clock as an Instant. Single canonical
“current time” function — there is no Int-returning variant.
Use Instant.to_seconds(Instant.now()) if you need a
seconds-grained representation.
Instant.from_seconds
Section titled “Instant.from_seconds”fn from_seconds(n: Int): Instant
type function on Instant
Construct an Instant from whole seconds since the Unix epoch.
Instant.to_seconds
Section titled “Instant.to_seconds”fn to_seconds(Instant(nanos)): Int
type function on Instant
Extract whole seconds since the Unix epoch from an Instant. Inverse
of Instant.from_seconds; sub-second precision is truncated.
Instant.between
Section titled “Instant.between”fn between(Instant(earlier), Instant(later)): Duration
type function on Instant
The Duration between two Instants (later minus earlier).
Instant.before?
Section titled “Instant.before?”fn before?(Instant(a), Instant(b)): Bool
type function on Instant
Compare: is a strictly before b?
Instant.add
Section titled “Instant.add”impl Add
fn add(Instant(nanos), rhs: Duration): Instant
impl Add.add
Add a Duration to an Instant, returning a new Instant.
Instant.inspect
Section titled “Instant.inspect”impl Debug
fn inspect(value: Instant): String
impl Debug.inspect