zena:time

zena
import {…} from 'zena:time';

Classes

Instant

zena
final extension class Instant
Re-exported from zena:time/types.zena

A point on the monotonic clock: nanoseconds from an arbitrary origin, so only the distance between two instants is meaningful.

Methods
zena
minus(d: Duration): Instant
#

The instant d before this one. Named because - already means instant minus instant, and one operator gets one method.

zena
isBefore(other: Instant): boolean
#

True when this instant precedes other.

Operators
zena
operator -(other: Instant): Duration
#

The span from other to this instant — negative when this instant is the earlier one.

zena
operator +(d: Duration): Instant
#

The instant d after this one — before it, for a negative d.

zena
operator ==(other: Instant): boolean
#

Duration

zena
final extension class Duration
Re-exported from zena:time/types.zena

A signed span of time, in nanoseconds.

Methods
zena
isPositive(): boolean
#

True for a span longer than zero.

zena
isNegative(): boolean
#

True for a span shorter than zero.

Operators
zena
operator +(other: Duration): Duration
#
zena
operator -(other: Duration): Duration
#
zena
operator *(k: i64): Duration
#

This span scaled k times.

zena
operator ==(other: Duration): boolean
#

Functions

sleep

zena
function sleep(d: Duration): Future<void>

A future that completes after at least d.

monotonic

zena
function monotonic(): Instant

The monotonic clock's reading.

Reads the clock directly rather than through the installed Clock: only the parker path — sleep, park, wait — needs the installation, and a clock read should not pay a registration check.

milliseconds

zena
function milliseconds(ms: i64): Duration
Re-exported from zena:time/types.zena

ms milliseconds as a Duration.

nanoseconds

zena
function nanoseconds(ns: i64): Duration
Re-exported from zena:time/types.zena

ns nanoseconds as a Duration.