OxL Reference

module std.time

std.time — time, calendar and clocks (§17). Decisions D-3100..D-3119.

The builtin types live in std.core (the prelude): Duration (i64 ns), Time (UTC instant, i64 ns since the epoch), Instant (monotonic), Date (days since the epoch), LocalDateTime (wall clock without a zone, i64 ns), Tz (zone name) and Cron. This module adds the methods, TimeOfDay, ZonedTime, Period, schedules and timers. The public aliases make the types importable as use std.time { Duration } (D-810). Inside this module the private aliases Dur, Inst, Tm, Ldt are used so that the public aliases stay "unused" until a program uses them.

Calendar arithmetic, formatting, parsing, cron and the zone database are in the runtime (runtime/src/timelib), the zones come from the system tz database (D-3104). Patterns: yyyy yy MMMM MMM MM M dd d EEEE EEE HH H hh h a mm m ss s S.. XXX XX X z VV, text in single quotes (D-3103).

Example:

oxl✓ checked in CI
use std.time { Time }

fn main() io {
  let start = 2026-11-03T18:00
  let meeting = (start + 90m).in(tz"Europe/Berlin")!
  print("{meeting.toIso()} {(2026-01-31 + 1.month()).toIso()}")
}
Output
2026-11-03T19:30:00+01:00[Europe/Berlin] 2026-02-28

Types

enum AmbiguityWhich of two equal wall-clock times to take when clocks are set back (§17.2)
data AmbiguousTimeA local wall-clock time that occurs twice (clocks set back) and Ambiguity.Reject was requested (§17.2).
type CronA cron expression (the type is declared in the prelude; literal cron"0 9 MON-FRI").
type DateA calendar date (the type is declared in the prelude; literal 2026-11-03).
type Durtype alias · std.time
type DurationAn exact time interval in nanoseconds (the type is declared in the prelude; use std.time { Duration } imports it with its methods).
type i64type alias · std.time
type Insttype alias · std.time
type InstantA reading of the monotonic clock, for measuring intervals (the type is declared in the prelude).
type Ldttype alias · std.time
type LocalDateTimeA date and time without a time zone (the type is declared in the prelude; literal 2026-11-03T18:00).
enum MissedWhat every does with ticks missed because the body was slow (§17.4).
data PeriodCalendar interval (§17.1)
data ScheduleA cron expression bound to a zone (cron"0 9 MON-FRI".in(tz"Europe/Moscow")).
type TimeA UTC instant, nanoseconds since the Unix epoch (the type is declared in the prelude).
enum TimeFormatPredefined text formats of parse (§17.5); every parse also accepts a pattern string instead.
data TimeOfDayWall-clock time of day, 00:00:00 ..
type Tmtype alias · std.time
type TzAn IANA time zone (the type is declared in the prelude; literal tz"Europe/Moscow").
enum WeekdayDay of the week; Mon is the first.
data ZonedTimeAn instant with a time zone (§17.1).

Functions

afterRuns body once after d (§17.4).
atRuns body at every fire time of schedule until the task is cancelled (§17.4).
everyRuns body every d until the task is cancelled (§17.4).
nowCurrent UTC time (§17.3); same as the prelude now.
sleepSuspends the current task (§17.4); same as the prelude sleep.
todayToday's date in tz (default

See also