/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import type { SheetWords } from "../words.js"; /** The cell's display pattern — `17 Nov 26`. */ export declare const DATE_DISPLAY_PATTERN = "D MMM YY"; /** The edit form — `17/11/26`. */ export declare const DATE_EDIT_PATTERN = "D/M/YY"; /** The strip preview — `Mon 17 Nov 26`. */ export declare const DATE_LONG_PATTERN = "ddd D MMM YY"; /** The clipboard form (B§10) — `17/11/2026`. */ export declare const DATE_CLIPBOARD_PATTERN = "D/M/YYYY"; /** UTC midnight of a date. */ export declare function utcMidnight(d: Date): Date; /** Today at UTC midnight — the `today` the wire context carries. */ export declare function todayUtc(now?: Date): Date; /** A UTC date from calendar parts (month 1-based). Invalid parts overflow like `Date.UTC`. */ export declare function utcDate(y: number, m: number, d: number): Date; /** `d` plus `n` days, in UTC. */ export declare function addDays(d: Date, n: number): Date; /** Whole days from `a` to `b` (rounded). */ export declare function daysBetween(a: Date, b: Date): number; /** What the grammar needs beside the text. */ export interface DateParseContext { /** Today, UTC midnight. */ today: Date; /** The base column's value, when the column declares a base and the row holds one. */ base?: Date | undefined; } /** * Parse typed text to a UTC-midnight date. * * @returns the date; `undefined` for an empty buffer (a blank); `null` when unrecognised */ export declare function parseDate(text: string, ctx: DateParseContext): Date | null | undefined; /** `17 Nov 26` — the cell's display form. */ export declare function formatDateDisplay(d: Date): string; /** `17/11/26` — the edit form. */ export declare function formatDateEdit(d: Date): string; /** `Mon 17 Nov 26` — the strip preview. */ export declare function formatDateLong(d: Date): string; /** `17/11/2026` — the clipboard form (B§10). */ export declare function formatDateClipboard(d: Date): string; /** How deep a date is read and typed — the tags of `Sheet.Types.DateLevel`. */ export type WhenLevel = "week" | "day" | "range" | "time"; /** Whether a string names a level — what a level rule cell holds. */ export declare function isWhenLevel(s: string): s is WhenLevel; /** The instant at `hh:mm` on `d`'s day. */ export declare function withTime(d: Date, hh: number, mm: number): Date; /** Whether an instant carries a time of day. */ export declare const hasTime: (d: Date) => boolean; /** `19:00`. */ export declare const formatTime: (d: Date) => string; /** The Monday of `d`'s week (UTC). */ export declare function weekStart(d: Date): Date; /** A trailing `hh:mm` on typed text, split off: the rest, and the time it names. */ export declare function splitTimeToken(text: string): { rest: string; time?: { hh: number; mm: number; }; }; /** * The edit form at a level: the day alone up to the range level, the day and * the clock at the time level (`22/3/26 19:00`). With no level, a date that * carries a time of day keeps it. * * @param d - The instant * @param level - The row's level, if the column declares one * @returns The text the editor opens with */ export declare function formatWhenEdit(d: Date, level?: WhenLevel): string; /** The cell's display form at a level — `22/03/26`. */ export declare const WHEN_DISPLAY_PATTERN = "DD/MM/YY"; /** * What a date cell prints at a level: the day as `dd/mm/yy` (at the week * level, the week's Monday), the time after it at the time level, and the * RESOLUTION as a tag — `wk` · `day` · `range` · `time` in English, the * sheet's words (#861) — so a reader never infers the precision from the * shape of the text. * * @param d - The instant * @param level - The level it is read at * @param w - The sheet's words * @returns The text and its resolution tag */ export declare function formatWhen(d: Date, level: WhenLevel, w: SheetWords): { text: string; suffix: string; }; /** * The forms a level accepts — the strip's `accepts` line, in the sheet's * words (#861). * * @param level - The level * @param w - The sheet's words * @returns The chip and the meta line */ export declare function whenAccepts(level: WhenLevel, w: SheetWords): { chip: string; meta: string; }; /** * How an ACTUAL instant stands against the WANTED date at its level. Inside * the window the level names — the week, the day, an hour either side of a * time — it is on time; otherwise late or early by whole days, or by hours * under a day, measured from the wanted instant. * * @param wanted - The wanted date, as the cell holds it * @param level - The level it is read at * @param actual - When the work really happened * @param w - The sheet's words (#861) * @returns The tag (`+1d` · `−3h` · `actual`), its tone, and the words the cell's detail says (`3 hours late`) */ export declare function actualAgainst(wanted: Date, level: WhenLevel, actual: Date, w: SheetWords): { tag: string; tone: "on" | "late" | "early"; words: string; }; //# sourceMappingURL=date.d.ts.map