Skip to main content

Module time

Module time 

Source
Expand description

Time, duration, and UTC date/time helpers.

Structs§

CivilDate
A proleptic Gregorian calendar date.
CivilDateTime
A UTC civil date and wall-clock time with whole-second precision.
FixedClock
Deterministic clock for tests and reproducible harnesses.
SystemClock
System-backed clock.

Traits§

Clock
Clock used for wall-clock timestamps and monotonic elapsed durations.

Functions§

civil_from_days
Converts a count of days since the Unix epoch to a civil date.
datetime_from_epoch_secs
Converts Unix epoch seconds to a UTC civil date/time.
days_from_civil
Converts a valid civil date to its day offset from the Unix epoch.
days_in_month
Returns the number of days in month for year, or None for invalid months.
elapsed_millis
Returns the non-negative elapsed milliseconds between two monotonic millisecond readings.
epoch_secs_from_datetime
Converts a valid UTC civil date/time to Unix epoch seconds.
format_compact_utc
Formats a Unix timestamp (whole seconds) as compact UTC YYYYMMDD-HHMMSS.
format_duration
Formats a Duration into a human-readable string.
format_rfc3339
Formats a Unix timestamp (whole seconds) as a UTC RFC 3339 string (YYYY-MM-DDTHH:MM:SSZ).
format_rfc3339_datetime
Formats a valid UTC civil date/time as YYYY-MM-DDTHH:MM:SSZ.
is_leap_year
Returns true when year is a leap year in the proleptic Gregorian calendar.
now_epoch_secs
Returns the current Unix epoch time in whole seconds, or None if the system clock is set before the Unix epoch or exceeds i64.
now_rfc3339
Returns the current wall-clock time as a UTC RFC 3339 string, or None if the system clock is set before the Unix epoch or exceeds i64.
now_utc
Returns the current UTC civil date/time, or None if the system clock is set before the Unix epoch or exceeds i64.
parse_duration
Parses simple duration strings like "5s", "10m", "1h" into a Duration. Case-insensitive, supports optional space, and treats unit-less values as seconds.
parse_rfc3339_utc
Parses a canonical UTC RFC 3339 timestamp into Unix epoch seconds.
parse_rfc3339_utc_datetime
Parses a canonical UTC RFC 3339 timestamp into a UTC civil date/time.
system_clock
Return a shared system-backed clock.
time_it
Runs a synchronous function and returns a tuple containing its return value and the exact execution time.

Type Aliases§

SharedClock
Shared clock handle.