std.time
Time: the current date and time in UTC, measuring durations, and waiting.
import std.time
print(time.now().iso()) // 2026-10-15T08:30:01.123Z
let start: i64 = time.millis()
time.sleep(250)
print(time.millis() - start) // about 250Types
struct Time
pub struct Time {
pub unix_millis: i64,
}A moment, as milliseconds since 1970-01-01T00:00:00Z.
Methods
pub fn unix_seconds(self) -> i64pub fn add_millis(self, millis: i64) -> Timepub fn add_seconds(self, seconds: i64) -> Timepub fn parts(self) -> DateTimeThe year, month, day and so on, in UTC.
pub fn date(self) -> stringThe date, as in 2026-10-15.
pub fn iso(self) -> stringISO 8601 in UTC, with milliseconds: 2026-10-15T08:30:01.123Z.
pub fn http_date(self) -> stringThe format of HTTP headers: Thu, 15 Oct 2026 08:30:01 GMT.
struct DateTime
pub struct DateTime {
pub year: i64,
pub month: i64,
pub day: i64,
pub hour: i64,
pub minute: i64,
pub second: i64,
pub millisecond: i64,
pub weekday: i64,
}The parts of a moment in UTC.
month1 to 12.
day1 to 31.
weekday1 (Monday) to 7 (Sunday).
Functions
fn now
pub fn now() -> TimeThe current time, from the system clock.
fn from_unix_millis
pub fn from_unix_millis(millis: i64) -> Timefn from_unix_seconds
pub fn from_unix_seconds(seconds: i64) -> Timefn millis
pub fn millis() -> i64Milliseconds on a clock that only moves forward, for measuring how long something takes. Unlike now, it does not jump when the system clock is set.
fn sleep
pub fn sleep(millis: i64)Waits this many milliseconds.