UNPKG

@taskgenius/calendar

Version:

A lightweight, configurable TypeScript calendar component with drag-and-drop support

75 lines (70 loc) 2.73 kB
import { Dayjs } from 'dayjs'; /** * Abstract date adapter interface for pluggable date libraries */ declare interface DateAdapter<T> { /** Create a date from various inputs */ create(date?: string | Date | T): T; /** Parse a date string with optional format */ parse(dateStr: string, format?: string): T; /** Format a date to string */ format(date: T, format: string): string; /** Get year */ year(date: T): number; /** Get month (0-11) */ month(date: T): number; /** Get day of month (1-31) */ date(date: T): number; /** Get day of week (0-6, Sunday = 0) */ day(date: T): number; /** Get hour (0-23) */ hour(date: T): number; /** Get minute (0-59) */ minute(date: T): number; /** Set hour and return new date */ setHour(date: T, hour: number): T; /** Set minute and return new date */ setMinute(date: T, minute: number): T; /** Add time to date */ add(date: T, amount: number, unit: TimeUnit): T; /** Calculate difference between dates */ diff(date1: T, date2: T, unit: TimeUnit): number; /** Get start of time unit */ startOf(date: T, unit: TimeUnit): T; /** Get end of time unit */ endOf(date: T, unit: TimeUnit): T; /** Check if date1 is before date2 */ isBefore(date1: T, date2: T, unit?: TimeUnit): boolean; /** Check if date1 is after date2 */ isAfter(date1: T, date2: T, unit?: TimeUnit): boolean; /** Check if dates are the same */ isSame(date1: T, date2: T, unit?: TimeUnit): boolean; } /** * DateAdapter implementation using Day.js */ export declare class DayJsAdapter implements DateAdapter<Dayjs> { create(date?: string | Date | Dayjs): Dayjs; parse(dateStr: string, _format?: string): Dayjs; format(date: Dayjs, formatStr: string): string; year(date: Dayjs): number; month(date: Dayjs): number; date(date: Dayjs): number; day(date: Dayjs): number; hour(date: Dayjs): number; minute(date: Dayjs): number; setHour(date: Dayjs, hour: number): Dayjs; setMinute(date: Dayjs, minute: number): Dayjs; add(date: Dayjs, amount: number, unit: TimeUnit): Dayjs; diff(date1: Dayjs, date2: Dayjs, unit: TimeUnit): number; startOf(date: Dayjs, unit: TimeUnit): Dayjs; endOf(date: Dayjs, unit: TimeUnit): Dayjs; isBefore(date1: Dayjs, date2: Dayjs, unit?: TimeUnit): boolean; isAfter(date1: Dayjs, date2: Dayjs, unit?: TimeUnit): boolean; isSame(date1: Dayjs, date2: Dayjs, unit?: TimeUnit): boolean; } /** * Time unit for date operations */ declare type TimeUnit = "year" | "month" | "week" | "day" | "hour" | "minute"; export { }