@rschedule/rschedule
Version:
A typescript library for working with recurring dates and events.
62 lines • 2.95 kB
TypeScript
import { DateTime, IDateAdapter } from '../date-time';
export declare class InvalidDateAdapterError extends Error {
}
declare const DATE_ADAPTER_ID: unique symbol;
export declare class DateAdapter implements IDateAdapter<unknown> {
static readonly date: unknown;
static readonly hasTimezoneSupport: boolean;
/**
* Similar to `Array.isArray()`, `isInstance()` provides a surefire method
* of determining if an object is a `DateAdapter` by checking against the
* global symbol registry.
*/
static isInstance(object: unknown): object is DateAdapter;
static isDate(_object: unknown): boolean;
static fromJSON(_json: IDateAdapter.JSON): DateAdapter;
static fromDateTime(_datetime: DateTime): DateAdapter;
readonly date: unknown;
readonly timezone: string | null;
/** A length of time in milliseconds */
readonly duration: number | 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: unknown[];
protected readonly [DATE_ADAPTER_ID] = true;
constructor(_date: unknown, _options?: unknown);
/**
* Returns `undefined` if `this.duration` is falsey. Else returns
* the `end` date.
*/
readonly end: unknown | undefined;
set(_prop: 'timezone', _value: string | null): DateAdapter;
valueOf(): number;
toISOString(): string;
toDateTime(): DateTime;
toJSON(): IDateAdapter.JSON;
assertIsValid(): boolean;
}
export {};
//# sourceMappingURL=date-adapter.d.ts.map