struct Instant
pub struct Instant :: [Equatable, Ordered, TotalOrder, Hashable, Add<Duration>, Display, Parse]
Conforms to Equatable, Ordered, TotalOrder, Hashable, Add<Duration>, Display, Parse.
A moment on the wall clock, in nanoseconds since 1970-01-01T00:00:00Z — POSIX time, no leap
seconds counted: the years 1677 to 2262. Two compare and order as the moments they are.
Its text is RFC 3339 in UTC, 2026-10-08T12:34:56.5Z, the fraction without trailing zeros.
Methods
pub static fn now(): Instant
Returns the current moment on the system's wall clock, which the system may set back; to
measure how long something took, use Monotonic.
pub static fn ofEpochMillis(n: int): Instant
Returns the moment n milliseconds after the epoch, before it for a negative n: the
inverse of epochMillis, which rounds down, so what is finer than a millisecond does not
come back.
Panics
Panics where an instant cannot hold the moment, outside the years 1677 to 2262.
pub fn epochSecs(): int
Returns the whole seconds since the epoch, rounded down (a moment before 1970 gives a negative count).
pub fn epochMillis(): int
Returns the whole milliseconds since the epoch, rounded down.
pub fn add(d: Duration): Instant
Returns the moment d later — earlier for a negative d.
pub fn since(earlier: Instant): Duration
Returns how long after earlier this moment is — negative where it is before.
pub fn toDateTime(zone: Zone): DateTime
Returns the date, the time of day and the offset of this moment in zone.
pub fn show(): string
Returns the moment as RFC 3339 text in UTC.
pub static fn parse(s: StringView): Instant throws ParseError
Parses an RFC 3339 date-time at any offset and returns the moment it names.
Errors
Throws ParseError as DateTime.parse does.
Panics
Panics with an overflow (RT0002) for a date-time outside the years an Instant reaches.