Skip to content

@mostlyrightmd/core/dates

CalendarDate: `${number}-${number}-${number}`

An ISO calendar date, YYYY-MM-DD. Template-literal-typed for compile-time hints.


DateLike: CalendarDate | UtcInstant | string

The accepted date-like inputs on a verb option — a calendar date or a UTC instant.


UtcInstant: `${string}Z`

An ISO-8601 UTC instant ending in Z (e.g. 2025-06-01T12:00:00Z).

coerceCalendarDate(value, field, verb): `${number}-${number}-${number}`

Validate a DateLike and return its normalized YYYY-MM-DD.

Rejects a Date object (its instant is timezone-ambiguous), a malformed string, and a non-UTC instant — all before any I/O, throwing ContractError.

unknown

string

string

`${number}-${number}-${number}`


validateWindow(fromDate, toDate, verb): readonly [`${number}-${number}-${number}`, `${number}-${number}-${number}`]

Validate a [from, to] date window before any I/O; return the ISO bounds.

Enforces the DateLike contract on both bounds and rejects an inverted window (from > to) — the single closure every finite TS verb routes through.

unknown

unknown

string

readonly [`${number}-${number}-${number}`, `${number}-${number}-${number}`]