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 durationa span of time
| Field | |
|---|---|
ns: i64 | nanoseconds |
Methods
attach fn as_nanos(this: std::time::duration&) -> i64the duration in nanoseconds
attach fn as_micros(this: std::time::duration&) -> i64the duration in whole microseconds
attach fn as_millis(this: std::time::duration&) -> i64the duration in whole milliseconds
attach fn as_secs(this: std::time::duration&) -> i64the duration in whole seconds
attach fn as_secs_f64(this: std::time::duration&) -> f64the duration in seconds, with the fraction
struct std::time::instant
struct instanta point on the monotonic clock: it never jumps back (the wall clock can), and only differences between instants mean anything
| Field | |
|---|---|
ns: i64 | nanoseconds since some fixed point (boot, usually) |
Methods
attach fn elapsed(this: std::time::instant&) -> std::time::durationhow long ago this was, on the monotonic clock
attach fn since(this: std::time::instant&, earlier: std::time::instant) -> std::time::durationthe time from earlier to this
struct std::time::timespec
struct timespecC'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) -> durationn nanoseconds
std::time::micros
fn micros(n: i64) -> durationn microseconds
std::time::millis
fn millis(n: i64) -> durationn milliseconds
std::time::secs
fn secs(n: i64) -> durationn seconds
std::time::now
fn now() -> instantnow, on the monotonic clock
std::time::unix_nanos
fn unix_nanos() -> i64the wall clock: nanoseconds since 1970-01-01 00:00 UTC
std::time::sleep
fn sleep(d: duration) -> voidwait 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