/** * Calendar Utilities * * Pure TypeScript utilities for calendar month generation and localization. * Ported from ClojureScript ty/date/core.cljs * * Key Features: * - 42-day calendar grid generation (6 weeks × 7 days) * - Monday-first week ordering * - Rich day context with metadata * - Localized weekday names * - No external dependencies (native Date API only) * * Note on Timestamps: * - `value`: UTC timestamp at midnight UTC (timezone-independent, use for storage/server) * - `localValue`: Local timestamp at midnight local time (use for display/local calculations) * - `year/month/dayInMonth`: Calendar date components (user's mental model) * * Example for October 13, 2025: * - value = Date.UTC(2025, 9, 13) = consistent worldwide * - localValue = new Date(2025, 9, 13).getTime() = varies by timezone * - Both represent the same calendar date, 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; } /** * 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; //# sourceMappingURL=calendar-utils.d.ts.map