/** * Date utilities for bridging form values, ISO strings, and `Date` objects. * * Components like {@link DatePicker} accept either a `Date` or an ISO * timestamp on input. When the surrounding state holds ISO strings (for * example because the database driver serialises timestamps that way), * use these helpers to convert in both directions instead of redoing the * arithmetic at every form site. * * The strict `YYYY-MM-DD` ↔ `Date` core is not reimplemented here: it lives in * `../date/range` (`toIso` / `isoToDate`, the Layer-0 source of truth). These * tolerant form helpers delegate to it and only add the tolerant shape rules * (empty/undefined → nullish, 1-digit month/day, epoch-number coercion). */ /** Shared union for utilities that accept any common "date-ish" input. */ export type DateInput = Date | string | number | null | undefined; /** Month index used by `Date#getMonth()`. */ export type MonthIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11; /** Weekday index used by `Date#getDay()`. */ export type WeekdayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6; /** * Coerce a `Date`, ISO timestamp, epoch-ms number, or empty value into a * `Date`. Returns `undefined` for empty / unparseable inputs. * * Shape rules: * - Strings of the form `YYYY-MM-DD` are parsed in LOCAL timezone * (matching `` and `toDateInputValue` round-trip). * - Numbers smaller than ~100 s past epoch are rejected as ambiguous * (programmer error — `2026` passed instead of a real timestamp). * Legitimate pre-2001 epoch ms (e.g. birthdays) are accepted. * - Invalid `Date` instances and unparseable strings log a warning * instead of disappearing silently. */ export declare function coerceToDate(input: DateInput): Date | undefined; /** * Format a date as the `YYYY-MM-DD` string accepted by * `` and the DatePicker text rendering. Returns * an empty string for null / invalid inputs so it can be assigned * directly to a form field's `value`. */ export declare function toDateInputValue(d: Date | string | null | undefined): string; /** * Parse a `YYYY-MM-DD` (or any other `Date`-parseable) string into a * `Date`. `YYYY-MM-DD` is interpreted as LOCAL midnight to round-trip * with `toDateInputValue`; full ISO timestamps with timezone are passed * to the native parser unchanged. Returns `null` for empty or malformed * input so the caller decides how to surface the error. */ export declare function fromDateInputValue(s: string | null | undefined): Date | null;