/** * Canonical timestamp/date registers (LC-12 TIMESTAMP-REGISTER, Axiom 9). * * One formatter owns every absolute date the catalog renders — Timeline * timestamps, table date cells (FieldDisplay), DatePicker display values — * so the same data class never speaks in multiple voices ("2026-07-01" vs * "Aug 9, 3:30 PM" vs "11/01/2026"). * * Content class picks the register (paired with the `timestampStyle` knob): * - feeds/social → relative ("2h ago") via `formatRelativeTimestamp` * - tables/system → compact absolute ("Jul 1" / "Aug 9, 3:30 PM"), * current year elided (`year: "auto"`) * - editing surfaces → compact absolute with the year always shown * ("Jul 1, 2026") — pickers are precision contexts * - calendar chrome → the day/month/time-of-day registers below * (weekday and month names, "2 PM" hour ticks, * "2:00 PM" times, "Tuesday, March 10" day names) * - date axis ticks → compact absolute with `year: "never"`, because * the surrounding chrome already states the year * No default may emit verbose locale output with seconds. */ export type DateInput = Date | string | number | null | undefined; export interface AbsoluteDateFormatOptions { /** * `"auto"` (default) elides the current year — the display register for * tables, feeds, and system events. `"always"` keeps it — the editing * register for picker display values. `"never"` drops it — the axis-tick * register, where a wider label would collide with its neighbours and the * period header carries the year. */ year?: "auto" | "always" | "never"; /** Include the time component ("Aug 9, 3:30 PM"). Default false. */ withTime?: boolean; /** * Append seconds to the time component ("Aug 9, 3:30:45 PM"). Off by * default — no register emits seconds unless a surface asks. Only the * editing register does: a `showSeconds` picker has to display the second * it lets you set. Ignored without `withTime`. */ seconds?: boolean; /** * Pin the 12/24-hour clock instead of following the locale — the * `timeFormat` contract a datetime picker exposes to its consumers. * Ignored without `withTime`. */ hour12?: boolean; /** BCP-47 locale forwarded to Intl. Default: system locale. */ locale?: string; /** Reference date for current-year elision (injectable for tests). */ now?: Date; } /** ISO date-only shape ("YYYY-MM-DD"). */ export declare const ISO_DATE_ONLY: RegExp; /** * Parse a date value onto the LOCAL calendar day it names — the canonical * parse for anything that will be positioned on a day grid (calendar cells, * Gantt bars, date axes) rather than merely formatted. * * A date-only string ("YYYY-MM-DD") is a calendar date carrying no timezone, * which is how Frappe sends `Date` fields. ECMA-262 parses that form as UTC * midnight, so every zone west of UTC reads it as the *previous* local day, * and no zone but UTC lands it on the local midnight that day-grid math tests * for. Those are built from local parts instead. * * Values that carry a time ("YYYY-MM-DD HH:MM:SS", ISO with an offset, epoch * millis) are genuine instants and keep the timezone-aware parse untouched. * * Returns null for empty and unparseable input, and for out-of-range parts * ("2026-13-45") rather than silently rolling them into the next month. */ export declare function parseCalendarDate(value: DateInput): Date | null; /** Timezone-naive wire shapes: Frappe's `Date`, `Datetime` and `Time`. */ export type CalendarDateShape = "date" | "datetime" | "time"; /** * Serialize a date onto the LOCAL calendar parts it names — the write * counterpart to `parseCalendarDate`, and the only place the repo builds a * timezone-naive wire string. * * `"date"` emits `YYYY-MM-DD`, `"datetime"` emits `YYYY-MM-DD HH:mm:ss`, and * `"time"` emits `HH:mm:ss` — the shapes Frappe stores, none of which carries * an offset. `toISOString()` renders the UTC instant instead, so it names the * wrong day whenever the value's local time of day sits across the UTC date * boundary, and shifts a wall clock by the whole offset. Reading such a string * back through `parseCalendarDate` then compounds the error, because the read * side treats it as local. * * Accepts anything `parseCalendarDate` does, so a value already on the wire * round-trips unchanged; empty and unparseable input serialize to "". */ export declare function formatCalendarDate(value: DateInput, shape?: CalendarDateShape): string; /** * Compact absolute date — the house register for every absolute date. * "Jul 1" / "Jul 1, 2025" (year auto-elided when current), or with * `withTime` "Aug 9, 3:30 PM". Empty input renders "" and an unparseable * string passes through unchanged (honest passthrough — never invents). */ export declare function formatAbsoluteDate(value: DateInput, options?: AbsoluteDateFormatOptions): string; /** * Compact absolute date-time ("Aug 9, 3:30 PM"; year added when not * current). The system-event register (LC-12), the tooltip form for relative * timestamps, and — with `year: "always"` — the datetime picker display on * BOTH platform halves, which is why it takes `hour12` / `seconds`: the two * halves used to compose their own and drifted by a comma. */ export declare function formatAbsoluteDateTime(value: DateInput, options?: Omit): string; /** * Relative timestamp ("just now", "5m ago", "2h ago", "10 days ago") — the * feed/social register (LC-12), selected by `timestampStyle: "relative"`. */ export declare function formatRelativeTimestamp(value: DateInput, now?: number): string; /** Clock-time shape ("HH:MM" / "HH:MM:SS") — how Frappe `Time` values arrive. */ export declare const CLOCK_TIME: RegExp; export interface TimeOfDayFormatOptions { /** BCP-47 locale forwarded to Intl. Default: system locale. */ locale?: string; /** Minutes ride along by default; `false` is the hour-tick register. */ minutes?: boolean; /** Pin the 12/24-hour clock. Default: whatever the locale uses. */ hour12?: boolean; } /** * Time-of-day register ("2:00 PM", or "2 PM" with `minutes: false` for * hour ticks) — calendar time grids, Frappe `Time` fields, and * "last updated" chrome. Accepts a clock-time string as well as a date, * and never emits seconds. */ export declare function formatTimeOfDay(value: DateInput, options?: TimeOfDayFormatOptions): string; export interface DayLongFormatOptions { locale?: string; /** Lead with the weekday ("Tuesday, March 10"). Default true. */ weekday?: boolean; /** Append the year ("Tuesday, March 10, 2026"). Default false. */ year?: boolean; } /** * Long day register ("Tuesday, March 10") — calendar day headers and the * accessible names that read a date aloud, where the compact absolute * register is too terse to speak. */ export declare function formatDayLong(value: DateInput, options?: DayLongFormatOptions): string; export interface MonthYearFormatOptions { locale?: string; /** `"short"` ("Mar 2026", the tick register) or `"long"` ("March 2026"). */ month?: "short" | "long"; } /** Month-year register ("Mar 2026") — period headers and month axis ticks. */ export declare function formatMonthYear(value: DateInput, options?: MonthYearFormatOptions): string; /** Day-of-month register ("10") — the densest date axis tick. */ export declare function formatDayOfMonth(value: DateInput, options?: { locale?: string; }): string; export interface WeekdayNamesOptions { locale?: string; /** `"short"` ("Mon"), `"long"` ("Monday") or `"narrow"` ("M"). */ style?: "short" | "long" | "narrow"; /** Week start, 0 = Sunday (default) — the index base callers rely on. */ firstDay?: number; } /** Weekday names for calendar chrome, in week order from `firstDay`. */ export declare function getWeekdayNames(options?: WeekdayNamesOptions): string[]; /** Month names for calendar chrome and picker headers, January first. */ export declare function getMonthNames(options?: { locale?: string; style?: "long" | "short"; }): string[]; //# sourceMappingURL=dates.d.ts.map