rrule-rust 3.0.0-alpha.6 → 3.0.0-alpha.8

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.
@@ -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 type DateTimeLikeWithoutUtc = Omit<DateTimeLike, 'utc'>;
11
- export interface ToPlainOptions {
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 implements DateTimeLike {
18
- private readonly numeric;
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 hour(): number;
24
- get minute(): number;
25
- get second(): number;
26
- get utc(): boolean;
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 create(year: number, month: number, day: number, hour: number, minute: number, second: number, utc: boolean): DateTime;
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
- } & ToPlainOptions): DateTimeLike;
53
- toPlain(options: {
65
+ }): DTL;
66
+ toPlain<DTL extends Omit<DateTimeLike, 'utc'>>(options?: ToPlainDateTimeOptions & {
54
67
  stripUtc: true;
55
- } & ToPlainOptions): DateTimeLikeWithoutUtc;
56
- toPlain(): DateTimeLike;
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
  */
@@ -3,41 +3,64 @@
3
3
  */
4
4
  export class DateTime {
5
5
  constructor(numeric) {
6
- this.numeric = numeric;
6
+ this.state = {
7
+ numeric,
8
+ };
7
9
  }
8
10
  get year() {
9
- return Math.floor(this.numeric / 100000000000);
11
+ return (this.state.year ??= Math.floor(this.state.numeric / 100000000000));
10
12
  }
11
13
  get month() {
12
- return Math.floor((this.numeric / 1000000000) % 100);
14
+ return (this.state.month ??= Math.floor((this.state.numeric / 1000000000) % 100));
13
15
  }
14
16
  get day() {
15
- return Math.floor((this.numeric / 10000000) % 100);
16
- }
17
- get hour() {
18
- return Math.floor((this.numeric / 100000) % 100);
19
- }
20
- get minute() {
21
- return Math.floor((this.numeric / 1000) % 100);
17
+ return (this.state.day ??= Math.floor((this.state.numeric / 10000000) % 100));
22
18
  }
23
- get second() {
24
- return Math.floor((this.numeric / 10) % 100);
19
+ get time() {
20
+ // return cached time if available
21
+ if ('time' in this.state) {
22
+ return this.state.time;
23
+ }
24
+ const type = this.state.numeric % 10; // 0 – non utc, 1 – utc, 2 – date only
25
+ if (type == 2) {
26
+ // if it's date only, return undefined and cache it in state
27
+ return (this.state.time ??= undefined);
28
+ }
29
+ else {
30
+ // otherwise compute it from numeric representation and cache it in state
31
+ return (this.state.time ??= {
32
+ hour: Math.floor((this.state.numeric / 100000) % 100),
33
+ minute: Math.floor((this.state.numeric / 1000) % 100),
34
+ second: Math.floor((this.state.numeric / 10) % 100),
35
+ utc: this.state.numeric % 10 == 1,
36
+ });
37
+ }
25
38
  }
26
- get utc() {
27
- return this.numeric % 10 == 1;
39
+ static create(year, month, day, hour, minute, second, utc) {
40
+ let numeric = year * 100000000000 + month * 1000000000 + day * 10000000;
41
+ if (hour !== undefined &&
42
+ minute !== undefined &&
43
+ second !== undefined &&
44
+ utc !== undefined) {
45
+ numeric += hour * 100000;
46
+ numeric += minute * 1000;
47
+ numeric += second * 10;
48
+ numeric += utc ? 1 : 0;
49
+ return new DateTime(numeric);
50
+ }
51
+ else {
52
+ numeric += 100000;
53
+ numeric += 1000;
54
+ numeric += 10;
55
+ numeric += 2;
56
+ return new DateTime(numeric);
57
+ }
28
58
  }
29
59
  /**
30
60
  * Creates a new DateTime object from the given date and time components.
31
61
  */
32
- static create(year, month, day, hour, minute, second, utc) {
33
- const numeric = year * 100000000000 +
34
- month * 1000000000 +
35
- day * 10000000 +
36
- hour * 100000 +
37
- minute * 1000 +
38
- second * 10 +
39
- (utc ? 1 : 0);
40
- return new DateTime(numeric);
62
+ static date(year, month, day) {
63
+ return this.create(year, month, day);
41
64
  }
42
65
  /**
43
66
  * This method is shorthand for `DateTime.create` with `utc` set to `false`.
@@ -51,68 +74,101 @@ export class DateTime {
51
74
  static utc(year, month, day, hour, minute, second) {
52
75
  return DateTime.create(year, month, day, hour, minute, second, true);
53
76
  }
54
- /**
55
- * Creates a new DateTime object from the given plain object.
56
- */
57
77
  static fromPlain(plain) {
58
- return DateTime.create(plain.year, plain.month, plain.day, plain.hour, plain.minute, plain.second, plain.utc);
78
+ if ('hour' in plain) {
79
+ return DateTime.create(plain.year, plain.month, plain.day, plain.hour, plain.minute, plain.second, plain.utc);
80
+ }
81
+ return DateTime.create(plain.year, plain.month, plain.day);
59
82
  }
60
83
  /**
61
84
  * Creates a new DateTime object from provided string representation of a date according to RFC 5545.
62
85
  */
86
+ // TODO: add template expression
63
87
  static fromString(str) {
64
- const typeError = new TypeError('Invalid date time string');
65
- if (str.length > 16 || str.length < 15) {
66
- throw typeError;
88
+ if (!(str.length === 8 || (str.length <= 16 && str.length >= 15))) {
89
+ throw new TypeError('Invalid date time string');
67
90
  }
68
91
  const year = parseInt(str.slice(0, 4));
69
92
  const month = parseInt(str.slice(4, 6));
70
93
  const day = parseInt(str.slice(6, 8));
71
- const hour = parseInt(str.slice(9, 11));
72
- const minute = parseInt(str.slice(11, 13));
73
- const second = parseInt(str.slice(13, 15));
74
- const utc = str.endsWith('Z');
75
- if (isNaN(year) ||
76
- isNaN(month) ||
77
- isNaN(day) ||
78
- isNaN(hour) ||
79
- isNaN(minute) ||
80
- isNaN(second)) {
81
- throw typeError;
94
+ let hour = undefined;
95
+ let minute = undefined;
96
+ let second = undefined;
97
+ let utc = undefined;
98
+ if (isNaN(year) || isNaN(month) || isNaN(day)) {
99
+ throw new TypeError('Invalid date');
100
+ }
101
+ if (str.length > 8) {
102
+ hour = parseInt(str.slice(9, 11));
103
+ minute = parseInt(str.slice(11, 13));
104
+ second = parseInt(str.slice(13, 15));
105
+ utc = str.endsWith('Z');
106
+ if (isNaN(hour) || isNaN(minute) || isNaN(second)) {
107
+ throw new TypeError('Invalid time');
108
+ }
109
+ return DateTime.create(year, month, day, hour, minute, second, utc);
110
+ }
111
+ else {
112
+ return DateTime.create(year, month, day);
82
113
  }
83
- return DateTime.create(year, month, day, hour, minute, second, utc);
84
114
  }
85
115
  /** @internal */
86
116
  static fromNumeric(numeric) {
87
117
  return new DateTime(numeric);
88
118
  }
89
119
  toPlain(options) {
90
- return {
91
- year: this.year,
92
- month: this.month,
93
- day: this.day,
94
- hour: this.hour,
95
- minute: this.minute,
96
- second: this.second,
97
- utc: options?.stripUtc ? undefined : this.utc,
98
- };
120
+ let plain;
121
+ if (this.time) {
122
+ plain = options?.stripUtc
123
+ ? {
124
+ year: this.year,
125
+ month: this.month,
126
+ day: this.day,
127
+ hour: this.time.hour,
128
+ minute: this.time.minute,
129
+ second: this.time.second,
130
+ }
131
+ : {
132
+ year: this.year,
133
+ month: this.month,
134
+ day: this.day,
135
+ hour: this.time.hour,
136
+ minute: this.time.minute,
137
+ second: this.time.second,
138
+ utc: this.time.utc,
139
+ };
140
+ }
141
+ else {
142
+ plain = {
143
+ year: this.year,
144
+ month: this.month,
145
+ day: this.day,
146
+ };
147
+ }
148
+ return plain;
99
149
  }
100
150
  /**
101
151
  * Converts DateTime into ISO 8601 string:
152
+ * * `YYYYMMDD` for date only
102
153
  * - `YYYYMMDDTHHMMSSZ` for UTC
103
154
  * - `YYYYMMDDTHHMMSS` for local
104
155
  */
105
156
  toString() {
106
- const year = this.year.toString().padStart(4, '0');
107
- const month = this.month.toString().padStart(2, '0');
108
- const day = this.day.toString().padStart(2, '0');
109
- const hour = this.hour.toString().padStart(2, '0');
110
- const minute = this.minute.toString().padStart(2, '0');
111
- const second = this.second.toString().padStart(2, '0');
112
- return `${year}${month}${day}T${hour}${minute}${second}${this.utc ? 'Z' : ''}`;
157
+ let str = this.year.toString().padStart(4, '0') +
158
+ this.month.toString().padStart(2, '0') +
159
+ this.day.toString().padStart(2, '0');
160
+ if (this.time) {
161
+ str +=
162
+ 'T' +
163
+ this.time.hour.toString().padStart(2, '0') +
164
+ this.time.minute.toString().padStart(2, '0') +
165
+ this.time.second.toString().padStart(2, '0') +
166
+ (this.time.utc ? 'Z' : '');
167
+ }
168
+ return str;
113
169
  }
114
170
  /** @internal */
115
171
  toNumeric() {
116
- return this.numeric;
172
+ return this.state.numeric;
117
173
  }
118
174
  }
@@ -1,19 +1,20 @@
1
- import { DateTime, type DateTimeLike } from './datetime';
2
- export interface DtStartOptions {
3
- datetime: 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: DateTimeLike;
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: 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, tzid?: string);
14
- constructor(options: DtStartOptions);
15
- static fromPlain(plain: DtStartLike): DtStart;
16
- setTzid(tzid: string): DtStart;
17
- setDatetime(datetime: DateTime): DtStart;
18
- toPlain(): DtStartLike;
13
+ constructor(datetime: DT, 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
  }
@@ -1,4 +1,4 @@
1
- import { DateTime } from './datetime';
1
+ import { DateTime, } from './datetime';
2
2
  export class DtStart {
3
3
  constructor(datetimeOrOptions, tzid) {
4
4
  if ('datetime' in datetimeOrOptions) {
@@ -17,16 +17,10 @@ export class DtStart {
17
17
  });
18
18
  }
19
19
  setTzid(tzid) {
20
- return new DtStart({
21
- datetime: this.datetime,
22
- tzid,
23
- });
20
+ return new DtStart(this.datetime, tzid);
24
21
  }
25
22
  setDatetime(datetime) {
26
- return new DtStart({
27
- datetime: datetime,
28
- tzid: this.tzid,
29
- });
23
+ return new DtStart(datetime, this.tzid);
30
24
  }
31
25
  toPlain() {
32
26
  return {
@@ -0,0 +1,20 @@
1
+ import { DateTime, type Time, type DateTimeLike, type DateLike } from './datetime';
2
+ export interface ExDateOptions<DT extends DateTime<Time> | DateTime<undefined>> {
3
+ values: DT[];
4
+ tzid?: string;
5
+ }
6
+ export interface ExDateLike<DT extends DateTimeLike | DateLike> {
7
+ values: DT[];
8
+ tzid?: string;
9
+ }
10
+ export declare class ExDate<DT extends DateTime<Time> | DateTime<undefined> = DateTime<Time>> {
11
+ readonly values: DT[];
12
+ readonly tzid?: string;
13
+ constructor(values: DT[], tzid?: string);
14
+ constructor(options: ExDateOptions<DT>);
15
+ static fromPlain(plain: ExDateLike<DateTimeLike>): ExDate<DateTime<Time>>;
16
+ static fromPlain(plain: ExDateLike<DateLike>): ExDate<DateTime<undefined>>;
17
+ setTzid(tzid: string | undefined): ExDate<DT>;
18
+ setValues<NDT extends DateTime<Time> | DateTime<undefined>>(datetimes: NDT[]): ExDate<NDT>;
19
+ toPlain<DTL extends DateTimeLike | DateLike = DT extends DateTime<Time> ? DateTimeLike : DateLike>(): ExDateLike<DTL>;
20
+ }
@@ -0,0 +1,47 @@
1
+ import { DateTime, } from './datetime';
2
+ import { ExDate as Rust } from './lib';
3
+ export class ExDate {
4
+ constructor(valuesOrOptions, tzid) {
5
+ if (!Array.isArray(valuesOrOptions)) {
6
+ this.values = valuesOrOptions.values;
7
+ this.tzid = valuesOrOptions.tzid;
8
+ }
9
+ else {
10
+ this.values = valuesOrOptions;
11
+ this.tzid = tzid;
12
+ }
13
+ }
14
+ /**
15
+ * @internal
16
+ */
17
+ static fromRust(rust) {
18
+ const rrule = new this(rust.values.map((dt) => DateTime.fromNumeric(dt)), rust.tzid ?? undefined);
19
+ rrule.rust = rust;
20
+ return rrule;
21
+ }
22
+ static fromPlain(plain) {
23
+ return new this({
24
+ values: plain.values.map((dt) => DateTime.fromPlain(dt)),
25
+ tzid: plain.tzid,
26
+ });
27
+ }
28
+ setTzid(tzid) {
29
+ return new ExDate(this.values, tzid);
30
+ }
31
+ setValues(datetimes) {
32
+ return new ExDate(datetimes, this.tzid);
33
+ }
34
+ toPlain() {
35
+ return {
36
+ values: this.values.map((dt) => dt.toPlain()),
37
+ tzid: this.tzid,
38
+ };
39
+ }
40
+ /**
41
+ * @internal
42
+ */
43
+ toRust() {
44
+ this.rust ??= new Rust(this.values.map((dt) => dt.toNumeric()), this.tzid);
45
+ return this.rust;
46
+ }
47
+ }
@@ -2,3 +2,5 @@ export * from './rrule-set';
2
2
  export * from './rrule';
3
3
  export * from './datetime';
4
4
  export * from './dtstart';
5
+ export * from './exdate';
6
+ export * from './rdate';
@@ -2,3 +2,5 @@ export * from './rrule-set';
2
2
  export * from './rrule';
3
3
  export * from './datetime';
4
4
  export * from './dtstart';
5
+ export * from './exdate';
6
+ export * from './rdate';
@@ -0,0 +1,20 @@
1
+ import { DateTime, type Time, type DateTimeLike, type DateLike } from './datetime';
2
+ export interface RDateOptions<DT extends DateTime<Time> | DateTime<undefined>> {
3
+ values: DT[];
4
+ tzid?: string;
5
+ }
6
+ export interface RDateLike<DT extends DateTimeLike | DateLike> {
7
+ values: DT[];
8
+ tzid?: string;
9
+ }
10
+ export declare class RDate<DT extends DateTime<Time> | DateTime<undefined> = DateTime<Time>> {
11
+ readonly values: DT[];
12
+ readonly tzid?: string;
13
+ constructor(values: DT[], tzid?: string);
14
+ constructor(options: RDateOptions<DT>);
15
+ static fromPlain(plain: RDateLike<DateTimeLike>): RDate<DateTime<Time>>;
16
+ static fromPlain(plain: RDateLike<DateLike>): RDate<DateTime<undefined>>;
17
+ setTzid(tzid: string | undefined): RDate<DT>;
18
+ setValues<NDT extends DateTime<Time> | DateTime<undefined>>(datetimes: NDT[]): RDate<NDT>;
19
+ toPlain<DTL extends DateTimeLike | DateLike = DT extends DateTime<Time> ? DateTimeLike : DateLike>(): RDateLike<DTL>;
20
+ }
@@ -0,0 +1,47 @@
1
+ import { DateTime, } from './datetime';
2
+ import { RDate as Rust } from './lib';
3
+ export class RDate {
4
+ constructor(valuesOrOptions, tzid) {
5
+ if (!Array.isArray(valuesOrOptions)) {
6
+ this.values = valuesOrOptions.values;
7
+ this.tzid = valuesOrOptions.tzid;
8
+ }
9
+ else {
10
+ this.values = valuesOrOptions;
11
+ this.tzid = tzid;
12
+ }
13
+ }
14
+ /**
15
+ * @internal
16
+ */
17
+ static fromRust(rust) {
18
+ const rrule = new this(rust.values.map((dt) => DateTime.fromNumeric(dt)), rust.tzid ?? undefined);
19
+ rrule.rust = rust;
20
+ return rrule;
21
+ }
22
+ static fromPlain(plain) {
23
+ return new this({
24
+ values: plain.values.map((dt) => DateTime.fromPlain(dt)),
25
+ tzid: plain.tzid,
26
+ });
27
+ }
28
+ setTzid(tzid) {
29
+ return new RDate(this.values, tzid);
30
+ }
31
+ setValues(datetimes) {
32
+ return new RDate(datetimes, this.tzid);
33
+ }
34
+ toPlain() {
35
+ return {
36
+ values: this.values.map((dt) => dt.toPlain()),
37
+ tzid: this.tzid,
38
+ };
39
+ }
40
+ /**
41
+ * @internal
42
+ */
43
+ toRust() {
44
+ this.rust ??= new Rust(this.values.map((dt) => dt.toNumeric()), this.tzid);
45
+ return this.rust;
46
+ }
47
+ }
@@ -1,48 +1,51 @@
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 DateTime[];
9
- readonly rdates?: readonly DateTime[];
4
+ import { ExDate, type ExDateLike } from './exdate';
5
+ import { RDate, type RDateLike } from './rdate';
6
+ export interface RRuleSetOptions<DT extends DateTime<Time> | DateTime<undefined> = DateTime<Time>> {
7
+ readonly dtstart: DtStart<DT>;
8
+ readonly rrules?: readonly RRule<DT>[];
9
+ readonly exrules?: readonly RRule<DT>[];
10
+ readonly exdates?: readonly ExDate<DT>[];
11
+ readonly rdates?: readonly RDate<DT>[];
10
12
  }
11
- export interface RRuleSetLike {
12
- readonly dtstart: DtStartLike;
13
- readonly rrules: readonly RRuleLike[];
14
- readonly exrules: readonly RRuleLike[];
15
- readonly exdates: readonly DateTimeLike[];
16
- readonly rdates: readonly DateTimeLike[];
13
+ export interface RRuleSetLike<DT extends DateTimeLike | DateLike> {
14
+ readonly dtstart: DtStartLike<DT>;
15
+ readonly rrules: readonly RRuleLike<DT>[];
16
+ readonly exrules: readonly RRuleLike<DT>[];
17
+ readonly exdates: readonly ExDateLike<DT>[];
18
+ readonly rdates: readonly RDateLike<DT>[];
17
19
  }
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 DateTime[];
23
- readonly rdates: readonly DateTime[];
24
- constructor(dtstart: DtStart);
25
- constructor(options: RRuleSetOptions);
20
+ export declare class RRuleSet<DT extends DateTime<Time> | DateTime<undefined>> implements Iterable<DateTime<Time> | DateTime<undefined>> {
21
+ readonly dtstart: DtStart<DT>;
22
+ readonly rrules: readonly RRule<DT>[];
23
+ readonly exrules: readonly RRule<DT>[];
24
+ readonly exdates: readonly ExDate<DT>[];
25
+ readonly rdates: readonly RDate<DT>[];
26
+ constructor(dtstart: DtStart<DT>);
27
+ constructor(options: RRuleSetOptions<DT>);
26
28
  /**
27
29
  * Parses a string into an RRuleSet.
28
30
  */
29
- static parse(str: string): RRuleSet;
30
- static fromPlain(plain: RRuleSetLike): RRuleSet;
31
- setDtstart(dtstart: DtStart): RRuleSet;
32
- addRrule(rrule: RRule): RRuleSet;
33
- setRrules(rrules: readonly RRule[]): RRuleSet;
34
- addExrule(rrule: RRule): RRuleSet;
35
- setExrules(rrules: readonly RRule[]): RRuleSet;
36
- addExdate(datetime: DateTime): RRuleSet;
37
- setExdates(datetimes: readonly DateTime[]): RRuleSet;
38
- addRdate(datetime: DateTime): RRuleSet;
39
- setRdates(datetimes: readonly DateTime[]): RRuleSet;
31
+ static parse<DT extends DateTime<Time> | DateTime<undefined>>(str: string): RRuleSet<DT>;
32
+ static fromPlain(plain: RRuleSetLike<DateTimeLike>): RRuleSet<DateTime<Time>>;
33
+ static fromPlain(plain: RRuleSetLike<DateLike>): RRuleSet<DateTime<undefined>>;
34
+ setDtstart(dtstart: DtStart<DT>): RRuleSet<DT>;
35
+ addRrule<RRDT extends DT>(rrule: RRule<RRDT>): RRuleSet<DT>;
36
+ setRrules(rrules: readonly RRule<DT>[]): RRuleSet<DT>;
37
+ addExrule(rrule: RRule<DT>): RRuleSet<DT>;
38
+ setExrules(rrules: readonly RRule<DT>[]): RRuleSet<DT>;
39
+ addExdate(exdate: ExDate<DT>): RRuleSet<DT>;
40
+ setExdates(exdates: readonly ExDate<DT>[]): RRuleSet<DT>;
41
+ addRdate(datetime: RDate<DT>): RRuleSet<DT>;
42
+ setRdates(datetimes: readonly RDate<DT>[]): RRuleSet<DT>;
40
43
  /**
41
44
  * Returns all the occurrences of the rrule.
42
45
  *
43
46
  * @param limit - The maximum number of occurrences to return.
44
47
  */
45
- all(limit?: number): DateTime[];
48
+ all(limit?: number): DT[];
46
49
  /**
47
50
  * Returns all the occurrences of the rrule between after and before.
48
51
  *
@@ -50,18 +53,18 @@ export declare class RRuleSet implements Iterable<DateTime> {
50
53
  * @param before - The upper bound date.
51
54
  * @param inclusive - Whether to include after and before in the list of occurrences.
52
55
  */
53
- between(after: DateTime, before: DateTime, inclusive?: boolean): DateTime[];
56
+ between(after: DT, before: DT, inclusive?: boolean): DT[];
54
57
  /**
55
58
  * Sets the RRuleSet from a string.
56
59
  *
57
60
  * @param str - The string to parse.
58
61
  */
59
- setFromString(str: string): RRuleSet;
62
+ setFromString<NDT extends DateTime<Time> | DateTime<undefined> = DT>(str: string): RRuleSet<NDT>;
60
63
  toString(): string;
61
64
  /**
62
65
  * Converts the RRuleSet to a plain object.
63
66
  */
64
- toPlain(): RRuleSetLike;
65
- [Symbol.iterator](): Iterator<DateTime, any, any>;
67
+ toPlain(): RRuleSetLike<DT extends DateTime<Time> ? DateTimeLike : DateLike>;
68
+ [Symbol.iterator](): Iterator<DT, any, any>;
66
69
  private toOptions;
67
70
  }