rrule-temporal 0.1.3 → 0.1.5

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/index.js CHANGED
@@ -1,661 +1,552 @@
1
- // rrule-temporal.ts
1
+ // src/index.ts
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
- /**
4
- * Parse either a full ICS snippet or an RRULE line into ManualOpts
5
- */
6
3
  function parseRRuleString(input, fallbackDtstart) {
7
- let dtstart;
8
- let tzid = "";
9
- let rruleLine;
10
- if (/^DTSTART/m.test(input)) {
11
- // ICS snippet: split DTSTART and RRULE
12
- const [dtLine, rrLine] = input.split(/\r?\n/);
13
- const m = dtLine?.match(/DTSTART(?:;TZID=([^:]+))?:(\d{8}T\d{6})/);
14
- if (!m)
15
- throw new Error("Invalid DTSTART in ICS snippet");
16
- tzid = m[1] || tzid;
17
- const isoDate = `${m[2].slice(0, 4)}-${m[2].slice(4, 6)}-${m[2].slice(6, 8)}` +
18
- `T${m[2].slice(9)}`;
19
- dtstart = Temporal.PlainDateTime.from(isoDate).toZonedDateTime(tzid);
20
- rruleLine = rrLine;
21
- }
22
- else {
23
- // Only RRULE line; require fallback
24
- if (!fallbackDtstart)
25
- throw new Error("dtstart required when parsing RRULE alone");
26
- dtstart = fallbackDtstart;
27
- tzid = fallbackDtstart.timeZoneId;
28
- rruleLine = input.replace(/^RRULE:/, "RRULE:");
29
- }
30
- // Parse RRULE
31
- const parts = rruleLine.replace(/^RRULE:/, "").split(";");
32
- const opts = { dtstart, tzid };
33
- for (const part of parts) {
34
- const [key, val] = part.split("=");
35
- switch (key) {
36
- case "FREQ":
37
- opts.freq = val;
38
- break;
39
- case "INTERVAL":
40
- opts.interval = parseInt(val, 10);
41
- break;
42
- case "COUNT":
43
- opts.count = parseInt(val, 10);
44
- break;
45
- case "UNTIL": {
46
- // RFC5545 UNTIL is YYYYMMDDTHHMMSSZ or without Z
47
- if (/Z$/.test(val)) {
48
- const iso = `${val.slice(0, 4)}-${val.slice(4, 6)}-` +
49
- `${val.slice(6, 8)}T${val.slice(9, 15)}Z`;
50
- opts.until = Temporal.Instant.from(iso).toZonedDateTimeISO(tzid || "UTC");
51
- }
52
- else {
53
- const iso = `${val.slice(0, 4)}-${val.slice(4, 6)}-` +
54
- `${val.slice(6, 8)}T${val.slice(9, 15)}`;
55
- opts.until = Temporal.PlainDateTime.from(iso).toZonedDateTime(tzid || "UTC");
56
- }
57
- break;
58
- }
59
- case "BYHOUR":
60
- opts.byHour = val.split(",").map((n) => parseInt(n, 10));
61
- break;
62
- case "BYMINUTE":
63
- opts.byMinute = val.split(",").map((n) => parseInt(n, 10));
64
- break;
65
- case "BYDAY":
66
- opts.byDay = val.split(","); // e.g. ["MO","2FR","-1SU"]
67
- break;
68
- case "BYMONTH":
69
- opts.byMonth = val.split(",").map((n) => parseInt(n, 10));
70
- break;
4
+ let dtstart;
5
+ let tzid = "";
6
+ let rruleLine;
7
+ if (/^DTSTART/m.test(input)) {
8
+ const [dtLine, rrLine] = input.split(/\r?\n/);
9
+ const m = dtLine?.match(/DTSTART(?:;TZID=([^:]+))?:(\d{8}T\d{6})/);
10
+ if (!m) throw new Error("Invalid DTSTART in ICS snippet");
11
+ tzid = m[1] || tzid;
12
+ const isoDate = `${m[2].slice(0, 4)}-${m[2].slice(4, 6)}-${m[2].slice(6, 8)}T${m[2].slice(9)}`;
13
+ dtstart = Temporal.PlainDateTime.from(isoDate).toZonedDateTime(tzid);
14
+ rruleLine = rrLine;
15
+ } else {
16
+ if (!fallbackDtstart)
17
+ throw new Error("dtstart required when parsing RRULE alone");
18
+ dtstart = fallbackDtstart;
19
+ tzid = fallbackDtstart.timeZoneId;
20
+ rruleLine = input.replace(/^RRULE:/, "RRULE:");
21
+ }
22
+ const parts = rruleLine.replace(/^RRULE:/, "").split(";");
23
+ const opts = { dtstart, tzid };
24
+ for (const part of parts) {
25
+ const [key, val] = part.split("=");
26
+ switch (key) {
27
+ case "FREQ":
28
+ opts.freq = val;
29
+ break;
30
+ case "INTERVAL":
31
+ opts.interval = parseInt(val, 10);
32
+ break;
33
+ case "COUNT":
34
+ opts.count = parseInt(val, 10);
35
+ break;
36
+ case "UNTIL": {
37
+ if (/Z$/.test(val)) {
38
+ const iso = `${val.slice(0, 4)}-${val.slice(4, 6)}-${val.slice(6, 8)}T${val.slice(9, 15)}Z`;
39
+ opts.until = Temporal.Instant.from(iso).toZonedDateTimeISO(
40
+ tzid || "UTC"
41
+ );
42
+ } else {
43
+ const iso = `${val.slice(0, 4)}-${val.slice(4, 6)}-${val.slice(6, 8)}T${val.slice(9, 15)}`;
44
+ opts.until = Temporal.PlainDateTime.from(iso).toZonedDateTime(
45
+ tzid || "UTC"
46
+ );
71
47
  }
48
+ break;
49
+ }
50
+ case "BYHOUR":
51
+ opts.byHour = val.split(",").map((n) => parseInt(n, 10));
52
+ break;
53
+ case "BYMINUTE":
54
+ opts.byMinute = val.split(",").map((n) => parseInt(n, 10));
55
+ break;
56
+ case "BYDAY":
57
+ opts.byDay = val.split(",");
58
+ break;
59
+ case "BYMONTH":
60
+ opts.byMonth = val.split(",").map((n) => parseInt(n, 10));
61
+ break;
72
62
  }
73
- return opts;
63
+ }
64
+ return opts;
74
65
  }
75
- export class RRuleTemporal {
76
- tzid;
77
- originalDtstart;
78
- opts;
79
- constructor(params) {
80
- let manual;
81
- if ("rruleString" in params) {
82
- manual = parseRRuleString(params.rruleString);
83
- this.tzid = manual.tzid || "UTC";
84
- this.originalDtstart = manual.dtstart;
85
- }
86
- else {
87
- manual = { ...params };
88
- if (typeof manual.dtstart === "string") {
89
- throw new Error("Manual dtstart must be a ZonedDateTime");
90
- }
91
- manual.tzid = manual.tzid || manual.dtstart.timeZoneId;
92
- this.tzid = manual.tzid;
93
- this.originalDtstart = manual.dtstart;
94
- }
95
- if (!manual.freq)
96
- throw new Error("RRULE must include FREQ");
97
- manual.interval = manual.interval ?? 1;
98
- this.opts = manual;
66
+ var RRuleTemporal = class {
67
+ tzid;
68
+ originalDtstart;
69
+ opts;
70
+ constructor(params) {
71
+ let manual;
72
+ if ("rruleString" in params) {
73
+ manual = parseRRuleString(params.rruleString);
74
+ this.tzid = manual.tzid || "UTC";
75
+ this.originalDtstart = manual.dtstart;
76
+ } else {
77
+ manual = { ...params };
78
+ if (typeof manual.dtstart === "string") {
79
+ throw new Error("Manual dtstart must be a ZonedDateTime");
80
+ }
81
+ manual.tzid = manual.tzid || manual.dtstart.timeZoneId;
82
+ this.tzid = manual.tzid;
83
+ this.originalDtstart = manual.dtstart;
99
84
  }
100
- rawAdvance(zdt) {
101
- const { freq, interval } = this.opts;
102
- switch (freq) {
103
- case "DAILY":
104
- return zdt.add({ days: interval });
105
- case "WEEKLY":
106
- return zdt.add({ weeks: interval });
107
- case "MONTHLY":
108
- return zdt.add({ months: interval });
109
- case "YEARLY":
110
- return zdt.add({ years: interval });
111
- case "HOURLY":
112
- return zdt.add({ hours: interval });
113
- case "MINUTELY":
114
- return zdt.add({ minutes: interval });
115
- case "SECONDLY":
116
- return zdt.add({ seconds: interval });
117
- default:
118
- throw new Error(`Unsupported FREQ: ${freq}`);
119
- }
85
+ if (!manual.freq) throw new Error("RRULE must include FREQ");
86
+ manual.interval = manual.interval ?? 1;
87
+ this.opts = manual;
88
+ }
89
+ rawAdvance(zdt) {
90
+ const { freq, interval } = this.opts;
91
+ switch (freq) {
92
+ case "DAILY":
93
+ return zdt.add({ days: interval });
94
+ case "WEEKLY":
95
+ return zdt.add({ weeks: interval });
96
+ case "MONTHLY":
97
+ return zdt.add({ months: interval });
98
+ case "YEARLY":
99
+ return zdt.add({ years: interval });
100
+ case "HOURLY":
101
+ return zdt.add({ hours: interval });
102
+ case "MINUTELY":
103
+ return zdt.add({ minutes: interval });
104
+ case "SECONDLY":
105
+ return zdt.add({ seconds: interval });
106
+ default:
107
+ throw new Error(`Unsupported FREQ: ${freq}`);
120
108
  }
121
- applyTimeOverride(zdt) {
122
- const { byHour, byMinute } = this.opts;
123
- let dt = zdt;
124
- if (byHour)
125
- dt = dt.with({ hour: byHour[0] });
126
- if (byMinute)
127
- dt = dt.with({ minute: byMinute[0] });
128
- return dt;
109
+ }
110
+ applyTimeOverride(zdt) {
111
+ const { byHour, byMinute } = this.opts;
112
+ let dt = zdt;
113
+ if (byHour) dt = dt.with({ hour: byHour[0] });
114
+ if (byMinute) dt = dt.with({ minute: byMinute[0] });
115
+ return dt;
116
+ }
117
+ computeFirst() {
118
+ let zdt = this.originalDtstart;
119
+ if (this.opts.freq === "WEEKLY" && this.opts.byDay?.length) {
120
+ const dayMap = {
121
+ MO: 1,
122
+ TU: 2,
123
+ WE: 3,
124
+ TH: 4,
125
+ FR: 5,
126
+ SA: 6,
127
+ SU: 7
128
+ };
129
+ const targetDow = dayMap[this.opts.byDay[0]];
130
+ const delta = (targetDow - zdt.dayOfWeek + 7) % 7;
131
+ zdt = zdt.add({ days: delta });
129
132
  }
130
- computeFirst() {
131
- let zdt = this.originalDtstart;
132
- // If it's WEEKLY with BYDAY, advance zdt to the first matching weekday ≥ dtstart
133
- if (this.opts.freq === "WEEKLY" && this.opts.byDay?.length) {
134
- const dayMap = {
135
- MO: 1,
136
- TU: 2,
137
- WE: 3,
138
- TH: 4,
139
- FR: 5,
140
- SA: 6,
141
- SU: 7,
142
- };
143
- const targetDow = dayMap[this.opts.byDay[0]];
144
- const delta = (targetDow - zdt.dayOfWeek + 7) % 7;
145
- zdt = zdt.add({ days: delta });
146
- }
147
- // then your existing BYHOUR/BYMINUTE override logic:
148
- const { byHour, byMinute } = this.opts;
149
- if (byHour || byMinute) {
150
- zdt = this.applyTimeOverride(zdt);
151
- if (Temporal.Instant.compare(zdt.toInstant(), this.originalDtstart.toInstant()) < 0) {
152
- zdt = this.applyTimeOverride(this.rawAdvance(this.originalDtstart));
153
- }
154
- }
155
- return zdt;
156
- }
157
- // inside class RRuleTemporal:
158
- generateWeeklyOccurrences(sample) {
159
- const { byDay } = this.opts;
160
- // Map token → ISO dayOfWeek
161
- const dayMap = {
162
- MO: 1,
163
- TU: 2,
164
- WE: 3,
165
- TH: 4,
166
- FR: 5,
167
- SA: 6,
168
- SU: 7,
169
- };
170
- // If no BYDAY, default to the sample’s own weekday token
171
- const tokens = byDay && byDay.length
172
- ? byDay
173
- : [Object.entries(dayMap).find(([, d]) => d === sample.dayOfWeek)[0]];
174
- // For each token, find the date in [sample, sample+6d] matching that weekday
175
- const occs = tokens.map((tok) => {
176
- const targetDow = dayMap[tok];
177
- const delta = (targetDow - sample.dayOfWeek + 7) % 7;
178
- return this.applyTimeOverride(sample.add({ days: delta }));
179
- });
180
- // Return in chronological order
181
- return occs.sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
133
+ const { byHour, byMinute } = this.opts;
134
+ if (byHour || byMinute) {
135
+ zdt = this.applyTimeOverride(zdt);
136
+ if (Temporal.Instant.compare(
137
+ zdt.toInstant(),
138
+ this.originalDtstart.toInstant()
139
+ ) < 0) {
140
+ zdt = this.applyTimeOverride(this.rawAdvance(this.originalDtstart));
141
+ }
182
142
  }
183
- // --- NEW: constraint checks ---
184
- // 2) Replace your matchesByDay with this:
185
- matchesByDay(zdt) {
186
- const { byDay } = this.opts;
187
- if (!byDay)
188
- return true;
189
- // map two‑letter to Temporal dayOfWeek (1=Mon … 7=Sun)
190
- const dayMap = {
191
- MO: 1,
192
- TU: 2,
193
- WE: 3,
194
- TH: 4,
195
- FR: 5,
196
- SA: 6,
197
- SU: 7,
198
- };
199
- for (const token of byDay) {
200
- // 1) match and destructure
201
- const m = token.match(/^([+-]?\d)?(MO|TU|WE|TH|FR|SA|SU)$/);
202
- if (!m)
203
- continue;
204
- const ord = m[1] ? parseInt(m[1], 10) : 0;
205
- // 2) pull weekday into its own variable and guard
206
- const weekday = m[2];
207
- if (!weekday)
208
- continue; // now TS knows `weekday` is string
209
- const wd = dayMap[weekday]; // no more "undefined index" error
210
- // no ordinal → simple weekday match
211
- if (ord === 0) {
212
- if (zdt.dayOfWeek === wd)
213
- return true;
214
- continue;
215
- }
216
- // build all days in month with this weekday
217
- const year = zdt.year;
218
- const month = zdt.month;
219
- let dt = zdt.with({ day: 1 });
220
- const candidates = [];
221
- while (dt.month === month) {
222
- if (dt.dayOfWeek === wd)
223
- candidates.push(dt.day);
224
- dt = dt.add({ days: 1 });
225
- }
226
- // pick the “ord-th” entry (supports negative ord)
227
- const idx = ord > 0 ? ord - 1 : candidates.length + ord;
228
- if (candidates[idx] === zdt.day)
229
- return true;
230
- }
231
- return false;
143
+ return zdt;
144
+ }
145
+ // inside class RRuleTemporal:
146
+ generateWeeklyOccurrences(sample) {
147
+ const { byDay } = this.opts;
148
+ const dayMap = {
149
+ MO: 1,
150
+ TU: 2,
151
+ WE: 3,
152
+ TH: 4,
153
+ FR: 5,
154
+ SA: 6,
155
+ SU: 7
156
+ };
157
+ const tokens = byDay && byDay.length ? byDay : [Object.entries(dayMap).find(([, d]) => d === sample.dayOfWeek)[0]];
158
+ const occs = tokens.map((tok) => {
159
+ const targetDow = dayMap[tok];
160
+ const delta = (targetDow - sample.dayOfWeek + 7) % 7;
161
+ return this.applyTimeOverride(sample.add({ days: delta }));
162
+ });
163
+ return occs.sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
164
+ }
165
+ // --- NEW: constraint checks ---
166
+ // 2) Replace your matchesByDay with this:
167
+ matchesByDay(zdt) {
168
+ const { byDay } = this.opts;
169
+ if (!byDay) return true;
170
+ const dayMap = {
171
+ MO: 1,
172
+ TU: 2,
173
+ WE: 3,
174
+ TH: 4,
175
+ FR: 5,
176
+ SA: 6,
177
+ SU: 7
178
+ };
179
+ for (const token of byDay) {
180
+ const m = token.match(/^([+-]?\d)?(MO|TU|WE|TH|FR|SA|SU)$/);
181
+ if (!m) continue;
182
+ const ord = m[1] ? parseInt(m[1], 10) : 0;
183
+ const weekday = m[2];
184
+ if (!weekday) continue;
185
+ const wd = dayMap[weekday];
186
+ if (ord === 0) {
187
+ if (zdt.dayOfWeek === wd) return true;
188
+ continue;
189
+ }
190
+ const year = zdt.year;
191
+ const month = zdt.month;
192
+ let dt = zdt.with({ day: 1 });
193
+ const candidates = [];
194
+ while (dt.month === month) {
195
+ if (dt.dayOfWeek === wd) candidates.push(dt.day);
196
+ dt = dt.add({ days: 1 });
197
+ }
198
+ const idx = ord > 0 ? ord - 1 : candidates.length + ord;
199
+ if (candidates[idx] === zdt.day) return true;
232
200
  }
233
- matchesByMonth(zdt) {
234
- const { byMonth } = this.opts;
235
- if (!byMonth)
236
- return true;
237
- return byMonth.includes(zdt.month);
201
+ return false;
202
+ }
203
+ matchesByMonth(zdt) {
204
+ const { byMonth } = this.opts;
205
+ if (!byMonth) return true;
206
+ return byMonth.includes(zdt.month);
207
+ }
208
+ matchesAll(zdt) {
209
+ return this.matchesByDay(zdt) && this.matchesByMonth(zdt);
210
+ }
211
+ /**
212
+ * Returns all occurrences of the rule.
213
+ * @param iterator - An optional callback iterator function that can be used to filter or modify the occurrences.
214
+ * @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule.
215
+ */
216
+ all(iterator) {
217
+ if (!this.opts.count && !this.opts.until && !iterator) {
218
+ throw new Error("all() requires iterator when no COUNT/UNTIL");
238
219
  }
239
- matchesAll(zdt) {
240
- return this.matchesByDay(zdt) && this.matchesByMonth(zdt);
220
+ const dates = [];
221
+ if (this.opts.freq === "MONTHLY" && this.opts.byDay) {
222
+ const start = this.originalDtstart;
223
+ let monthCursor = start.with({ day: 1 });
224
+ let matchCount2 = 0;
225
+ outer_month: while (true) {
226
+ const occs = this.generateMonthlyOccurrences(monthCursor);
227
+ for (const occ of occs) {
228
+ if (Temporal.ZonedDateTime.compare(occ, start) < 0) continue;
229
+ if (this.opts.until && Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
230
+ break outer_month;
231
+ }
232
+ if (this.opts.count !== void 0 && matchCount2 >= this.opts.count) {
233
+ break outer_month;
234
+ }
235
+ if (iterator && !iterator(occ, matchCount2)) {
236
+ break outer_month;
237
+ }
238
+ dates.push(occ);
239
+ matchCount2++;
240
+ }
241
+ monthCursor = monthCursor.add({ months: this.opts.interval });
242
+ }
243
+ return dates;
241
244
  }
242
- /**
243
- * Returns all occurrences of the rule.
244
- * @param iterator - An optional callback iterator function that can be used to filter or modify the occurrences.
245
- * @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule.
246
- */
247
- all(iterator) {
248
- if (!this.opts.count && !this.opts.until && !iterator) {
249
- throw new Error("all() requires iterator when no COUNT/UNTIL");
245
+ if (this.opts.freq === "WEEKLY") {
246
+ const start = this.originalDtstart;
247
+ const dayMap = {
248
+ MO: 1,
249
+ TU: 2,
250
+ WE: 3,
251
+ TH: 4,
252
+ FR: 5,
253
+ SA: 6,
254
+ SU: 7
255
+ };
256
+ const tokens = this.opts.byDay ? [...this.opts.byDay] : [Object.entries(dayMap).find(([, d]) => d === start.dayOfWeek)[0]];
257
+ const dows = tokens.map((tok) => dayMap[tok]).filter((d) => d !== void 0).sort((a, b) => a - b);
258
+ const firstWeekDates = dows.map((dw) => {
259
+ const delta = (dw - start.dayOfWeek + 7) % 7;
260
+ return start.add({ days: delta });
261
+ });
262
+ let weekCursor = firstWeekDates.reduce(
263
+ (a, b) => Temporal.ZonedDateTime.compare(a, b) <= 0 ? a : b
264
+ );
265
+ let matchCount2 = 0;
266
+ outer_week: while (true) {
267
+ const baseDow = weekCursor.dayOfWeek;
268
+ const occs = dows.map((dw) => {
269
+ const delta = dw - baseDow;
270
+ return this.applyTimeOverride(weekCursor.add({ days: delta }));
271
+ }).sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
272
+ for (const occ of occs) {
273
+ if (Temporal.ZonedDateTime.compare(occ, start) < 0) continue;
274
+ if (this.opts.until && Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
275
+ break outer_week;
276
+ }
277
+ if (this.opts.count !== void 0 && matchCount2 >= this.opts.count) {
278
+ break outer_week;
279
+ }
280
+ if (iterator && !iterator(occ, matchCount2)) {
281
+ break outer_week;
282
+ }
283
+ dates.push(occ);
284
+ matchCount2++;
250
285
  }
251
- const dates = [];
252
- // --- 1) MONTHLY + BYDAY (multi-day expansions) ---
253
- if (this.opts.freq === "MONTHLY" && this.opts.byDay) {
254
- const start = this.originalDtstart;
255
- let monthCursor = start.with({ day: 1 });
256
- let matchCount = 0;
257
- outer_month: while (true) {
258
- const occs = this.generateMonthlyOccurrences(monthCursor);
259
- for (const occ of occs) {
260
- if (Temporal.ZonedDateTime.compare(occ, start) < 0)
261
- continue;
262
- if (this.opts.until &&
263
- Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
264
- break outer_month;
265
- }
266
- if (this.opts.count !== undefined && matchCount >= this.opts.count) {
267
- break outer_month;
268
- }
269
- if (iterator && !iterator(occ, matchCount)) {
270
- break outer_month;
271
- }
272
- dates.push(occ);
273
- matchCount++;
274
- }
275
- monthCursor = monthCursor.add({ months: this.opts.interval });
276
- }
277
- return dates;
286
+ weekCursor = weekCursor.add({ weeks: this.opts.interval });
287
+ }
288
+ return dates;
289
+ }
290
+ if (this.opts.freq === "YEARLY" && this.opts.byMonth) {
291
+ const start = this.originalDtstart;
292
+ const months = [...this.opts.byMonth].sort((a, b) => a - b);
293
+ let i = 0;
294
+ while (true) {
295
+ const year = start.year + i * this.opts.interval;
296
+ const month = months[i % months.length];
297
+ let occ = start.with({ year, month });
298
+ occ = this.applyTimeOverride(occ);
299
+ if (i === 0 && Temporal.ZonedDateTime.compare(occ, start) < 0) {
300
+ i++;
301
+ continue;
278
302
  }
279
- // --- 2) WEEKLY + BYDAY (or default to DTSTART’s weekday) ---
280
- if (this.opts.freq === "WEEKLY") {
281
- const start = this.originalDtstart;
282
- // Build the list of target weekdays (1=Mon..7=Sun)
283
- const dayMap = {
284
- MO: 1,
285
- TU: 2,
286
- WE: 3,
287
- TH: 4,
288
- FR: 5,
289
- SA: 6,
290
- SU: 7,
291
- };
292
- // If no BYDAY, default to DTSTART’s weekday token
293
- const tokens = this.opts.byDay
294
- ? [...this.opts.byDay]
295
- : [Object.entries(dayMap).find(([, d]) => d === start.dayOfWeek)[0]];
296
- const dows = tokens
297
- .map((tok) => dayMap[tok])
298
- .filter((d) => d !== undefined)
299
- .sort((a, b) => a - b);
300
- // Find the very first weekCursor: the earliest of this week’s matching days ≥ start
301
- const firstWeekDates = dows.map((dw) => {
302
- const delta = (dw - start.dayOfWeek + 7) % 7;
303
- return start.add({ days: delta });
304
- });
305
- let weekCursor = firstWeekDates.reduce((a, b) => Temporal.ZonedDateTime.compare(a, b) <= 0 ? a : b);
306
- let matchCount = 0;
307
- outer_week: while (true) {
308
- // Generate this week’s occurrences
309
- const baseDow = weekCursor.dayOfWeek;
310
- const occs = dows
311
- .map((dw) => {
312
- const delta = dw - baseDow;
313
- return this.applyTimeOverride(weekCursor.add({ days: delta }));
314
- })
315
- .sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
316
- for (const occ of occs) {
317
- if (Temporal.ZonedDateTime.compare(occ, start) < 0)
318
- continue;
319
- if (this.opts.until &&
320
- Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
321
- break outer_week;
322
- }
323
- if (this.opts.count !== undefined && matchCount >= this.opts.count) {
324
- break outer_week;
325
- }
326
- if (iterator && !iterator(occ, matchCount)) {
327
- break outer_week;
328
- }
329
- dates.push(occ);
330
- matchCount++;
331
- }
332
- weekCursor = weekCursor.add({ weeks: this.opts.interval });
333
- }
334
- return dates;
303
+ if (this.opts.until && Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
304
+ break;
335
305
  }
336
- // --- 3) YEARLY + BYMONTH (one per year, rotating) ---
337
- if (this.opts.freq === "YEARLY" && this.opts.byMonth) {
338
- const start = this.originalDtstart;
339
- const months = [...this.opts.byMonth].sort((a, b) => a - b);
340
- let i = 0;
341
- while (true) {
342
- const year = start.year + i * this.opts.interval;
343
- const month = months[i % months.length];
344
- let occ = start.with({ year, month });
345
- occ = this.applyTimeOverride(occ);
346
- if (i === 0 && Temporal.ZonedDateTime.compare(occ, start) < 0) {
347
- i++;
348
- continue;
349
- }
350
- if (this.opts.until &&
351
- Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
352
- break;
353
- }
354
- if (this.opts.count !== undefined && i >= this.opts.count) {
355
- break;
356
- }
357
- if (iterator && !iterator(occ, i)) {
358
- break;
359
- }
360
- dates.push(occ);
361
- i++;
362
- }
363
- return dates;
306
+ if (this.opts.count !== void 0 && i >= this.opts.count) {
307
+ break;
364
308
  }
365
- // --- 4) fallback: step + filter ---
366
- let current = this.computeFirst();
367
- let matchCount = 0;
368
- while (true) {
369
- if (this.opts.until &&
370
- Temporal.ZonedDateTime.compare(current, this.opts.until) > 0) {
371
- break;
372
- }
373
- if (this.matchesAll(current)) {
374
- if (this.opts.count !== undefined && matchCount >= this.opts.count) {
375
- break;
376
- }
377
- if (iterator && !iterator(current, matchCount)) {
378
- break;
379
- }
380
- dates.push(current);
381
- matchCount++;
382
- }
383
- current = this.applyTimeOverride(this.rawAdvance(current));
309
+ if (iterator && !iterator(occ, i)) {
310
+ break;
384
311
  }
385
- return dates;
312
+ dates.push(occ);
313
+ i++;
314
+ }
315
+ return dates;
386
316
  }
387
- /**
388
- * Returns all occurrences of the rule within a specified time window.
389
- * @param after - The start date or Temporal.ZonedDateTime object.
390
- * @param before - The end date or Temporal.ZonedDateTime object.
391
- * @param inc - Optional boolean flag to include the end date in the results.
392
- * @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule within the specified time window.
393
- */
394
- between(after, before, inc = false) {
395
- const startInst = after instanceof Date
396
- ? Temporal.Instant.from(after.toISOString())
397
- : after.toInstant();
398
- const endInst = before instanceof Date
399
- ? Temporal.Instant.from(before.toISOString())
400
- : before.toInstant();
401
- const results = [];
402
- // 1) MONTHLY + BYDAY
403
- if (this.opts.freq === "MONTHLY" && this.opts.byDay) {
404
- let monthCursor = this.computeFirst().with({ day: 1 });
405
- outer: while (true) {
406
- const occs = this.generateMonthlyOccurrences(monthCursor);
407
- for (const occ of occs) {
408
- const inst = occ.toInstant();
409
- if (inc
410
- ? Temporal.Instant.compare(inst, endInst) > 0
411
- : Temporal.Instant.compare(inst, endInst) >= 0) {
412
- break outer;
413
- }
414
- if (Temporal.Instant.compare(inst, startInst) >= 0) {
415
- results.push(occ);
416
- }
417
- }
418
- monthCursor = monthCursor.add({ months: this.opts.interval });
419
- }
420
- return results;
317
+ let current = this.computeFirst();
318
+ let matchCount = 0;
319
+ while (true) {
320
+ if (this.opts.until && Temporal.ZonedDateTime.compare(current, this.opts.until) > 0) {
321
+ break;
322
+ }
323
+ if (this.matchesAll(current)) {
324
+ if (this.opts.count !== void 0 && matchCount >= this.opts.count) {
325
+ break;
421
326
  }
422
- // 2) YEARLY + BYMONTH
423
- if (this.opts.freq === "YEARLY" && this.opts.byMonth) {
424
- const start = this.originalDtstart;
425
- const months = [...this.opts.byMonth].sort((a, b) => a - b);
426
- let i = 0;
427
- outer: while (true) {
428
- const year = start.year + i * this.opts.interval;
429
- const month = months[i % months.length];
430
- let occ = start.with({ year, month });
431
- occ = this.applyTimeOverride(occ);
432
- const inst = occ.toInstant();
433
- if (inc
434
- ? Temporal.Instant.compare(inst, endInst) > 0
435
- : Temporal.Instant.compare(inst, endInst) >= 0) {
436
- break;
437
- }
438
- if (Temporal.Instant.compare(inst, startInst) >= 0) {
439
- results.push(occ);
440
- }
441
- i++;
442
- }
443
- return results;
327
+ if (iterator && !iterator(current, matchCount)) {
328
+ break;
444
329
  }
445
- if (this.opts.freq === "WEEKLY") {
446
- const startInst = after instanceof Date
447
- ? Temporal.Instant.from(after.toISOString())
448
- : after.toInstant();
449
- const endInst = before instanceof Date
450
- ? Temporal.Instant.from(before.toISOString())
451
- : before.toInstant();
452
- let weekCursor = this.computeFirst();
453
- const results = [];
454
- outer: while (true) {
455
- const occs = this.generateWeeklyOccurrences(weekCursor);
456
- for (const occ of occs) {
457
- const inst = occ.toInstant();
458
- // break when beyond end
459
- if (inc
460
- ? Temporal.Instant.compare(inst, endInst) > 0
461
- : Temporal.Instant.compare(inst, endInst) >= 0) {
462
- break outer;
463
- }
464
- // include if on/after start
465
- if (Temporal.Instant.compare(inst, startInst) >= 0) {
466
- results.push(occ);
467
- }
468
- }
469
- weekCursor = weekCursor.add({ weeks: this.opts.interval });
470
- }
471
- return results;
472
- }
473
- // 3) fallback
474
- let current = this.computeFirst();
475
- while (true) {
476
- const inst = current.toInstant();
477
- if (inc) {
478
- if (Temporal.Instant.compare(inst, endInst) > 0)
479
- break;
480
- }
481
- else {
482
- if (Temporal.Instant.compare(inst, endInst) >= 0)
483
- break;
484
- }
485
- if (Temporal.Instant.compare(inst, startInst) >= 0 &&
486
- this.matchesAll(current)) {
487
- results.push(current);
488
- }
489
- current = this.applyTimeOverride(this.rawAdvance(current));
330
+ dates.push(current);
331
+ matchCount++;
332
+ }
333
+ current = this.applyTimeOverride(this.rawAdvance(current));
334
+ }
335
+ return dates;
336
+ }
337
+ /**
338
+ * Returns all occurrences of the rule within a specified time window.
339
+ * @param after - The start date or Temporal.ZonedDateTime object.
340
+ * @param before - The end date or Temporal.ZonedDateTime object.
341
+ * @param inc - Optional boolean flag to include the end date in the results.
342
+ * @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule within the specified time window.
343
+ */
344
+ between(after, before, inc = false) {
345
+ const startInst = after instanceof Date ? Temporal.Instant.from(after.toISOString()) : after.toInstant();
346
+ const endInst = before instanceof Date ? Temporal.Instant.from(before.toISOString()) : before.toInstant();
347
+ const results = [];
348
+ if (this.opts.freq === "MONTHLY" && this.opts.byDay) {
349
+ let monthCursor = this.computeFirst().with({ day: 1 });
350
+ outer: while (true) {
351
+ const occs = this.generateMonthlyOccurrences(monthCursor);
352
+ for (const occ of occs) {
353
+ const inst = occ.toInstant();
354
+ if (inc ? Temporal.Instant.compare(inst, endInst) > 0 : Temporal.Instant.compare(inst, endInst) >= 0) {
355
+ break outer;
356
+ }
357
+ if (Temporal.Instant.compare(inst, startInst) >= 0) {
358
+ results.push(occ);
359
+ }
490
360
  }
491
- return results;
361
+ monthCursor = monthCursor.add({ months: this.opts.interval });
362
+ }
363
+ return results;
492
364
  }
493
- /**
494
- * Returns the next occurrence of the rule after a specified date.
495
- * @param after - The start date or Temporal.ZonedDateTime object.
496
- * @param inc - Optional boolean flag to include occurrences on the start date.
497
- * @returns The next occurrence of the rule after the specified date or null if no occurrences are found.
498
- */
499
- next(after = new Date(), inc = false) {
500
- const afterInst = after instanceof Date
501
- ? Temporal.Instant.from(after.toISOString())
502
- : after.toInstant();
503
- let current = this.computeFirst();
504
- let matchCount = 0;
505
- while (true) {
506
- const inst = current.toInstant();
507
- // if this satisfies constraints, check if it's beyond 'after'
508
- if (this.matchesAll(current)) {
509
- const ok = inc
510
- ? Temporal.Instant.compare(inst, afterInst) >= 0
511
- : Temporal.Instant.compare(inst, afterInst) > 0;
512
- if (ok)
513
- return current;
514
- // count it toward COUNT
515
- matchCount++;
516
- if (this.opts.count !== undefined && matchCount >= this.opts.count) {
517
- return null;
518
- }
519
- }
520
- // stop on UNTIL
521
- if (this.opts.until &&
522
- Temporal.ZonedDateTime.compare(current, this.opts.until) >= 0) {
523
- return null;
524
- }
525
- current = this.applyTimeOverride(this.rawAdvance(current));
365
+ if (this.opts.freq === "YEARLY" && this.opts.byMonth) {
366
+ const start = this.originalDtstart;
367
+ const months = [...this.opts.byMonth].sort((a, b) => a - b);
368
+ let i = 0;
369
+ outer: while (true) {
370
+ const year = start.year + i * this.opts.interval;
371
+ const month = months[i % months.length];
372
+ let occ = start.with({ year, month });
373
+ occ = this.applyTimeOverride(occ);
374
+ const inst = occ.toInstant();
375
+ if (inc ? Temporal.Instant.compare(inst, endInst) > 0 : Temporal.Instant.compare(inst, endInst) >= 0) {
376
+ break;
377
+ }
378
+ if (Temporal.Instant.compare(inst, startInst) >= 0) {
379
+ results.push(occ);
526
380
  }
381
+ i++;
382
+ }
383
+ return results;
527
384
  }
528
- /**
529
- * Returns the previous occurrence of the rule before a specified date.
530
- * @param before - The end date or Temporal.ZonedDateTime object.
531
- * @param inc - Optional boolean flag to include occurrences on the end date.
532
- * @returns The previous occurrence of the rule before the specified date or null if no occurrences are found.
533
- */
534
- previous(before = new Date(), inc = false) {
535
- const beforeInst = before instanceof Date
536
- ? Temporal.Instant.from(before.toISOString())
537
- : before.toInstant();
538
- let current = this.computeFirst();
539
- let prev = null;
540
- while (true) {
541
- const inst = current.toInstant();
542
- // if beyond window, stop
543
- if (inc
544
- ? Temporal.Instant.compare(inst, beforeInst) > 0
545
- : Temporal.Instant.compare(inst, beforeInst) >= 0) {
546
- break;
547
- }
548
- // track it if it matches constraints
549
- if (this.matchesAll(current)) {
550
- prev = current;
551
- }
552
- if (this.opts.until &&
553
- Temporal.ZonedDateTime.compare(current, this.opts.until) >= 0) {
554
- break;
555
- }
556
- current = this.applyTimeOverride(this.rawAdvance(current));
385
+ if (this.opts.freq === "WEEKLY") {
386
+ const startInst2 = after instanceof Date ? Temporal.Instant.from(after.toISOString()) : after.toInstant();
387
+ const endInst2 = before instanceof Date ? Temporal.Instant.from(before.toISOString()) : before.toInstant();
388
+ let weekCursor = this.computeFirst();
389
+ const results2 = [];
390
+ outer: while (true) {
391
+ const occs = this.generateWeeklyOccurrences(weekCursor);
392
+ for (const occ of occs) {
393
+ const inst = occ.toInstant();
394
+ if (inc ? Temporal.Instant.compare(inst, endInst2) > 0 : Temporal.Instant.compare(inst, endInst2) >= 0) {
395
+ break outer;
396
+ }
397
+ if (Temporal.Instant.compare(inst, startInst2) >= 0) {
398
+ results2.push(occ);
399
+ }
557
400
  }
558
- return prev;
401
+ weekCursor = weekCursor.add({ weeks: this.opts.interval });
402
+ }
403
+ return results2;
559
404
  }
560
- toString() {
561
- const iso = this.originalDtstart
562
- .toString({ smallestUnit: "second" })
563
- .replace(/[-:]/g, "");
564
- const dtLine = `DTSTART;TZID=${this.tzid}:${iso.slice(0, 15)}`;
565
- const parts = [];
566
- const { freq, interval, count, byHour, byMinute, byDay, byMonth } = this.opts;
567
- parts.push(`FREQ=${freq}`);
568
- if (interval !== 1)
569
- parts.push(`INTERVAL=${interval}`);
570
- if (count !== undefined)
571
- parts.push(`COUNT=${count}`);
572
- if (byHour)
573
- parts.push(`BYHOUR=${byHour.join(",")}`);
574
- if (byMinute)
575
- parts.push(`BYMINUTE=${byMinute.join(",")}`);
576
- if (byDay)
577
- parts.push(`BYDAY=${byDay.join(",")}`);
578
- if (byMonth)
579
- parts.push(`BYMONTH=${byMonth.join(",")}`);
580
- return [dtLine, `RRULE:${parts.join(";")}`].join("\n");
405
+ let current = this.computeFirst();
406
+ while (true) {
407
+ const inst = current.toInstant();
408
+ if (inc) {
409
+ if (Temporal.Instant.compare(inst, endInst) > 0) break;
410
+ } else {
411
+ if (Temporal.Instant.compare(inst, endInst) >= 0) break;
412
+ }
413
+ if (Temporal.Instant.compare(inst, startInst) >= 0 && this.matchesAll(current)) {
414
+ results.push(current);
415
+ }
416
+ current = this.applyTimeOverride(this.rawAdvance(current));
581
417
  }
582
- /**
583
- * Given any date in a month, return all the ZonedDateTimes in that month
584
- * matching your opts.byDay and opts.byMonth (or the single "same day" if no BYDAY).
585
- */
586
- generateMonthlyOccurrences(sample) {
587
- const { byDay, byMonth, tzid } = this.opts;
588
- // 1) Skip entire month if BYMONTH excludes it
589
- if (byMonth && !byMonth.includes(sample.month)) {
590
- return [];
418
+ return results;
419
+ }
420
+ /**
421
+ * Returns the next occurrence of the rule after a specified date.
422
+ * @param after - The start date or Temporal.ZonedDateTime object.
423
+ * @param inc - Optional boolean flag to include occurrences on the start date.
424
+ * @returns The next occurrence of the rule after the specified date or null if no occurrences are found.
425
+ */
426
+ next(after = /* @__PURE__ */ new Date(), inc = false) {
427
+ const afterInst = after instanceof Date ? Temporal.Instant.from(after.toISOString()) : after.toInstant();
428
+ let current = this.computeFirst();
429
+ let matchCount = 0;
430
+ while (true) {
431
+ const inst = current.toInstant();
432
+ if (this.matchesAll(current)) {
433
+ const ok = inc ? Temporal.Instant.compare(inst, afterInst) >= 0 : Temporal.Instant.compare(inst, afterInst) > 0;
434
+ if (ok) return current;
435
+ matchCount++;
436
+ if (this.opts.count !== void 0 && matchCount >= this.opts.count) {
437
+ return null;
591
438
  }
592
- // 2) If no BYDAY, just return the sample (we'll override time later)
593
- if (!byDay || byDay.length === 0) {
594
- return [sample];
595
- }
596
- // Map MO,TU…SU → dayOfWeek numbers
597
- const dayMap = {
598
- MO: 1,
599
- TU: 2,
600
- WE: 3,
601
- TH: 4,
602
- FR: 5,
603
- SA: 6,
604
- SU: 7,
605
- };
606
- const tokens = byDay
607
- .map((tok) => {
608
- const m = tok.match(/^([+-]?\d)?(MO|TU|WE|TH|FR|SA|SU)$/);
609
- if (!m)
610
- return null;
611
- const ord = m[1] ? parseInt(m[1], 10) : 0;
612
- const wd = dayMap[m[2]];
613
- return { ord, wd };
614
- })
615
- .filter((x) => x !== null);
616
- // 3) Build a map from weekday → all day‑of‑month numbers
617
- const year = sample.year;
618
- const month = sample.month;
619
- let cursor = Temporal.ZonedDateTime.from({
620
- year,
621
- month,
622
- day: 1,
623
- hour: sample.hour,
624
- minute: sample.minute,
625
- second: sample.second,
626
- timeZone: tzid,
627
- });
628
- const weekdayBuckets = {};
629
- while (cursor.month === month) {
630
- const dow = cursor.dayOfWeek;
631
- weekdayBuckets[dow] = weekdayBuckets[dow] || [];
632
- weekdayBuckets[dow].push(cursor.day);
633
- cursor = cursor.add({ days: 1 });
439
+ }
440
+ if (this.opts.until && Temporal.ZonedDateTime.compare(current, this.opts.until) >= 0) {
441
+ return null;
442
+ }
443
+ current = this.applyTimeOverride(this.rawAdvance(current));
444
+ }
445
+ }
446
+ /**
447
+ * Returns the previous occurrence of the rule before a specified date.
448
+ * @param before - The end date or Temporal.ZonedDateTime object.
449
+ * @param inc - Optional boolean flag to include occurrences on the end date.
450
+ * @returns The previous occurrence of the rule before the specified date or null if no occurrences are found.
451
+ */
452
+ previous(before = /* @__PURE__ */ new Date(), inc = false) {
453
+ const beforeInst = before instanceof Date ? Temporal.Instant.from(before.toISOString()) : before.toInstant();
454
+ let current = this.computeFirst();
455
+ let prev = null;
456
+ while (true) {
457
+ const inst = current.toInstant();
458
+ if (inc ? Temporal.Instant.compare(inst, beforeInst) > 0 : Temporal.Instant.compare(inst, beforeInst) >= 0) {
459
+ break;
460
+ }
461
+ if (this.matchesAll(current)) {
462
+ prev = current;
463
+ }
464
+ if (this.opts.until && Temporal.ZonedDateTime.compare(current, this.opts.until) >= 0) {
465
+ break;
466
+ }
467
+ current = this.applyTimeOverride(this.rawAdvance(current));
468
+ }
469
+ return prev;
470
+ }
471
+ toString() {
472
+ const iso = this.originalDtstart.toString({ smallestUnit: "second" }).replace(/[-:]/g, "");
473
+ const dtLine = `DTSTART;TZID=${this.tzid}:${iso.slice(0, 15)}`;
474
+ const parts = [];
475
+ const { freq, interval, count, byHour, byMinute, byDay, byMonth } = this.opts;
476
+ parts.push(`FREQ=${freq}`);
477
+ if (interval !== 1) parts.push(`INTERVAL=${interval}`);
478
+ if (count !== void 0) parts.push(`COUNT=${count}`);
479
+ if (byHour) parts.push(`BYHOUR=${byHour.join(",")}`);
480
+ if (byMinute) parts.push(`BYMINUTE=${byMinute.join(",")}`);
481
+ if (byDay) parts.push(`BYDAY=${byDay.join(",")}`);
482
+ if (byMonth) parts.push(`BYMONTH=${byMonth.join(",")}`);
483
+ return [dtLine, `RRULE:${parts.join(";")}`].join("\n");
484
+ }
485
+ /**
486
+ * Given any date in a month, return all the ZonedDateTimes in that month
487
+ * matching your opts.byDay and opts.byMonth (or the single "same day" if no BYDAY).
488
+ */
489
+ generateMonthlyOccurrences(sample) {
490
+ const { byDay, byMonth, tzid } = this.opts;
491
+ if (byMonth && !byMonth.includes(sample.month)) {
492
+ return [];
493
+ }
494
+ if (!byDay || byDay.length === 0) {
495
+ return [sample];
496
+ }
497
+ const dayMap = {
498
+ MO: 1,
499
+ TU: 2,
500
+ WE: 3,
501
+ TH: 4,
502
+ FR: 5,
503
+ SA: 6,
504
+ SU: 7
505
+ };
506
+ const tokens = byDay.map((tok) => {
507
+ const m = tok.match(/^([+-]?\d)?(MO|TU|WE|TH|FR|SA|SU)$/);
508
+ if (!m) return null;
509
+ const ord = m[1] ? parseInt(m[1], 10) : 0;
510
+ const wd = dayMap[m[2]];
511
+ return { ord, wd };
512
+ }).filter((x) => x !== null);
513
+ const year = sample.year;
514
+ const month = sample.month;
515
+ let cursor = Temporal.ZonedDateTime.from({
516
+ year,
517
+ month,
518
+ day: 1,
519
+ hour: sample.hour,
520
+ minute: sample.minute,
521
+ second: sample.second,
522
+ timeZone: tzid
523
+ });
524
+ const weekdayBuckets = {};
525
+ while (cursor.month === month) {
526
+ const dow = cursor.dayOfWeek;
527
+ weekdayBuckets[dow] = weekdayBuckets[dow] || [];
528
+ weekdayBuckets[dow].push(cursor.day);
529
+ cursor = cursor.add({ days: 1 });
530
+ }
531
+ const results = [];
532
+ for (const { ord, wd } of tokens) {
533
+ const days = weekdayBuckets[wd] || [];
534
+ if (!days.length) continue;
535
+ if (ord === 0) {
536
+ for (const d of days) {
537
+ results.push(sample.with({ day: d }));
634
538
  }
635
- // 4) For each token, pick the right day‑of‑month
636
- const results = [];
637
- for (const { ord, wd } of tokens) {
638
- const days = weekdayBuckets[wd] || [];
639
- if (!days.length)
640
- continue;
641
- if (ord === 0) {
642
- // simple weekday: include *all* Fridays, e.g.
643
- for (const d of days) {
644
- results.push(sample.with({ day: d }));
645
- }
646
- }
647
- else {
648
- // ordinal: 2FR → days[1], -1FR → days[days.length-1], etc.
649
- const idx = ord > 0 ? ord - 1 : days.length + ord;
650
- const dayNum = days[idx];
651
- if (dayNum) {
652
- results.push(sample.with({ day: dayNum }));
653
- }
654
- }
539
+ } else {
540
+ const idx = ord > 0 ? ord - 1 : days.length + ord;
541
+ const dayNum = days[idx];
542
+ if (dayNum) {
543
+ results.push(sample.with({ day: dayNum }));
655
544
  }
656
- // 5) Apply your BYHOUR/BYMINUTE overrides and sort chronologically
657
- return results
658
- .map((zdt) => this.applyTimeOverride(zdt))
659
- .sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
545
+ }
660
546
  }
661
- }
547
+ return results.map((zdt) => this.applyTimeOverride(zdt)).sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
548
+ }
549
+ };
550
+ export {
551
+ RRuleTemporal
552
+ };