time
Spans and clocks. Duration measures a length of time, Instant reads the monotonic clock, SystemTime reads the wall clock, and DateTime breaks a timestamp into UTC calendar parts.
All four types are POD — copied by value, nothing to drop. Every difference saturates at zero rather than wrapping. A plain import std::time; brings in the whole module.
public module time::duration;
public module time::clock;
public module time::datetime;
| File | What it holds | Import |
|---|---|---|
duration | Duration | import std::time::duration; |
clock | Instant, SystemTime, sleep | import std::time::clock; |
datetime | DateTime | import std::time::datetime; |
public function name() { ... }
public:Visible to any module that imports this one - the default for top-level items and for struct fields, so it is mostly written to be explicit. public: opens a visibility block that groups the members after it.
public module collections::array;In a directory's _module.cryo aggregator, lists a submodule and whether it is public. Importing the directory's namespace sees only the modules declared public here.
type struct Duration {
secs: u64;
nanos: u32;
}A length of time: whole secs plus a sub-second nanos remainder (0 <= nanos < 1_000_000_000). POD; copy-by-value, no drop.
type struct Instant {
secs: i64;
nanos: i64;
}A measurement of the monotonic clock. Opaque: the fields are the raw timespec, meaningful only relative to another Instant. POD.
type struct SystemTime {
secs: i64;
nanos: i64;
}A measurement of the wall clock (CLOCK_REALTIME) as a raw timespec. duration_since_epoch() yields a Unix timestamp. Subject to NTP steps and manual changes; do not use for elapsed-time measurement. POD.
type struct DateTime {
year: i64;
month: u32;
day: u32;
hour: u32;
minute: u32;
second: u32;
}A UTC civil calendar reading. All fields are UTC and already normalized: month in 1..=12, day in 1..=31, hour in 0..=23, minute/second in 0..=59. year is the proleptic Gregorian year and may be negative for timestamps far before the Common Era. POD.
import a::b;
import a::b::{ X, Y };
import a::b as c;
import a::b::*;Brings a module, or selected items from it, into scope. One path per declaration: use the brace form for several items, as to alias, and * for everything public (prefer the brace form; wildcards invite name collisions).