-
Notifications
You must be signed in to change notification settings - Fork 1
/
interval.d.ts
101 lines (101 loc) · 3.42 KB
/
interval.d.ts
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import * as moment from 'moment';
/**
* Class to describe ISO 8601 time intervals, including the repeating functionality.
*
* The class is primarily backed by moment.js and contains the start, end, duration,
* and number of repetitions found in the ISO8601 string or overridden in the constructor.
* Typical usage of the class is to construct one with a ISO8601 string in the constructor.
*/
export declare class Interval {
private _start;
private _end;
private _duration;
private _recurs;
private _repetitions;
private _first;
private _last;
private _infiniteSpan;
/**
* The start of all intervals, if this is a repeating interval
* then this is the start of the first repitition.
* Returns an invalid moment if there are infinite negative repetitions
*/
start: moment.Moment;
/**
* The end of all intervals, if this is a repeating interval
* then this is then end of the last repitition.
* Returns an invalid moment if there are infinite positive repetitions
*/
end: moment.Moment;
/**
* The duration of a single repition of the interval
*/
duration: moment.Duration;
/**
* True if the schedule is infintely long
* @returns {boolean}
*/
isInfinite: boolean;
/**
* True if the schedule progresses infinitely in the positive
* @returns {boolean}
*/
isInfinitePositive: boolean;
/**
* True if the schedule progresses infinitely in the negative
* @returns {boolean}
*/
isInfiniteNegative: boolean;
/**
* True if the schedule repeats (has more than one occurrence)
* @returns {boolean}
*/
isRepeating: boolean;
/**
* The number of repetitions
* @returns {number}
*/
repetitions: number;
/**
* Index of the first occurrence,
* Number.NEGATIVE_INFINITY if the interval is reverse repeating indefinitely
* @returns {number}
*/
first: number;
/**
* Index of the last occurrence,
* Number.POSITIVE_INFINITY if the interval is forward repeating indefinitely
* @returns {number}
*/
last: number;
/**
* @param interval either ISO8601 string or an instance to copy
* @param repetitions the number of times to repeat, null for infinite
*/
constructor(interval?: string | Interval, repetitions?: number);
occurrence(idx: number): moment.Moment;
/**
* Get a list of the occurrences for an interval,
* if no parameters are supplied then all occurrences are returned.
*
* @param {number} [from] the starting occurrence index
* @param {number} [to] the ending occurrence index
* @returns {moment.Moment[]}
*/
slice(from?: number, to?: number): moment.Moment[];
/**
* Get the recurrence (the index of the occurrence) after the supplied time
* @param after Moment or something that it parses (if a number, then in epoc ms)
*/
indexAfter(after: string | number | moment.Moment): number;
indexBefore(before: string | number | moment.Moment): number;
/**
* Get the occurrence happening after the supplied date.
* Throws Error if there is no occurrence after the supplied date
*/
occurrenceAfter(after: string | number | moment.Moment): moment.Moment;
durationBetween(from: number, to: number): moment.Duration;
static extents(intervalList: Interval[]): Interval;
toISOString(): string;
toString(): string;
}