Skip to content

Std.Instant

opaque type Instant

A point in time. The current one is returned by Clock.now.

fn from_unix_milliseconds(ms: Int64) -> Instant

Negative values are before the epoch.

fn to_unix_milliseconds(t: Instant) -> Int64

Milliseconds since the Unix epoch. Negative before the epoch.

fn add(t: Instant, d: Duration) -> Instant

Earlier if d is negative.

fn subtract(t: Instant, d: Duration) -> Instant

d earlier. Later if d is negative.

fn since(t: Instant, earlier: Instant) -> Duration

The duration from earlier to t; negative if earlier is later. Reads as now.since(start).

fn to_string(t: Instant) -> String

The date and time in UTC (2026-10-12T03:04:05.678Z), an RFC 3339 date-time for years 0 to 9999. Other years are written with a sign and at least six digits (+010000, -000001), the expanded year of ISO 8601. The format is in spec [api.std.instant].

fn parse(s: String) -> Instant fails ParseError

The point in time written in s: a date and time with an offset from UTC, in the form that to_string writes, the date-time of RFC 3339, and a few more (2025-10-12 12:04:05.678+09). The offset is required. Fails with ParseError(input: s) otherwise. The grammar is in spec [api.std.instant].