@mostlyrightmd/core/dates
Type Aliases
Section titled “Type Aliases”CalendarDate
Section titled “CalendarDate”CalendarDate:
`${number}-${number}-${number}`
An ISO calendar date, YYYY-MM-DD. Template-literal-typed for compile-time hints.
DateLike
Section titled “DateLike”DateLike:
CalendarDate|UtcInstant|string
The accepted date-like inputs on a verb option — a calendar date or a UTC instant.
UtcInstant
Section titled “UtcInstant”UtcInstant:
`${string}Z`
An ISO-8601 UTC instant ending in Z (e.g. 2025-06-01T12:00:00Z).
Functions
Section titled “Functions”coerceCalendarDate()
Section titled “coerceCalendarDate()”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.
Parameters
Section titled “Parameters”unknown
string
string
Returns
Section titled “Returns”`${number}-${number}-${number}`
validateWindow()
Section titled “validateWindow()”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.
Parameters
Section titled “Parameters”fromDate
Section titled “fromDate”unknown
toDate
Section titled “toDate”unknown
string
Returns
Section titled “Returns”readonly [`${number}-${number}-${number}`, `${number}-${number}-${number}`]