time module

Time primitives — millisecond and nanosecond clocks, calendar component conversions, duration math, and ISO 8601 formatting.

Time is represented as milliseconds since the Unix epoch.

import "time" as time;

var now = time.now();
print(time.iso(now));                    // 2026-05-11T14:30:00.000Z
print(time.components(now, false));      // { year, month, day, hour, ... }

Clocks

FunctionDescription
time.now() → numberCurrent time, milliseconds since epoch.
time.now_seconds() → numberSame as now() / 1000.
time.now_ns() → numberHigh-resolution monotonic nanosecond counter.

Calendar conversion

FunctionDescription
time.components(ms, local) → map{year, month, day, hour, minute, second, ms, weekday, yearday}. local selects local vs. UTC.
time.from(parts, local) → numberInverse of components.
time.local_offset_ms(ms) → numberLocal timezone offset from UTC at that instant.

Duration helpers (durations are plain numbers in ms)

FunctionDescription
time.seconds(n), time.minutes(n), time.hours(n), time.days(n)Convert a count to milliseconds.
time.add_seconds(ms, n), add_minutes, add_hours, add_daysShift an instant by a duration.

ISO 8601

FunctionDescription
time.iso(ms) → stringUTC, 2026-05-11T14:30:00.000Z.
time.iso_local(ms) → stringLocal with offset, 2026-05-11T20:30:00.000+06:00.
time.parse_iso(s) → numberParse an ISO 8601 string back to a timestamp.