Skip to content

Duration

A signed time span, with nanosecond precision.

There is no constructor. Durations come from subtracting two DateTimes or two Dates, and from APIs elsewhere that report elapsed time.

Durations do not support arithmetic: they cannot be added, subtracted, scaled or negated.

Fields

nanos @ Int [get]

Total nanoseconds. Exact.

secs @ Float [get]

Seconds. Approximate: long spans lose sub-second precision.

Methods

(eq) other -> Bool

Compares two durations.

Parameters

NameTypeDescription
other Value

(lt) other -> Bool

Orders two durations.

Parameters

NameTypeDescription
other Duration

(str)() -> Str

Returns a compact seconds form, such as 0s, 2.5s or -2.5s.