zena:time
import {…} from 'zena:time';
Monotonic time measurement, durations, and timers.
Provides Instant for points in time, Duration for spans of time,
monotonic() for reading the system monotonic clock, and sleep(duration)
for asynchronous waiting.
Examples ​
import { monotonic, sleep, milliseconds } from 'zena:time';
let start = monotonic();
await sleep(milliseconds(50));
let elapsed = monotonic() - start;
Classes
Instant
final extension class Instant
A point on the monotonic clock: nanoseconds from an arbitrary origin, so only the distance between two instants is meaningful.
Duration
final extension class Duration
A signed span of time, in nanoseconds.
Functions
sleep
function sleep(d: Duration): Future<void>
A future that completes after at least d.
"At least": the deadline is when the timer becomes eligible, and it completes through the microtask queue like every other future, so a busy queue can delay it further. A zero-length sleep still yields — it never completes synchronously, per the always-async rule.
monotonic
function monotonic(): Instant
The monotonic clock's reading.
formatTimestamp
function formatTimestamp(epochNanos: i64): String
The UTC time epochNanos nanoseconds after the Unix epoch, as an
ISO 8601 / RFC 3339 timestamp with milliseconds:
2026-10-23T17:04:05.123Z. It counts days the proleptic Gregorian way,
with no leap seconds, as Unix time does. Times before the epoch are not
supported.
milliseconds
function milliseconds(ms: i64): Duration
ms milliseconds as a Duration.
nanoseconds
function nanoseconds(ns: i64): Duration
ns nanoseconds as a Duration.