/** * Calendar month generation and localization (native Date API only). * * Timestamps: `value` is UTC midnight (timezone-independent, for storage/server), * `localValue` is local midnight (for display/local math). Both denote the same * calendar date but are different moments in time. */ /** * Rich context for a single calendar day * Contains all metadata needed for rendering and event handling */ export interface DayContext { /** Timestamp in milliseconds (UTC midnight) - use for server communication and storage */ value: number; /** Timestamp in milliseconds (local midnight) - use for local calculations and display */ localValue: number; /** Year (e.g., 2025) */ year: number; /** Month (1-12, 1 = January) */ month: number; /** Day of month (1-31) */ dayInMonth: number; /** Is this a weekend day? (Saturday or Sunday) */ weekend: boolean; /** Is this day from a different month? */ otherMonth: boolean; /** Is this from the previous month? */ prevMonth?: boolean; /** Is this from the next month? */ nextMonth?: boolean; /** Is this today? */ today?: boolean; /** Is this a holiday? (extensible for future use) */ holiday?: boolean; /** Is this day selected? (from calendar's internal state) */ isSelected?: boolean; /** Calendar's selected year (if any) */ selectedYear?: number; /** Calendar's selected month (if any) */ selectedMonth?: number; /** Calendar's selected day (if any) */ selectedDay?: number; } /** * Local midnight of a calendar day. Not the Date constructor: it reads years * 0-99 as 1900-1999. Noon is never skipped by a clock change, so the day * can't shift before setHours. */ export declare function localMidnight(year: number, month: number, day: number): Date; /** UTC midnight of a calendar day, as a timestamp. Not Date.UTC(): it reads years 0-99 as 1900-1999. */ export declare function utcMidnight(year: number, month: number, day: number): number; /** * Generate a 42-day calendar grid for a given month * * Returns 6 weeks (42 days) starting from the Monday at or before * the first day of the month. This ensures a complete calendar view * with days from the previous and next months as needed. * * @param year - Year (e.g., 2025) * @param month - Month (1-12, 1 = January) * @param selection - Optional selection state to include in day contexts * @returns Array of 42 day contexts with rich metadata * * @throws {RangeError} If year or month are invalid * * @example * const days = getCalendarMonthDays(2025, 10); // October 2025 * console.log(days.length); // 42 * console.log(days[0].dayInMonth); // First day shown (might be from September) */ export declare function getCalendarMonthDays(year: number, month: number, selection?: { year?: number; month?: number; day?: number; }): DayContext[]; /** * Get localized weekday names in Monday-first order * * Note: Intl.DateTimeFormat returns Sunday-first by default, * so we reorder to Monday-first: [Mon, Tue, Wed, Thu, Fri, Sat, Sun] * * @param locale - Locale string (e.g., "en-US", "de-DE", "ja-JP") * @param style - Display style: "long" (Monday), "short" (Mon), "narrow" (M) * @returns Array of 7 weekday names starting with Monday * * @example * getLocalizedWeekdays("en-US", "short") * // Returns: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] * * getLocalizedWeekdays("de-DE", "long") * // Returns: ["Montag", "Dienstag", "Mittwoch", ...] */ export declare function getLocalizedWeekdays(locale: string, style?: 'long' | 'short' | 'narrow'): string[]; /** * Get month name in specified locale * * @param month - Month (1-12) * @param locale - Locale string * @param style - Display style * @returns Localized month name * * @throws {RangeError} If month is invalid */ export declare function getMonthName(month: number, locale?: string, style?: 'long' | 'short' | 'narrow'): string; /** * Parse an ISO date string (YYYY-MM-DD) into year, month, day components * * @param isoString - ISO date string (YYYY-MM-DD) * @returns Object with year, month (1-12), and day, or null if invalid * * @example * parseISODate("2025-10-13") * // Returns: { year: 2025, month: 10, day: 13 } */ export declare function parseISODate(isoString: string): { year: number; month: number; day: number; } | null; /** * Date/time components in local time, as ty-date-picker holds them. */ export interface DateTimeParts { year?: number; month?: number; day?: number; hour?: number; minute?: number; second?: number; epoch?: number; } /** A Date whose UTC fields are these components: formats a wall-clock as written (timeZone 'UTC'). */ export declare function wallClockDate(c: DateTimeParts): Date; /** * Parse any date value ty-date-picker reads into local components: * - Date only: '2024-09-21' (that calendar day) * - Datetime-local: '2024-09-21T10:30[:45]' (local wall-clock) * - UTC strings: '2024-09-21T08:30:00Z' or '2024-09-21T08:30:00.000Z' * - With timezone: '2024-09-21T10:30:00+02:00' * - Timestamps: milliseconds since epoch (a number, not a digit string) * * A zone-less value is taken as written, even a time the clocks skip when * summer time starts (like ); 2024-02-30 or 24:00 * is no value. An instant reads as its LOCAL day and time, and keeps its * epoch. */ export declare function parseDateTime(value: string | number | null | undefined): DateTimeParts | null; /** * The calendar day of any value parseDateTime reads, or a Date: an instant * is its local day. Years outside 1-9999 (no 4-digit YYYY-MM-DD) are no day. */ export declare function parseDateDay(value: string | number | Date | null | undefined): { year: number; month: number; day: number; } | null; /** 'YYYY-MM-DD' of a calendar day (years below 1000 padded to 4 digits). */ export declare function formatISODay(year: number, month: number, day: number): string; /** Any value parseDateDay reads as 'YYYY-MM-DD', or null. */ export declare function toISODay(value: string | number | Date | null | undefined): string | null;