Skip to content
volt
GitHub

std::time

The monotonic clock (for measuring), the wall clock, sleeping, durations, and UTC dates in ISO 8601.

Source: std/time.volt

Types

struct std::time::duration

struct duration

a span of time

Field
ns: i64nanoseconds

Methods

attach fn as_nanos(this: std::time::duration&) -> i64

the duration in nanoseconds

attach fn as_micros(this: std::time::duration&) -> i64

the duration in whole microseconds

attach fn as_millis(this: std::time::duration&) -> i64

the duration in whole milliseconds

attach fn as_secs(this: std::time::duration&) -> i64

the duration in whole seconds

attach fn as_secs_f64(this: std::time::duration&) -> f64

the duration in seconds, with the fraction

struct std::time::instant

struct instant

a point on the monotonic clock: it never jumps back (the wall clock can), and only differences between instants mean anything

Field
ns: i64nanoseconds since some fixed point (boot, usually)

Methods

attach fn elapsed(this: std::time::instant&) -> std::time::duration

how long ago this was, on the monotonic clock

attach fn since(this: std::time::instant&, earlier: std::time::instant) -> std::time::duration

the time from earlier to this

struct std::time::timespec

struct timespec

C's struct timespec: seconds and nanoseconds, two 64-bit fields on 64-bit systems

Field
sec: i64
nsec: i64

Functions

std::time::nanos

fn nanos(n: i64) -> duration

n nanoseconds

std::time::micros

fn micros(n: i64) -> duration

n microseconds

std::time::millis

fn millis(n: i64) -> duration

n milliseconds

std::time::secs

fn secs(n: i64) -> duration

n seconds

std::time::now

fn now() -> instant

now, on the monotonic clock

std::time::unix_nanos

fn unix_nanos() -> i64

the wall clock: nanoseconds since 1970-01-01 00:00 UTC

std::time::sleep

fn sleep(d: duration) -> void

wait for at least d

std::time::utc_iso8601

<A: std::mem::allocator = std::mem::default_allocator> fn utc_iso8601(unix_ns: i64, allocator: A = {}) -> std::string<A>

a time on the wall clock (nanoseconds since 1970, as unix_nanos gives) as UTC ISO 8601: "2026-09-30T12:34:56Z", with ".789" milliseconds when there are any