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

Total nanoseconds. Exact.

secs @ Float

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

Methods

(eq) other

Compares two durations.

(hash)()

Hashes the value.

(lt) other

Orders two durations.

(str)()

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