export declare class InvalidDateAdapterError extends Error {} export interface DateAdapterType { base: DateAdapterBase; } export interface DateAdapterCTorType { base: typeof DateAdapterBase & (new (date: any) => DateAdapterBase); } export declare type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; export declare type DateAdapter = UnionToIntersection< DateAdapterType[keyof DateAdapterType] >; export declare type DateAdapterCTor = UnionToIntersection< DateAdapterCTorType[keyof DateAdapterCTorType] >; export declare type DateInput = DateAdapter['date'] | DateAdapter | DateTime; export declare abstract class DateAdapterBase { static set adapter(value: DateAdapterCTor); static get adapter(): DateAdapterCTor; static readonly date: object; static readonly hasTimezoneSupport: boolean; static isDate(_object: unknown): boolean; static fromDate( _date: DateAdapter['date'], _options?: { duration?: number; }, ): DateAdapter; static fromJSON(_json: DateAdapter.JSON): DateAdapter; static fromDateTime(_datetime: DateTime): DateAdapter; abstract readonly date: object; abstract readonly timezone: string | null; /** A length of time in milliseconds */ readonly duration: number; /** * Returns `undefined` if `this.duration` is falsey. Else returns * the `end` date. */ abstract end: object | undefined; /** * An array of OccurrenceGenerator objects which produced this DateAdapter. * * #### Details * * When a Rule object creates a DateAdapter, that Rule object adds itself to * the DateAdapter's generators property before yielding the DateAdapter. If you are using a Rule * object directly, the process ends there and the DateAdapter is yielded to you (in this case, * generators will have the type `[Rule]`) * * If you are using another object, like a Schedule however, then each DateAdapter is generated * by either a Dates (rdates) or Rule (rrule) within the Schedule. After being originally * generated by a Dates/Rule, the DateAdapter is then filtered by any exdate/exrules and, * assuming it passes, then the DateAdapter "bubbles up" to the Schedule object itself. At this * point the Schedule adds itself to the generators array of the DateAdapter and yields the date * to you. So each DateAdapter produced by a Schedule has a generators property of type * `[Schedule, Rule | Dates]`. * * The generators property pairs well with the `data` property on many OccurrenceGenerators. You * can access the OccurrenceGenerators which produced a DateAdapter via `generators`, and then * access any arbitrary data via the `data` property. * * _Note: occurrence operators are never included in the generators array._ * */ readonly generators: ReadonlyArray; /** * The metadata property is intended to store arbitrary data * related to this DateAdapter. Unlike other properties, the * metadata property is intended to be mutable. */ readonly metadata: Record; protected constructor( _date: unknown, options?: { duration?: number; generators?: ReadonlyArray; }, ); abstract set(prop: 'timezone', value: string | null): this; abstract set(prop: 'duration', value: number): this; abstract valueOf(): number; /** * Returns a string in simplified extended ISO format (ISO 8601). * * _Note: this method is intended for testing and its * implementation isn't particularly performant._ */ toISOString(): string; toDateTime(): DateTime; abstract toJSON(): DateAdapter.JSON; abstract assertIsValid(): boolean; } export declare namespace DateAdapter { const WEEKDAYS: ReadonlyArray<'SU' | 'MO' | 'TU' | 'WE' | 'TH' | 'FR' | 'SA'>; const MILLISECONDS_IN_SECOND = 1000; const MILLISECONDS_IN_MINUTE: number; const MILLISECONDS_IN_HOUR: number; const MILLISECONDS_IN_DAY: number; const MILLISECONDS_IN_WEEK: number; type Weekday = 'SU' | 'MO' | 'TU' | 'WE' | 'TH' | 'FR' | 'SA'; type TimeUnit = | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond'; interface JSON { timezone: string | null; duration?: number; year: number; month: number; day: number; hour: number; minute: number; second: number; millisecond: number; metadata?: Record; } type Year = number; type YearDay = number; type Month = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; type Day = | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31; type Hour = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23; type Minute = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59; type Second = Minute; type Millisecond = number; } declare type Granularity = DateAdapter.TimeUnit | 'week'; export declare class InvalidDateTimeError extends Error {} export declare class DateTime { /** * Returns `undefined` if `duration` is `0`. Else returns * the `end` date. */ get end(): DateTime | undefined; static fromJSON( json: DateAdapter.JSON & { generators?: ReadonlyArray; metadata?: Record; }, ): DateTime; static fromDateAdapter(adapter: DateAdapter): DateTime; readonly metadata: Record; readonly date: Date; /** * This property contains an ordered array of the generator objects * responsible for producing this DateAdapter. * * - If this DateAdapter was produced by a `Rule` object, this array * will just contain the `Rule` object. * - If this DateAdapter was produced by a `Schedule` object, this * array will contain the `Schedule` object as well as the `Rule` * or `Dates` object which generated it. * - If this DateAdapter was produced by a `Calendar` object, this * array will contain, at minimum, the `Calendar`, `Schedule`, and * `Rule`/`Dates` objects which generated it. */ readonly generators: ReadonlyArray; readonly timezone: string | null; readonly duration: number; private _end; private forkDateTime; private constructor(); isEqual(object?: DateTime): boolean; isBefore(object: DateTime): boolean; isBeforeOrEqual(object: DateTime): boolean; isAfter(object: DateTime): boolean; isAfterOrEqual(object: DateTime): boolean; isOccurring(object: DateTime): boolean; add(amount: number, unit: Granularity): DateTime; add(amount: unknown, unit: 'generator'): DateTime; subtract(amount: number, unit: Granularity): DateTime; get(unit: 'year'): DateAdapter.Year; get(unit: 'yearday'): DateAdapter.YearDay; get(unit: 'month'): DateAdapter.Month; get(unit: 'weekday'): DateAdapter.Weekday; get(unit: 'day'): DateAdapter.Day; get(unit: 'hour'): DateAdapter.Hour; get(unit: 'minute'): DateAdapter.Minute; get(unit: 'second'): DateAdapter.Second; get(unit: 'millisecond'): DateAdapter.Millisecond; set(unit: 'generators', value: unknown[]): DateTime; set(unit: DateAdapter.TimeUnit | 'duration', value: number): DateTime; granularity( granularity: Granularity, opt?: { weekStart?: DateAdapter.Weekday; }, ): DateTime; endGranularity( granularity: Granularity, opt?: { weekStart?: DateAdapter.Weekday; }, ): DateTime; toISOString(): string; toDateTime(): DateTime; toJSON(): DateAdapter.JSON; valueOf(): number; assertIsValid(): true; } export declare function dateTimeSortComparer( a: DateTime, b: DateTime, ): 1 | 0 | -1; export declare function uniqDateTimes(dates: DateTime[]): DateTime[]; export declare function orderedWeekdays( wkst?: DateAdapter.Weekday, ): DateAdapter.Weekday[]; export declare function getDifferenceBetweenWeekdays( x: DateAdapter.Weekday, y: DateAdapter.Weekday, ): number; export declare function isLeapYear(year: number): boolean; export declare function getDaysInYear(year: number): 366 | 365; export {};