forked from jkbrzt/rrule
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace definitions with one from @types/rrule
- Loading branch information
1 parent
c14e49d
commit e2a63a1
Showing
1 changed file
with
179 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,184 @@ | ||
declare module __RRule { | ||
interface Frequency {} | ||
interface Day {} | ||
type integer = number; | ||
|
||
interface Options { | ||
freq: Frequency; | ||
dtstart?: Date; | ||
interval?: number; | ||
wkst?: Day | integer; | ||
count?: integer; | ||
until?: Date; | ||
bysetpos?: integer | integer[]; | ||
bymonth?: integer | integer[]; | ||
bymonthday?: integer | integer[]; | ||
byyearday?: integer | integer[]; | ||
byweekno?: integer | integer[]; | ||
byweekday?: integer | integer[] | Day | Day[]; | ||
byhour?: integer | integer[]; | ||
byminute?: integer | integer[]; | ||
bysecond?: integer | integer[]; | ||
} | ||
|
||
interface Language {} | ||
|
||
interface Iterator { | ||
(date: Date, i: number): boolean; | ||
} | ||
|
||
module RRule { | ||
export let YEARLY: Frequency; | ||
export let MONTHLY: Frequency; | ||
export let WEEKLY: Frequency; | ||
export let DAILY: Frequency; | ||
export let HOURLY: Frequency; | ||
export let MINUTELY: Frequency; | ||
export let SECONDLY: Frequency; | ||
|
||
export let MO: Day; | ||
export let TU: Day; | ||
export let WE: Day; | ||
export let TH: Day; | ||
export let FR: Day; | ||
export let SA: Day; | ||
export let SU: Day; | ||
} | ||
|
||
class RRule { | ||
options: Options; | ||
origOptions: Options; | ||
constructor(options: Options, noCache?: boolean); | ||
all(iterator?: Iterator): Date[]; | ||
between(after: Date, before: Date, inc?: boolean, iterator?: Iterator): Date[]; | ||
before(dt: Date, inc?: boolean): Date; | ||
// Type definitions for rrule 2.1.0 | ||
// Project: https://github.com/jkbrzt/rrule | ||
// Definitions by: James Bracy <https://github.com/waratuman> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
declare module 'rrule' { | ||
export = RRule; | ||
} | ||
|
||
declare namespace RRule { | ||
|
||
/** | ||
* see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418> | ||
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ... | ||
*/ | ||
interface Options { | ||
freq: RRule.Frequency; | ||
dtstart?: Date; | ||
interval?: number; | ||
wkst?: number | Weekday | ||
count?: number; | ||
until?: Date; | ||
bysetpos?: number | number[]; | ||
bymonth?: number | number[]; | ||
bymonthday?: number | number[]; | ||
byyearday?: number | number[]; | ||
byweekno?: number | number[]; | ||
byweekday?: Weekday | Weekday[] | number | number[]; | ||
byhour?: number | number[]; | ||
byminute?: number | number[]; | ||
bysecond?: number | number[]; | ||
} | ||
|
||
class Weekday { | ||
constructor(weekday: number, n: number); | ||
|
||
nth(n: number): Weekday; | ||
|
||
equals(other: Weekday): boolean; | ||
|
||
toString(): string; | ||
|
||
getJsWeekday(): number; | ||
} | ||
|
||
} | ||
|
||
declare class RRule { | ||
|
||
/** | ||
* @param {Object?} options - see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418> | ||
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ... | ||
* @constructor | ||
*/ | ||
constructor(options: RRule.Options, noCache?: boolean); | ||
|
||
options: RRule.Options; | ||
|
||
origOptions: RRule.Options; | ||
|
||
/** | ||
* 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, index?: number) => 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, inc?: boolean, iterator?: (date: Date, index: number) => 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; | ||
|
||
/** | ||
* Converts the rrule into its string representation | ||
* @see <http://www.ietf.org/rfc/rfc2445.txt> | ||
* @return String | ||
*/ | ||
toString(): string; | ||
static optionsToString(options: Options): string; | ||
static fromString(rfcString: string): RRule; | ||
static parseString(rfcString: string): Options; | ||
toText(gettext?: (token: string) => string, language?: Language): string; | ||
|
||
/** | ||
* Will convert all rules described in nlp:ToText | ||
* to text. | ||
*/ | ||
toText(gettext?: (str: string) => string, language?: any): string; | ||
|
||
isFullyConvertibleToText(): boolean; | ||
static fromText(text: string, language?: Language): RRule; | ||
static parseText(text?: string, language?: Language): Options; | ||
} | ||
|
||
class RRuleSet { | ||
constructor(noCache?: boolean); | ||
rrule(rrule: RRule): any; | ||
rdate(dt: Date): any; | ||
exrule(rrule: RRule): any; | ||
exdate(dt: Date): any; | ||
all(iterator?: Iterator): Date[]; | ||
between(after: Date, before: Date, inc?: boolean, iterator?: Iterator): Date[]; | ||
before(dt: Date, inc?: boolean): Date; | ||
after(dt: Date, inc?: boolean): Date; | ||
} | ||
} | ||
|
||
declare module "rrule-alt" { | ||
export = __RRule; | ||
clone(): RRule; | ||
|
||
} | ||
|
||
declare namespace RRule { | ||
|
||
const FREQUENCIES: "YEARLY" | "MONTHLY" | "WEEKLY" | "DAILY" | "HOURLY" | "MINUTELY" | "SECONDLY"; | ||
|
||
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; | ||
const WE: Weekday; | ||
const TH: Weekday; | ||
const FR: Weekday; | ||
const SA: Weekday; | ||
const SU: Weekday; | ||
|
||
const DEFAULT_OPTIONS: RRule.Options; | ||
|
||
function parseText(text: string, language?: any): RRule.Options; | ||
|
||
function fromText(text: string, language?: any): RRule; | ||
|
||
function optionsToString(options: RRule.Options): string; | ||
|
||
function parseString(rfcString: string): RRule.Options; | ||
|
||
function fromString(value: string): RRule; | ||
|
||
class RRuleSet extends RRule { | ||
/** | ||
* | ||
* @param {Boolean?} noCache | ||
* The same stratagy as RRule on cache, default to false | ||
* @constructor | ||
*/ | ||
constructor(noCache?: boolean); | ||
rrule(rrule: RRule): void; | ||
rdate(date: Date): void; | ||
exrule(rrule: RRule): void; | ||
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; | ||
} | ||
} |