@rschedule/rschedule
Version:
A typescript library for working with recurring dates and events.
70 lines • 3.63 kB
TypeScript
import { DateAdapter } from '../date-adapter';
import { DateTime, IDateAdapter } from '../date-time';
import { DateInput } from '../utilities';
/**
* This function performs validation checks on the provided rule options and retuns
* a cloned validated options object.
*/
export declare function normalizeRuleOptions<T extends typeof DateAdapter>(dateAdapterConstructor: T, options: IProvidedRuleOptions<T>): INormalizedRuleOptions;
export declare function normalizeDateInput<T extends typeof DateAdapter>(input: T['date'] | InstanceType<T> | IDateAdapter.JSON, dateAdapter: T): DateTime;
export declare function cloneRuleOptions<T extends typeof DateAdapter, O extends IProvidedRuleOptions<T> | INormalizedRuleOptions>(options: O): O;
export declare class RuleValidationError extends Error {
}
export interface IProvidedRuleOptions<T extends typeof DateAdapter> {
start: RuleOption.Start<T>;
end?: RuleOption.End<T>;
duration?: RuleOption.Duration;
frequency: RuleOption.Frequency;
interval?: RuleOption.Interval;
count?: RuleOption.Count;
weekStart?: RuleOption.WeekStart;
bySecondOfMinute?: RuleOption.BySecondOfMinute[];
byMinuteOfHour?: RuleOption.ByMinuteOfHour[];
byHourOfDay?: RuleOption.ByHourOfDay[];
byDayOfWeek?: RuleOption.ByDayOfWeek[];
byDayOfMonth?: RuleOption.ByDayOfMonth[];
byMonthOfYear?: RuleOption.ByMonthOfYear[];
}
export interface INormalizedRuleOptions {
start: DateTime;
end?: DateTime;
duration?: number;
frequency: RuleOption.Frequency;
interval: RuleOption.Interval;
count?: RuleOption.Count;
weekStart: RuleOption.WeekStart;
byMillisecondOfSecond?: RuleOption.ByMillisecondOfSecond[];
bySecondOfMinute?: RuleOption.BySecondOfMinute[];
byMinuteOfHour?: RuleOption.ByMinuteOfHour[];
byHourOfDay?: RuleOption.ByHourOfDay[];
byDayOfWeek?: RuleOption.ByDayOfWeek[];
byDayOfMonth?: RuleOption.ByDayOfMonth[];
byMonthOfYear?: RuleOption.ByMonthOfYear[];
}
export declare namespace RuleOption {
type Start<T extends typeof DateAdapter> = DateInput<T>;
type End<T extends typeof DateAdapter> = Start<T>;
type Duration = number;
type Interval = number;
type Count = number;
type WeekStart = IDateAdapter.Weekday;
type Frequency = 'MILLISECONDLY' | 'SECONDLY' | 'MINUTELY' | 'HOURLY' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
/**
* The ByDayOfWeek type corresponds to either a two letter string for the weekday
* (i.e. 'SU', 'MO', etc) or an array of length two containing a weekday string
* and a number, in that order. The number describes the position of the weekday
* in the month / year (depending on other rules). It's explained pretty well
* in the [ICAL spec](https://tools.ietf.org/html/rfc5545#section-3.3.10).
* If the number is negative, it is calculated from the end of
* the month / year.
*/
type ByDayOfWeek = IDateAdapter.Weekday | [IDateAdapter.Weekday, number];
type ByMillisecondOfSecond = IDateAdapter.Millisecond;
type BySecondOfMinute = ByMinuteOfHour | 60;
type ByMonthOfYear = IDateAdapter.Month;
type ByMinuteOfHour = IDateAdapter.Minute;
type ByHourOfDay = IDateAdapter.Hour;
type ByDayOfMonth = IDateAdapter.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 ByWeekOfMonth = 1 | 2 | 3 | 4 | 5 | -1 | -2 | -3 | -4;
}
//# sourceMappingURL=rule-options.d.ts.map