diff --git a/rrule/rrule.d.ts b/rrule/rrule.d.ts index d7e38129a0..a86a37c8c7 100644 --- a/rrule/rrule.d.ts +++ b/rrule/rrule.d.ts @@ -17,7 +17,7 @@ declare namespace RRule { freq: any; // Should be enum dtstart?: Date; interval?: number; - wkst?: number // | day enum + wkst?: number | Weekday count?: number; until?: Date; bysetpos?: number; @@ -31,11 +31,15 @@ declare namespace RRule { bysecond?: number; } - interface Weekday { - new (n: number): Weekday; + class Weekday { + constructor(weekday: number, n: number); + nth(n: number): Weekday; + equals(other: Weekday): boolean; + toString(): string; + getJsWeekday(): number; } @@ -114,15 +118,25 @@ declare class RRule { declare namespace RRule { - const FREQUENCIES: ['YEARLY' | 'MONTHLY' | 'WEEKLY' | 'DAILY' | 'HOURLY' | 'MINUTELY' | 'SECONDLY']; + const FREQUENCIES: "YEARLY" | "MONTHLY" | "WEEKLY" | "DAILY" | "HOURLY" | "MINUTELY" | "SECONDLY"; - const YEARLY: number; - const MONTHLY: number; - const WEEKLY: number; - const DAILY: number; - const HOURLY: number; - const MINUTELY: number; - const SECONDLY: number; + enum Frequency { + YEARLY = 0, + MONTHLY = 1, + WEEKLY = 2, + DAILY = 3, + HOURLY = 4, + MINUTELY = 5, + SECONDLY = 6 + } + + const YEARLY: Frequency; + const MONTHLY: Frequency; + const WEEKLY: Frequency; + const DAILY: Frequency; + const HOURLY: Frequency; + const MINUTELY: Frequency; + const SECONDLY: Frequency; const MO: Weekday; const TU: Weekday; @@ -144,106 +158,4 @@ declare namespace RRule { function fromString(value: string): RRule; - class RRuleSet { - constructor(noCache?: boolean); - - /** - * @param {RRule} - */ - rrule(rrule: RRule): void; - - /** - * @param {Date} - */ - rdate(date: Date): void; - - /** - * @param {RRule} - */ - exrule(rrule: RRule): void; - - /** - * @param {Date} - */ - exdate(date: Date): void; - - valueOf(): string; - - /** - * to generate recurrence field sush as: - * ["RRULE:FREQ=YEARLY;COUNT=2;BYDAY=TU;DTSTART=19970902T010000Z","RRULE:FREQ=YEARLY;COUNT=1;BYDAY=TH;DTSTART=19970902T010000Z"] - */ - toString(): string; - - /** - * Create a new RRuleSet Object completely base on current instance - */ - clone(): RRuleSet; - - /** - * Returns the first recurrence after the given datetime instance. - * The inc keyword defines what happens if dt is an occurrence. - * With inc == True, if dt itself is an occurrence, it will be returned. - * @return Date or null - */ - after(dt: Date, inc?: boolean): Date; - - /** - * @param {Function} iterator - optional function that will be called - * on each date that is added. It can return false - * to stop the iteration. - * @return Array containing all recurrences. - */ - all(iterator?: (date: Date) => void): Date[] - - /** - * Returns all the occurrences of the rrule between after and before. - * The inc keyword defines what happens if after and/or before are - * themselves occurrences. With inc == True, they will be included in the - * list, if they are found in the recurrence set. - * @return Array - */ - between(a: Date, b: Date, iterator?: (date: Date) => void): Date[]; - - /** - * Returns the last recurrence before the given datetime instance. - * The inc keyword defines what happens if dt is an occurrence. - * With inc == True, if dt itself is an occurrence, it will be returned. - * @return Date or null - */ - before(dt: Date, inc?: boolean): Date; - - /** - * Returns the number of recurrences in this set. It will have go trough - * the whole recurrence, if this hasn't been done before. - */ - count(): number; - - } - - /** - * RRuleStr - * To parse a set of rrule strings - */ - class RRuleString { - constructor(); - parse(s: string, options: RRuleString.Options): RRuleSet | RRule; - } - - namespace RRuleString { - interface Options { - dtstart: Date; - cache: boolean; - unfold: boolean; - forceset: boolean; - compatible: boolean; - ignoretz: boolean; - tzinfos: any; - } - - const DEFAULT_OPTIONS: Options; - } - - const rrulestr: RRuleString; - }