Time
Source: std/time.mw.
Clocks, sleeping and calendar conversion (proleptic Gregorian, UTC).
DateTime
Section titled “DateTime”struct DateTime { year: i64; month: i64; // 1..12 day: i64; // 1..31 hour: i64; minute: i64; second: i64; weekday: i64; // 0 = Sunday yday: i64; // 0-based day of the year}Functions
Section titled “Functions”time_now_ns
Section titled “time_now_ns”fn time_now_ns() -> i64Nanoseconds since 1970-01-01 00:00:00 UTC (negative on error).
time_mono_ns
Section titled “time_mono_ns”fn time_mono_ns() -> i64Nanoseconds from an arbitrary starting point; never goes backwards.
time_unix
Section titled “time_unix”fn time_unix() -> i64sleep_ns
Section titled “sleep_ns”fn sleep_ns(ns: i64)sleep_ms
Section titled “sleep_ms”fn sleep_ms(ms: i64)is_leap_year
Section titled “is_leap_year”fn is_leap_year(y: i64) -> booldays_in_month
Section titled “days_in_month”fn days_in_month(y: i64, m: i64) -> i64days_from_civil
Section titled “days_from_civil”fn days_from_civil(y: i64, m: i64, d: i64) -> i64Days since 1970-01-01 for a civil date (Howard Hinnant’s algorithm).
datetime_from_unix
Section titled “datetime_from_unix”fn datetime_from_unix(t: i64) -> DateTimeSeconds since the epoch -> broken-down UTC time.
datetime_to_unix
Section titled “datetime_to_unix”fn datetime_to_unix(dt: DateTime) -> i64time_pad2
Section titled “time_pad2”fn time_pad2(buf: *u8, n: i64)datetime_format_iso
Section titled “datetime_format_iso”fn datetime_format_iso(buf: *u8, dt: DateTime) -> i64“YYYY-MM-DDTHH:MM:SSZ” (20 bytes, no terminator) -> returns 20.