rrule-rust 3.0.0-alpha.6 → 3.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/datetime.d.ts +32 -18
- package/dist/browser/datetime.js +115 -59
- package/dist/browser/dtstart.d.ts +14 -13
- package/dist/browser/dtstart.js +3 -9
- package/dist/browser/rrule-set.d.ts +38 -37
- package/dist/browser/rrule-set.js +3 -4
- package/dist/browser/rrule.d.ts +26 -25
- package/dist/browser/rrule.js +4 -6
- package/dist/node/datetime.d.ts +32 -18
- package/dist/node/datetime.js +115 -59
- package/dist/node/dtstart.d.ts +14 -13
- package/dist/node/dtstart.js +2 -8
- package/dist/node/rrule-set.d.ts +38 -37
- package/dist/node/rrule-set.js +2 -3
- package/dist/node/rrule.d.ts +26 -25
- package/dist/node/rrule.js +3 -5
- package/package.json +15 -15
package/dist/node/datetime.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export interface DateLike {
|
|
2
|
+
readonly year: number;
|
|
3
|
+
readonly month: number;
|
|
4
|
+
readonly day: number;
|
|
5
|
+
}
|
|
1
6
|
export interface DateTimeLike {
|
|
2
7
|
readonly year: number;
|
|
3
8
|
readonly month: number;
|
|
@@ -7,55 +12,64 @@ export interface DateTimeLike {
|
|
|
7
12
|
readonly second: number;
|
|
8
13
|
readonly utc: boolean;
|
|
9
14
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
15
|
+
export interface Time {
|
|
16
|
+
readonly hour: number;
|
|
17
|
+
readonly minute: number;
|
|
18
|
+
readonly second: number;
|
|
19
|
+
readonly utc: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ToPlainDateTimeOptions {
|
|
12
22
|
stripUtc?: boolean;
|
|
13
23
|
}
|
|
14
24
|
/**
|
|
15
25
|
* Represents a date and time. Either local or UTC.
|
|
16
26
|
*/
|
|
17
|
-
export declare class DateTime
|
|
18
|
-
private readonly
|
|
27
|
+
export declare class DateTime<T extends Time | undefined> {
|
|
28
|
+
private readonly state;
|
|
19
29
|
private constructor();
|
|
20
30
|
get year(): number;
|
|
21
31
|
get month(): number;
|
|
22
32
|
get day(): number;
|
|
23
|
-
get
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
get time(): T;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new DateTime object from the given date and time components.
|
|
36
|
+
*/
|
|
37
|
+
static create(year: number, month: number, day: number): DateTime<undefined>;
|
|
38
|
+
static create(year: number, month: number, day: number, hour: number, minute: number, second: number, utc: boolean): DateTime<Time>;
|
|
27
39
|
/**
|
|
28
40
|
* Creates a new DateTime object from the given date and time components.
|
|
29
41
|
*/
|
|
30
|
-
static
|
|
42
|
+
static date(year: number, month: number, day: number): DateTime<undefined>;
|
|
31
43
|
/**
|
|
32
44
|
* This method is shorthand for `DateTime.create` with `utc` set to `false`.
|
|
33
45
|
*/
|
|
34
|
-
static local(year: number, month: number, day: number, hour: number, minute: number, second: number): DateTime
|
|
46
|
+
static local(year: number, month: number, day: number, hour: number, minute: number, second: number): DateTime<Time>;
|
|
35
47
|
/**
|
|
36
48
|
* This method is shorthand for `DateTime.create` with `utc` set to `true`.
|
|
37
49
|
*/
|
|
38
|
-
static utc(year: number, month: number, day: number, hour: number, minute: number, second: number): DateTime
|
|
50
|
+
static utc(year: number, month: number, day: number, hour: number, minute: number, second: number): DateTime<Time>;
|
|
39
51
|
/**
|
|
40
52
|
* Creates a new DateTime object from the given plain object.
|
|
41
53
|
*/
|
|
42
|
-
static fromPlain(plain: DateTimeLike): DateTime
|
|
54
|
+
static fromPlain(plain: DateTimeLike): DateTime<Time>;
|
|
55
|
+
static fromPlain(plain: DateLike): DateTime<undefined>;
|
|
43
56
|
/**
|
|
44
57
|
* Creates a new DateTime object from provided string representation of a date according to RFC 5545.
|
|
45
58
|
*/
|
|
46
|
-
static fromString(str: string): DateTime
|
|
59
|
+
static fromString(str: string): DateTime<Time> | DateTime<undefined>;
|
|
47
60
|
/**
|
|
48
61
|
* Converts DateTime into a plain object.
|
|
49
62
|
*/
|
|
50
|
-
toPlain(options
|
|
63
|
+
toPlain<DTL extends DateTimeLike>(options?: ToPlainDateTimeOptions & {
|
|
51
64
|
stripUtc: false;
|
|
52
|
-
}
|
|
53
|
-
toPlain(options
|
|
65
|
+
}): DTL;
|
|
66
|
+
toPlain<DTL extends Omit<DateTimeLike, 'utc'>>(options?: ToPlainDateTimeOptions & {
|
|
54
67
|
stripUtc: true;
|
|
55
|
-
}
|
|
56
|
-
toPlain():
|
|
68
|
+
}): DTL;
|
|
69
|
+
toPlain<DTL extends DateLike>(): DTL;
|
|
57
70
|
/**
|
|
58
71
|
* Converts DateTime into ISO 8601 string:
|
|
72
|
+
* * `YYYYMMDD` for date only
|
|
59
73
|
* - `YYYYMMDDTHHMMSSZ` for UTC
|
|
60
74
|
* - `YYYYMMDDTHHMMSS` for local
|
|
61
75
|
*/
|
package/dist/node/datetime.js
CHANGED
|
@@ -6,41 +6,64 @@ exports.DateTime = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
class DateTime {
|
|
8
8
|
constructor(numeric) {
|
|
9
|
-
this.
|
|
9
|
+
this.state = {
|
|
10
|
+
numeric,
|
|
11
|
+
};
|
|
10
12
|
}
|
|
11
13
|
get year() {
|
|
12
|
-
return Math.floor(this.numeric / 100000000000);
|
|
14
|
+
return (this.state.year ??= Math.floor(this.state.numeric / 100000000000));
|
|
13
15
|
}
|
|
14
16
|
get month() {
|
|
15
|
-
return Math.floor((this.numeric / 1000000000) % 100);
|
|
17
|
+
return (this.state.month ??= Math.floor((this.state.numeric / 1000000000) % 100));
|
|
16
18
|
}
|
|
17
19
|
get day() {
|
|
18
|
-
return Math.floor((this.numeric / 10000000) % 100);
|
|
19
|
-
}
|
|
20
|
-
get hour() {
|
|
21
|
-
return Math.floor((this.numeric / 100000) % 100);
|
|
22
|
-
}
|
|
23
|
-
get minute() {
|
|
24
|
-
return Math.floor((this.numeric / 1000) % 100);
|
|
20
|
+
return (this.state.day ??= Math.floor((this.state.numeric / 10000000) % 100));
|
|
25
21
|
}
|
|
26
|
-
get
|
|
27
|
-
return
|
|
22
|
+
get time() {
|
|
23
|
+
// return cached time if available
|
|
24
|
+
if ('time' in this.state) {
|
|
25
|
+
return this.state.time;
|
|
26
|
+
}
|
|
27
|
+
const type = this.state.numeric % 10; // 0 – non utc, 1 – utc, 2 – date only
|
|
28
|
+
if (type == 2) {
|
|
29
|
+
// if it's date only, return undefined and cache it in state
|
|
30
|
+
return (this.state.time ??= undefined);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// otherwise compute it from numeric representation and cache it in state
|
|
34
|
+
return (this.state.time ??= {
|
|
35
|
+
hour: Math.floor((this.state.numeric / 100000) % 100),
|
|
36
|
+
minute: Math.floor((this.state.numeric / 1000) % 100),
|
|
37
|
+
second: Math.floor((this.state.numeric / 10) % 100),
|
|
38
|
+
utc: this.state.numeric % 10 == 1,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
28
41
|
}
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
static create(year, month, day, hour, minute, second, utc) {
|
|
43
|
+
let numeric = year * 100000000000 + month * 1000000000 + day * 10000000;
|
|
44
|
+
if (hour !== undefined &&
|
|
45
|
+
minute !== undefined &&
|
|
46
|
+
second !== undefined &&
|
|
47
|
+
utc !== undefined) {
|
|
48
|
+
numeric += hour * 100000;
|
|
49
|
+
numeric += minute * 1000;
|
|
50
|
+
numeric += second * 10;
|
|
51
|
+
numeric += utc ? 1 : 0;
|
|
52
|
+
return new DateTime(numeric);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
numeric += 100000;
|
|
56
|
+
numeric += 1000;
|
|
57
|
+
numeric += 10;
|
|
58
|
+
numeric += 2;
|
|
59
|
+
return new DateTime(numeric);
|
|
60
|
+
}
|
|
31
61
|
}
|
|
32
62
|
/**
|
|
33
63
|
* Creates a new DateTime object from the given date and time components.
|
|
34
64
|
*/
|
|
35
|
-
static
|
|
36
|
-
|
|
37
|
-
month * 1000000000 +
|
|
38
|
-
day * 10000000 +
|
|
39
|
-
hour * 100000 +
|
|
40
|
-
minute * 1000 +
|
|
41
|
-
second * 10 +
|
|
42
|
-
(utc ? 1 : 0);
|
|
43
|
-
return new DateTime(numeric);
|
|
65
|
+
static date(year, month, day) {
|
|
66
|
+
return this.create(year, month, day);
|
|
44
67
|
}
|
|
45
68
|
/**
|
|
46
69
|
* This method is shorthand for `DateTime.create` with `utc` set to `false`.
|
|
@@ -54,69 +77,102 @@ class DateTime {
|
|
|
54
77
|
static utc(year, month, day, hour, minute, second) {
|
|
55
78
|
return DateTime.create(year, month, day, hour, minute, second, true);
|
|
56
79
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Creates a new DateTime object from the given plain object.
|
|
59
|
-
*/
|
|
60
80
|
static fromPlain(plain) {
|
|
61
|
-
|
|
81
|
+
if ('hour' in plain) {
|
|
82
|
+
return DateTime.create(plain.year, plain.month, plain.day, plain.hour, plain.minute, plain.second, plain.utc);
|
|
83
|
+
}
|
|
84
|
+
return DateTime.create(plain.year, plain.month, plain.day);
|
|
62
85
|
}
|
|
63
86
|
/**
|
|
64
87
|
* Creates a new DateTime object from provided string representation of a date according to RFC 5545.
|
|
65
88
|
*/
|
|
89
|
+
// TODO: add template expression
|
|
66
90
|
static fromString(str) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
throw typeError;
|
|
91
|
+
if (!(str.length === 8 || (str.length <= 16 && str.length >= 15))) {
|
|
92
|
+
throw new TypeError('Invalid date time string');
|
|
70
93
|
}
|
|
71
94
|
const year = parseInt(str.slice(0, 4));
|
|
72
95
|
const month = parseInt(str.slice(4, 6));
|
|
73
96
|
const day = parseInt(str.slice(6, 8));
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (isNaN(year) ||
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
let hour = undefined;
|
|
98
|
+
let minute = undefined;
|
|
99
|
+
let second = undefined;
|
|
100
|
+
let utc = undefined;
|
|
101
|
+
if (isNaN(year) || isNaN(month) || isNaN(day)) {
|
|
102
|
+
throw new TypeError('Invalid date');
|
|
103
|
+
}
|
|
104
|
+
if (str.length > 8) {
|
|
105
|
+
hour = parseInt(str.slice(9, 11));
|
|
106
|
+
minute = parseInt(str.slice(11, 13));
|
|
107
|
+
second = parseInt(str.slice(13, 15));
|
|
108
|
+
utc = str.endsWith('Z');
|
|
109
|
+
if (isNaN(hour) || isNaN(minute) || isNaN(second)) {
|
|
110
|
+
throw new TypeError('Invalid time');
|
|
111
|
+
}
|
|
112
|
+
return DateTime.create(year, month, day, hour, minute, second, utc);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return DateTime.create(year, month, day);
|
|
85
116
|
}
|
|
86
|
-
return DateTime.create(year, month, day, hour, minute, second, utc);
|
|
87
117
|
}
|
|
88
118
|
/** @internal */
|
|
89
119
|
static fromNumeric(numeric) {
|
|
90
120
|
return new DateTime(numeric);
|
|
91
121
|
}
|
|
92
122
|
toPlain(options) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
123
|
+
let plain;
|
|
124
|
+
if (this.time) {
|
|
125
|
+
plain = options?.stripUtc
|
|
126
|
+
? {
|
|
127
|
+
year: this.year,
|
|
128
|
+
month: this.month,
|
|
129
|
+
day: this.day,
|
|
130
|
+
hour: this.time.hour,
|
|
131
|
+
minute: this.time.minute,
|
|
132
|
+
second: this.time.second,
|
|
133
|
+
}
|
|
134
|
+
: {
|
|
135
|
+
year: this.year,
|
|
136
|
+
month: this.month,
|
|
137
|
+
day: this.day,
|
|
138
|
+
hour: this.time.hour,
|
|
139
|
+
minute: this.time.minute,
|
|
140
|
+
second: this.time.second,
|
|
141
|
+
utc: this.time.utc,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
plain = {
|
|
146
|
+
year: this.year,
|
|
147
|
+
month: this.month,
|
|
148
|
+
day: this.day,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return plain;
|
|
102
152
|
}
|
|
103
153
|
/**
|
|
104
154
|
* Converts DateTime into ISO 8601 string:
|
|
155
|
+
* * `YYYYMMDD` for date only
|
|
105
156
|
* - `YYYYMMDDTHHMMSSZ` for UTC
|
|
106
157
|
* - `YYYYMMDDTHHMMSS` for local
|
|
107
158
|
*/
|
|
108
159
|
toString() {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
160
|
+
let str = this.year.toString().padStart(4, '0') +
|
|
161
|
+
this.month.toString().padStart(2, '0') +
|
|
162
|
+
this.day.toString().padStart(2, '0');
|
|
163
|
+
if (this.time) {
|
|
164
|
+
str +=
|
|
165
|
+
'T' +
|
|
166
|
+
this.time.hour.toString().padStart(2, '0') +
|
|
167
|
+
this.time.minute.toString().padStart(2, '0') +
|
|
168
|
+
this.time.second.toString().padStart(2, '0') +
|
|
169
|
+
(this.time.utc ? 'Z' : '');
|
|
170
|
+
}
|
|
171
|
+
return str;
|
|
116
172
|
}
|
|
117
173
|
/** @internal */
|
|
118
174
|
toNumeric() {
|
|
119
|
-
return this.numeric;
|
|
175
|
+
return this.state.numeric;
|
|
120
176
|
}
|
|
121
177
|
}
|
|
122
178
|
exports.DateTime = DateTime;
|
package/dist/node/dtstart.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { DateTime, type DateTimeLike } from './datetime';
|
|
2
|
-
export interface DtStartOptions {
|
|
3
|
-
datetime:
|
|
1
|
+
import { DateTime, type Time, type DateTimeLike, type DateLike } from './datetime';
|
|
2
|
+
export interface DtStartOptions<DT extends DateTime<Time> | DateTime<undefined>> {
|
|
3
|
+
datetime: DT;
|
|
4
4
|
tzid?: string;
|
|
5
5
|
}
|
|
6
|
-
export interface DtStartLike {
|
|
7
|
-
datetime:
|
|
6
|
+
export interface DtStartLike<DT extends DateTimeLike | DateLike> {
|
|
7
|
+
datetime: DT;
|
|
8
8
|
tzid?: string;
|
|
9
9
|
}
|
|
10
|
-
export declare class DtStart {
|
|
11
|
-
readonly datetime:
|
|
10
|
+
export declare class DtStart<DT extends DateTime<Time> | DateTime<undefined> = DateTime<Time>> {
|
|
11
|
+
readonly datetime: DT;
|
|
12
12
|
readonly tzid?: string;
|
|
13
|
-
constructor(datetime: DateTime
|
|
14
|
-
constructor(options: DtStartOptions);
|
|
15
|
-
static fromPlain(plain: DtStartLike): DtStart
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
constructor(datetime: DateTime<Time> | DateTime<undefined>, tzid?: string);
|
|
14
|
+
constructor(options: DtStartOptions<DT>);
|
|
15
|
+
static fromPlain(plain: DtStartLike<DateTimeLike>): DtStart<DateTime<Time>>;
|
|
16
|
+
static fromPlain(plain: DtStartLike<DateLike>): DtStart<DateTime<undefined>>;
|
|
17
|
+
setTzid(tzid: string | undefined): DtStart<DT>;
|
|
18
|
+
setDatetime<NDT extends DateTime<Time> | DateTime<undefined>>(datetime: NDT): DtStart<NDT>;
|
|
19
|
+
toPlain<DTL extends DateTimeLike | DateLike = DT extends DateTime<Time> ? DateTimeLike : DateLike>(): DtStartLike<DTL>;
|
|
19
20
|
}
|
package/dist/node/dtstart.js
CHANGED
|
@@ -20,16 +20,10 @@ class DtStart {
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
setTzid(tzid) {
|
|
23
|
-
return new DtStart(
|
|
24
|
-
datetime: this.datetime,
|
|
25
|
-
tzid,
|
|
26
|
-
});
|
|
23
|
+
return new DtStart(this.datetime, tzid);
|
|
27
24
|
}
|
|
28
25
|
setDatetime(datetime) {
|
|
29
|
-
return new DtStart(
|
|
30
|
-
datetime: datetime,
|
|
31
|
-
tzid: this.tzid,
|
|
32
|
-
});
|
|
26
|
+
return new DtStart(datetime, this.tzid);
|
|
33
27
|
}
|
|
34
28
|
toPlain() {
|
|
35
29
|
return {
|
package/dist/node/rrule-set.d.ts
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
1
|
import { RRule, type RRuleLike } from './rrule';
|
|
2
|
-
import { DateTime, type DateTimeLike } from './datetime';
|
|
2
|
+
import { type Time, DateTime, type DateTimeLike, type DateLike } from './datetime';
|
|
3
3
|
import { DtStart, type DtStartLike } from './dtstart';
|
|
4
|
-
export interface RRuleSetOptions {
|
|
5
|
-
readonly dtstart: DtStart
|
|
6
|
-
readonly rrules?: readonly RRule[];
|
|
7
|
-
readonly exrules?: readonly RRule[];
|
|
8
|
-
readonly exdates?: readonly
|
|
9
|
-
readonly rdates?: readonly
|
|
4
|
+
export interface RRuleSetOptions<DT extends DateTime<Time> | DateTime<undefined> = DateTime<Time>> {
|
|
5
|
+
readonly dtstart: DtStart<DT>;
|
|
6
|
+
readonly rrules?: readonly RRule<DT>[];
|
|
7
|
+
readonly exrules?: readonly RRule<DT>[];
|
|
8
|
+
readonly exdates?: readonly DT[];
|
|
9
|
+
readonly rdates?: readonly DT[];
|
|
10
10
|
}
|
|
11
|
-
export interface RRuleSetLike {
|
|
12
|
-
readonly dtstart: DtStartLike
|
|
13
|
-
readonly rrules: readonly RRuleLike[];
|
|
14
|
-
readonly exrules: readonly RRuleLike[];
|
|
15
|
-
readonly exdates: readonly
|
|
16
|
-
readonly rdates: readonly
|
|
11
|
+
export interface RRuleSetLike<DT extends DateTimeLike | DateLike> {
|
|
12
|
+
readonly dtstart: DtStartLike<DT>;
|
|
13
|
+
readonly rrules: readonly RRuleLike<DT>[];
|
|
14
|
+
readonly exrules: readonly RRuleLike<DT>[];
|
|
15
|
+
readonly exdates: readonly DT[];
|
|
16
|
+
readonly rdates: readonly DT[];
|
|
17
17
|
}
|
|
18
|
-
export declare class RRuleSet implements Iterable<DateTime> {
|
|
19
|
-
readonly dtstart: DtStart
|
|
20
|
-
readonly rrules: readonly RRule[];
|
|
21
|
-
readonly exrules: readonly RRule[];
|
|
22
|
-
readonly exdates: readonly
|
|
23
|
-
readonly rdates: readonly
|
|
24
|
-
constructor(dtstart: DtStart);
|
|
25
|
-
constructor(options: RRuleSetOptions);
|
|
18
|
+
export declare class RRuleSet<DT extends DateTime<Time> | DateTime<undefined>> implements Iterable<DateTime<Time> | DateTime<undefined>> {
|
|
19
|
+
readonly dtstart: DtStart<DT>;
|
|
20
|
+
readonly rrules: readonly RRule<DT>[];
|
|
21
|
+
readonly exrules: readonly RRule<DT>[];
|
|
22
|
+
readonly exdates: readonly DT[];
|
|
23
|
+
readonly rdates: readonly DT[];
|
|
24
|
+
constructor(dtstart: DtStart<DT>);
|
|
25
|
+
constructor(options: RRuleSetOptions<DT>);
|
|
26
26
|
/**
|
|
27
27
|
* Parses a string into an RRuleSet.
|
|
28
28
|
*/
|
|
29
|
-
static parse(str: string): RRuleSet
|
|
30
|
-
static fromPlain(plain: RRuleSetLike): RRuleSet
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
static parse<DT extends DateTime<Time> | DateTime<undefined>>(str: string): RRuleSet<DT>;
|
|
30
|
+
static fromPlain(plain: RRuleSetLike<DateTimeLike>): RRuleSet<DateTime<Time>>;
|
|
31
|
+
static fromPlain(plain: RRuleSetLike<DateLike>): RRuleSet<DateTime<undefined>>;
|
|
32
|
+
setDtstart(dtstart: DtStart<DT>): RRuleSet<DT>;
|
|
33
|
+
addRrule<RRDT extends DT>(rrule: RRule<RRDT>): RRuleSet<DT>;
|
|
34
|
+
setRrules(rrules: readonly RRule<DT>[]): RRuleSet<DT>;
|
|
35
|
+
addExrule(rrule: RRule<DT>): RRuleSet<DT>;
|
|
36
|
+
setExrules(rrules: readonly RRule<DT>[]): RRuleSet<DT>;
|
|
37
|
+
addExdate(datetime: DT): RRuleSet<DT>;
|
|
38
|
+
setExdates(datetimes: readonly DT[]): RRuleSet<DT>;
|
|
39
|
+
addRdate(datetime: DT): RRuleSet<DT>;
|
|
40
|
+
setRdates(datetimes: readonly DT[]): RRuleSet<DT>;
|
|
40
41
|
/**
|
|
41
42
|
* Returns all the occurrences of the rrule.
|
|
42
43
|
*
|
|
43
44
|
* @param limit - The maximum number of occurrences to return.
|
|
44
45
|
*/
|
|
45
|
-
all(limit?: number):
|
|
46
|
+
all(limit?: number): DT[];
|
|
46
47
|
/**
|
|
47
48
|
* Returns all the occurrences of the rrule between after and before.
|
|
48
49
|
*
|
|
@@ -50,18 +51,18 @@ export declare class RRuleSet implements Iterable<DateTime> {
|
|
|
50
51
|
* @param before - The upper bound date.
|
|
51
52
|
* @param inclusive - Whether to include after and before in the list of occurrences.
|
|
52
53
|
*/
|
|
53
|
-
between(after:
|
|
54
|
+
between(after: DT, before: DT, inclusive?: boolean): DT[];
|
|
54
55
|
/**
|
|
55
56
|
* Sets the RRuleSet from a string.
|
|
56
57
|
*
|
|
57
58
|
* @param str - The string to parse.
|
|
58
59
|
*/
|
|
59
|
-
setFromString(str: string): RRuleSet
|
|
60
|
+
setFromString<NDT extends DateTime<Time> | DateTime<undefined> = DT>(str: string): RRuleSet<NDT>;
|
|
60
61
|
toString(): string;
|
|
61
62
|
/**
|
|
62
63
|
* Converts the RRuleSet to a plain object.
|
|
63
64
|
*/
|
|
64
|
-
toPlain(): RRuleSetLike
|
|
65
|
-
[Symbol.iterator](): Iterator<
|
|
65
|
+
toPlain(): RRuleSetLike<DT extends DateTime<Time> ? DateTimeLike : DateLike>;
|
|
66
|
+
[Symbol.iterator](): Iterator<DT, any, any>;
|
|
66
67
|
private toOptions;
|
|
67
68
|
}
|
package/dist/node/rrule-set.js
CHANGED
|
@@ -26,8 +26,7 @@ class RRuleSet {
|
|
|
26
26
|
* Parses a string into an RRuleSet.
|
|
27
27
|
*/
|
|
28
28
|
static parse(str) {
|
|
29
|
-
|
|
30
|
-
return this.fromRust(rust);
|
|
29
|
+
return this.fromRust(lib_1.RRuleSet.parse(str));
|
|
31
30
|
}
|
|
32
31
|
static fromPlain(plain) {
|
|
33
32
|
return new RRuleSet({
|
|
@@ -143,7 +142,7 @@ class RRuleSet {
|
|
|
143
142
|
* @internal
|
|
144
143
|
*/
|
|
145
144
|
toRust() {
|
|
146
|
-
this.rust ??= new lib_1.RRuleSet(this.dtstart.datetime.toNumeric(), this.dtstart.tzid, this.rrules.map((rrule) => rrule.toRust()), this.exrules.map((rrule) => rrule.toRust()), this.exdates.map((datetime) => datetime.toNumeric()), this.rdates.map((datetime) => datetime.toNumeric()));
|
|
145
|
+
this.rust ??= new lib_1.RRuleSet(this.dtstart.datetime.toNumeric(), this.dtstart.tzid, undefined, this.rrules.map((rrule) => rrule.toRust()), this.exrules.map((rrule) => rrule.toRust()), this.exdates.map((datetime) => datetime.toNumeric()), this.rdates.map((datetime) => datetime.toNumeric()));
|
|
147
146
|
return this.rust;
|
|
148
147
|
}
|
|
149
148
|
toString() {
|
package/dist/node/rrule.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateTime, type DateTimeLike } from './datetime';
|
|
1
|
+
import { type Time, DateTime, type DateTimeLike, type DateLike } from './datetime';
|
|
2
2
|
export interface NWeekday {
|
|
3
3
|
/**
|
|
4
4
|
* If set, this represents the nth occurrence of the weekday.
|
|
@@ -41,11 +41,11 @@ export declare enum Weekday {
|
|
|
41
41
|
Saturday = 5,
|
|
42
42
|
Sunday = 6
|
|
43
43
|
}
|
|
44
|
-
export interface RRuleOptions {
|
|
44
|
+
export interface RRuleOptions<DT extends DateTime<Time> | DateTime<undefined>> {
|
|
45
45
|
readonly frequency: Frequency;
|
|
46
46
|
readonly interval?: number;
|
|
47
47
|
readonly count?: number;
|
|
48
|
-
readonly until?:
|
|
48
|
+
readonly until?: DT;
|
|
49
49
|
readonly byWeekday?: readonly (NWeekday | Weekday)[];
|
|
50
50
|
readonly byHour?: readonly number[];
|
|
51
51
|
readonly byMinute?: readonly number[];
|
|
@@ -57,11 +57,11 @@ export interface RRuleOptions {
|
|
|
57
57
|
readonly byYearday?: readonly number[];
|
|
58
58
|
readonly weekstart?: Weekday;
|
|
59
59
|
}
|
|
60
|
-
export interface RRuleLike {
|
|
60
|
+
export interface RRuleLike<DT extends DateTimeLike | DateLike> {
|
|
61
61
|
readonly frequency: Frequency;
|
|
62
62
|
readonly interval?: number;
|
|
63
63
|
readonly count?: number;
|
|
64
|
-
readonly until?:
|
|
64
|
+
readonly until?: DT;
|
|
65
65
|
readonly byWeekday: readonly (NWeekday | Weekday)[];
|
|
66
66
|
readonly byHour: readonly number[];
|
|
67
67
|
readonly byMinute: readonly number[];
|
|
@@ -73,10 +73,10 @@ export interface RRuleLike {
|
|
|
73
73
|
readonly byYearday: readonly number[];
|
|
74
74
|
readonly weekstart?: Weekday;
|
|
75
75
|
}
|
|
76
|
-
export declare class RRule {
|
|
76
|
+
export declare class RRule<DT extends DateTime<Time> | DateTime<undefined> = DateTime<Time>> {
|
|
77
77
|
readonly frequency: Frequency;
|
|
78
78
|
readonly interval?: number;
|
|
79
|
-
readonly until?:
|
|
79
|
+
readonly until?: DT;
|
|
80
80
|
readonly count?: number;
|
|
81
81
|
readonly byWeekday: readonly (NWeekday | Weekday)[];
|
|
82
82
|
readonly byHour: readonly number[];
|
|
@@ -89,27 +89,28 @@ export declare class RRule {
|
|
|
89
89
|
readonly byYearday: readonly number[];
|
|
90
90
|
readonly weekstart?: Weekday;
|
|
91
91
|
constructor(frequency: Frequency);
|
|
92
|
-
constructor(options: RRuleOptions);
|
|
92
|
+
constructor(options: RRuleOptions<DT>);
|
|
93
93
|
/**
|
|
94
94
|
* Parses a string into an RRule.
|
|
95
95
|
*/
|
|
96
|
-
static parse(str: string): RRule
|
|
97
|
-
static fromPlain(rrule: RRuleLike): RRule
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
96
|
+
static parse<DT extends DateTime<Time> | DateTime<undefined>>(str: string): RRule<DT>;
|
|
97
|
+
static fromPlain(rrule: RRuleLike<DateTimeLike>): RRule<DateTime<Time>>;
|
|
98
|
+
static fromPlain(rrule: RRuleLike<DateLike>): RRule<DateTime<undefined>>;
|
|
99
|
+
setFrequency(frequency: Frequency): RRule<DT>;
|
|
100
|
+
setInterval(interval: number): RRule<DT>;
|
|
101
|
+
setCount(count: number): RRule<DT>;
|
|
102
|
+
setByWeekday(weekdays: readonly (NWeekday | Weekday)[]): RRule<DT>;
|
|
103
|
+
setByHour(hours: readonly number[]): RRule<DT>;
|
|
104
|
+
setByMinute(minutes: readonly number[]): RRule<DT>;
|
|
105
|
+
setBySecond(seconds: readonly number[]): RRule<DT>;
|
|
106
|
+
setByMonthday(days: readonly number[]): RRule<DT>;
|
|
107
|
+
setBySetpos(poses: readonly number[]): RRule<DT>;
|
|
108
|
+
setByMonth(months: readonly Month[]): RRule<DT>;
|
|
109
|
+
setByWeekno(weekNumbers: readonly number[]): RRule<DT>;
|
|
110
|
+
setByYearday(days: readonly number[]): RRule<DT>;
|
|
111
|
+
setWeekstart(day: Weekday): RRule<DT>;
|
|
112
|
+
setUntil(until: DT): RRule<DT>;
|
|
112
113
|
toString(): string;
|
|
113
|
-
toPlain(): RRuleLike
|
|
114
|
+
toPlain(): RRuleLike<DT extends DateTime<Time> ? DateTimeLike : DateLike>;
|
|
114
115
|
private toOptions;
|
|
115
116
|
}
|
package/dist/node/rrule.js
CHANGED
|
@@ -43,9 +43,7 @@ class RRule {
|
|
|
43
43
|
if (typeof frequencyOrOptions === 'object' && frequencyOrOptions !== null) {
|
|
44
44
|
this.frequency = frequencyOrOptions.frequency;
|
|
45
45
|
this.interval = frequencyOrOptions.interval;
|
|
46
|
-
this.until =
|
|
47
|
-
frequencyOrOptions.until &&
|
|
48
|
-
datetime_1.DateTime.fromPlain(frequencyOrOptions.until);
|
|
46
|
+
this.until = frequencyOrOptions.until;
|
|
49
47
|
this.count = frequencyOrOptions.count;
|
|
50
48
|
this.byWeekday = frequencyOrOptions.byWeekday ?? [];
|
|
51
49
|
this.byHour = frequencyOrOptions.byHour ?? [];
|
|
@@ -158,8 +156,8 @@ class RRule {
|
|
|
158
156
|
setWeekstart(day) {
|
|
159
157
|
return new RRule({ ...this.toOptions(), weekstart: day });
|
|
160
158
|
}
|
|
161
|
-
setUntil(
|
|
162
|
-
return new RRule({ ...this.toOptions(), until
|
|
159
|
+
setUntil(until) {
|
|
160
|
+
return new RRule({ ...this.toOptions(), until });
|
|
163
161
|
}
|
|
164
162
|
toString() {
|
|
165
163
|
return this.toRust().toString();
|