UNPKG

claritykit-svelte

Version:

A comprehensive Svelte component library focused on accessibility, ADHD-optimized design, developer experience, and full SSR compatibility

112 lines 3.54 kB
/** * Date utility functions for ClarityKit * Provides common date formatting, parsing, and calculation functions */ /** * Format a date using various format options * @param date - Date to format * @param format - Format string or preset format * @param locale - Optional locale for formatting */ export declare function formatDate(date: Date | string | number, format?: string, locale?: string): string; /** * Format a date relative to now (e.g., "2 days ago", "in 3 hours") */ export declare function formatRelativeDate(date: Date | string | number): string; /** * Parse a date string or number into a Date object */ export declare function parseDate(date: string | number | Date): Date | null; /** * Convert a date to ISO date string (YYYY-MM-DD) */ export declare function toISODateString(date: Date | string | number): string; /** * Calculate the number of days between two dates */ export declare function daysBetween(date1: Date | string, date2: Date | string): number; /** * Check if a year is a leap year */ export declare function isLeapYear(year: number): boolean; /** * Get the number of days in a specific month */ export declare function getDaysInMonth(year: number, month: number): number; /** * Check if two dates are on the same day */ export declare function isSameDay(date1: Date | string, date2: Date | string): boolean; /** * Add days to a date */ export declare function addDays(date: Date | string, days: number): Date; /** * Add months to a date */ export declare function addMonths(date: Date | string, months: number): Date; /** * Get the start of day for a date (00:00:00) */ export declare function startOfDay(date: Date | string): Date; /** * Get the end of day for a date (23:59:59.999) */ export declare function endOfDay(date: Date | string): Date; /** * Check if a date is today */ export declare function isToday(date: Date | string): boolean; /** * Check if a date is in the past */ export declare function isPast(date: Date | string): boolean; /** * Check if a date is in the future */ export declare function isFuture(date: Date | string): boolean; /** * Format duration in milliseconds to human-readable string */ export declare function formatDuration(ms: number): string; /** * Get the age in years from a birth date */ export declare function getAge(birthDate: Date | string): number; /** * Format date and time together */ export declare function formatDateTime(date: Date | string | number, locale?: string): string; /** * Format relative time (alias for formatRelativeDate) */ export declare function formatRelativeTime(date: Date | string | number): string; /** * Check if a date is yesterday */ export declare function isYesterday(date: Date | string): boolean; /** * Check if a date is tomorrow */ export declare function isTomorrow(date: Date | string): boolean; /** * Subtract days from a date */ export declare function subDays(date: Date | string, days: number): Date; /** * Get the start of the month for a date */ export declare function startOfMonth(date: Date | string): Date; /** * Get the end of the month for a date */ export declare function endOfMonth(date: Date | string): Date; /** * Get the start of the week for a date (Sunday by default) */ export declare function startOfWeek(date: Date | string, weekStartsOn?: number): Date; /** * Get the end of the week for a date (Saturday by default) */ export declare function endOfWeek(date: Date | string, weekStartsOn?: number): Date; //# sourceMappingURL=date.d.ts.map