Skip to main content

Function: instant()

instant(value): Instant

Defined in: time/instant.ts:35

The Instant an absolute value names. instant() resolves no zone, so it takes only values that already name a moment: a Date, epoch milliseconds, or a string carrying Z or a numeric offset. A wall-clock reading with no zone is not one of them — read that through the dataset's zone instead, which every Dataset write already does.

Every refusal is an InvalidInstantError carrying the value the consumer wrote, in the same vocabulary toInstant uses (instant-fault.ts). It used to be a bare RangeError that named a zone problem for every input it did not like, including null — which is the one thing a missing date is not (#431). It also used to answer NaN rather than refuse, for new Date('nope'), for Number.NaN, and for any unparsable string ending in Z: a NaN Instant flows on and surfaces much later as an unpainted bar, with nothing left pointing at the value that caused it.

Parameters​

value​

string | number | Date

Returns​

Instant