/** * date-core - framework-free date math shared by SvCalendar, SvTimePicker and * SvDateTimePicker. No Svelte, no DOM: pure functions over the native `Date` * so it is trivially unit- and mutation-testable and reusable standalone. * * Conventions: * - A "day" is compared by local calendar date (year/month/date), ignoring the * time-of-day, unless a helper says otherwise. * - `firstDayOfWeek` is 0-6 (0 = Sunday), matching `Date.getDay()` and Smart's * `firstDayOfWeek`. */ export type DateLike = Date | number | string; /** Coerce a Date | epoch-ms | parseable string to a Date, or null if invalid. */ export declare function toDate(value: DateLike | null | undefined): Date | null; /** A new Date at local midnight of the same calendar day (time stripped). */ export declare function startOfDay(d: Date): Date; /** First day (midnight) of the month `d` falls in. */ export declare function startOfMonth(d: Date): Date; /** Last day (midnight) of the month `d` falls in. */ export declare function endOfMonth(d: Date): Date; /** Number of days in the month `d` falls in. */ export declare function daysInMonth(d: Date): number; /** * Start of the week containing `d`, honoring `firstDayOfWeek` (0-6). Returns a * local-midnight Date on or before `d`. */ export declare function startOfWeek(d: Date, firstDayOfWeek?: number): Date; /** True when both dates are the same local calendar day. */ export declare function isSameDay(a: Date | null, b: Date | null): boolean; /** True when both dates are in the same year+month. */ export declare function isSameMonth(a: Date | null, b: Date | null): boolean; /** -1 / 0 / 1 comparison by calendar day (time-of-day ignored). */ export declare function compareDay(a: Date, b: Date): number; /** Add `n` days (can be negative), returning a new Date. */ export declare function addDays(d: Date, n: number): Date; /** * Add `n` calendar months, clamping the day-of-month so 31 Jan + 1 month = 28/29 * Feb rather than spilling into March (matches how calendars paginate). */ export declare function addMonths(d: Date, n: number): Date; /** Add `n` years, clamping Feb-29 to Feb-28 on non-leap targets. */ export declare function addYears(d: Date, n: number): Date; /** Clamp `d` to the inclusive [min, max] range (either bound may be null). */ export declare function clampDate(d: Date, min: Date | null, max: Date | null): Date; /** * ISO 8601 week number (1-53) for `d`. Week 1 is the week containing the first * Thursday of the year; weeks start Monday. Independent of `firstDayOfWeek`, * matching Smart's `weekNumbers` column which is always ISO. */ export declare function isoWeek(d: Date): number; /** * The [start, end] years of the decade block that `year` belongs to, as Smart * renders it: a 12-cell page running from the decade start minus 1 to plus 10 * (one leading + one trailing year for context). We expose the canonical * decade [Y0, Y0+9] and let the view pad. */ export declare function decadeRange(year: number): { start: number; end: number; }; /** The [start, end] years of the century block (100-year) `year` belongs to. */ export declare function centuryRange(year: number): { start: number; end: number; }; export type MonthMatrixCell = { date: Date; /** In the displayed month (vs. leading/trailing days of adjacent months). */ inMonth: boolean; /** ISO week number of the row this cell sits in. */ week: number; }; /** * Build a month grid of `weeks` rows x 7 columns starting at `firstDayOfWeek`, * padded with the trailing days of the previous month and leading days of the * next so every row is full. `weeks` defaults to 6 (the max any month needs), * matching Smart's fixed-height calendar. */ export declare function monthMatrix(monthDate: Date, firstDayOfWeek?: number, weeks?: number): MonthMatrixCell[][]; /** * Ordered weekday indexes (0-6) for a header row starting at `firstDayOfWeek`. * e.g. firstDayOfWeek=1 -> [1,2,3,4,5,6,0]. */ export declare function weekdayOrder(firstDayOfWeek?: number): number[]; /** Merge a calendar day with a time-of-day taken from `time`, returning a new Date. */ export declare function withTime(day: Date, time: Date): Date; /** Snap a minute value to the nearest lower multiple of `interval` (>=1). */ export declare function snapMinute(minute: number, interval: number): number;