rrule-temporal 1.1.0 → 1.1.2
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/README.md +2 -1
- package/dist/chunk-6A2XASAM.js +1335 -0
- package/dist/index.cjs +374 -291
- package/dist/index.d.cts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +1 -1
- package/dist/totext.cjs +417 -358
- package/dist/totext.js +43 -67
- package/package.json +2 -2
package/dist/totext.cjs
CHANGED
|
@@ -43,52 +43,61 @@ var import_polyfill = require("@js-temporal/polyfill");
|
|
|
43
43
|
function unfoldLine(foldedLine) {
|
|
44
44
|
return foldedLine.replace(/\r?\n[ \t]/g, "");
|
|
45
45
|
}
|
|
46
|
-
function parseDateValues(dateValues, tzid) {
|
|
46
|
+
function parseDateValues(dateValues, tzid, valueType) {
|
|
47
47
|
const dates = [];
|
|
48
48
|
for (const dateValue of dateValues) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const isDate = valueType === "DATE" || !dateValue.includes("T");
|
|
50
|
+
if (isDate) {
|
|
51
|
+
const isoDate = `${dateValue.slice(0, 4)}-${dateValue.slice(4, 6)}-${dateValue.slice(6, 8)}`;
|
|
52
|
+
dates.push(import_polyfill.Temporal.PlainDate.from(isoDate).toZonedDateTime({ timeZone: tzid }));
|
|
52
53
|
} else {
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
if (/Z$/.test(dateValue)) {
|
|
55
|
+
const iso = `${dateValue.slice(0, 4)}-${dateValue.slice(4, 6)}-${dateValue.slice(6, 8)}T${dateValue.slice(9, 15)}Z`;
|
|
56
|
+
dates.push(import_polyfill.Temporal.Instant.from(iso).toZonedDateTimeISO(tzid || "UTC"));
|
|
57
|
+
} else {
|
|
58
|
+
const isoDate = `${dateValue.slice(0, 4)}-${dateValue.slice(4, 6)}-${dateValue.slice(6, 8)}T${dateValue.slice(9)}`;
|
|
59
|
+
dates.push(import_polyfill.Temporal.PlainDateTime.from(isoDate).toZonedDateTime(tzid));
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
return dates;
|
|
58
64
|
}
|
|
59
65
|
function parseRRuleString(input, targetTimezone) {
|
|
60
|
-
var _a
|
|
66
|
+
var _a;
|
|
61
67
|
const unfoldedInput = unfoldLine(input).trim();
|
|
62
68
|
let dtstart;
|
|
63
69
|
let tzid = "UTC";
|
|
64
70
|
let rruleLine;
|
|
65
71
|
let exDate = [];
|
|
66
72
|
let rDate = [];
|
|
67
|
-
if (/^DTSTART/
|
|
73
|
+
if (/^DTSTART/im.test(unfoldedInput)) {
|
|
68
74
|
const lines = unfoldedInput.split(/\s+/);
|
|
69
|
-
const dtLine = lines
|
|
75
|
+
const dtLine = lines.find((line) => line.match(/^DTSTART/i));
|
|
70
76
|
const rrLine = lines.find((line) => line.match(/^RRULE:/i));
|
|
71
77
|
const exLines = lines.filter((line) => line.match(/^EXDATE/i));
|
|
72
78
|
const rLines = lines.filter((line) => line.match(/^RDATE/i));
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
const dtMatch = dtLine.match(/DTSTART(?:;VALUE=([^;]+))?(?:;TZID=([^:]+))?:(.+)/i);
|
|
80
|
+
if (!dtMatch) throw new Error("Invalid DTSTART in ICS snippet");
|
|
81
|
+
const [, valueType, dtTzid, dtValue] = dtMatch;
|
|
82
|
+
tzid = (_a = dtTzid != null ? dtTzid : targetTimezone) != null ? _a : tzid;
|
|
83
|
+
dtstart = parseDateValues([dtValue], tzid, valueType)[0];
|
|
77
84
|
rruleLine = rrLine;
|
|
78
85
|
for (const exLine of exLines) {
|
|
79
|
-
const exMatch = exLine.match(/EXDATE(?:;TZID=([^:]+))?:(.+)/i);
|
|
86
|
+
const exMatch = exLine.match(/EXDATE(?:;VALUE=([^;]+))?(?:;TZID=([^:]+))?:(.+)/i);
|
|
80
87
|
if (exMatch) {
|
|
81
|
-
const exTzid = exMatch
|
|
82
|
-
const
|
|
83
|
-
|
|
88
|
+
const [, valueType2, exTzid, dateValuesStr] = exMatch;
|
|
89
|
+
const exTimezone = exTzid || tzid;
|
|
90
|
+
const dateValues = dateValuesStr.split(",");
|
|
91
|
+
exDate.push(...parseDateValues(dateValues, exTimezone, valueType2));
|
|
84
92
|
}
|
|
85
93
|
}
|
|
86
94
|
for (const rLine of rLines) {
|
|
87
|
-
const rMatch = rLine.match(/RDATE(?:;TZID=([^:]+))?:(.+)/i);
|
|
95
|
+
const rMatch = rLine.match(/RDATE(?:;VALUE=([^;]+))?(?:;TZID=([^:]+))?:(.+)/i);
|
|
88
96
|
if (rMatch) {
|
|
89
|
-
const rTzid = rMatch
|
|
90
|
-
const
|
|
91
|
-
|
|
97
|
+
const [, valueType2, rTzid, dateValuesStr] = rMatch;
|
|
98
|
+
const rTimezone = rTzid || tzid;
|
|
99
|
+
const dateValues = dateValuesStr.split(",");
|
|
100
|
+
rDate.push(...parseDateValues(dateValues, rTimezone, valueType2));
|
|
92
101
|
}
|
|
93
102
|
}
|
|
94
103
|
} else {
|
|
@@ -117,14 +126,13 @@ function parseRRuleString(input, targetTimezone) {
|
|
|
117
126
|
case "UNTIL": {
|
|
118
127
|
if (/Z$/.test(val)) {
|
|
119
128
|
const iso = `${val.slice(0, 4)}-${val.slice(4, 6)}-${val.slice(6, 8)}T${val.slice(9, 15)}Z`;
|
|
120
|
-
opts.until = import_polyfill.Temporal.Instant.from(iso).toZonedDateTimeISO(
|
|
121
|
-
tzid || "UTC"
|
|
122
|
-
);
|
|
129
|
+
opts.until = import_polyfill.Temporal.Instant.from(iso).toZonedDateTimeISO(tzid || "UTC");
|
|
123
130
|
} else {
|
|
124
131
|
const iso = `${val.slice(0, 4)}-${val.slice(4, 6)}-${val.slice(6, 8)}T${val.slice(9, 15)}`;
|
|
125
|
-
opts.until = import_polyfill.Temporal.PlainDateTime.from(iso).toZonedDateTime(
|
|
126
|
-
|
|
127
|
-
|
|
132
|
+
opts.until = import_polyfill.Temporal.PlainDateTime.from(iso).toZonedDateTime(tzid || "UTC");
|
|
133
|
+
if (tzid !== "UTC") {
|
|
134
|
+
throw new Error("UNTIL rule part MUST always be specified as a date with UTC time");
|
|
135
|
+
}
|
|
128
136
|
}
|
|
129
137
|
break;
|
|
130
138
|
}
|
|
@@ -162,7 +170,7 @@ function parseRRuleString(input, targetTimezone) {
|
|
|
162
170
|
}
|
|
163
171
|
return opts;
|
|
164
172
|
}
|
|
165
|
-
var RRuleTemporal = class {
|
|
173
|
+
var RRuleTemporal = class _RRuleTemporal {
|
|
166
174
|
constructor(params) {
|
|
167
175
|
var _a, _b, _c, _d, _e;
|
|
168
176
|
let manual;
|
|
@@ -227,6 +235,9 @@ var RRuleTemporal = class {
|
|
|
227
235
|
if (opts.bySecond.length === 0) delete opts.bySecond;
|
|
228
236
|
}
|
|
229
237
|
if (opts.bySetPos) {
|
|
238
|
+
if (opts.bySetPos.some((p) => p === 0)) {
|
|
239
|
+
throw new Error("bySetPos may not contain 0");
|
|
240
|
+
}
|
|
230
241
|
opts.bySetPos = opts.bySetPos.filter((n) => Number.isInteger(n) && n !== 0);
|
|
231
242
|
if (opts.bySetPos.length === 0) delete opts.bySetPos;
|
|
232
243
|
}
|
|
@@ -335,9 +346,73 @@ var RRuleTemporal = class {
|
|
|
335
346
|
return dt;
|
|
336
347
|
}
|
|
337
348
|
computeFirst() {
|
|
338
|
-
var _a;
|
|
349
|
+
var _a, _b, _c;
|
|
339
350
|
let zdt = this.originalDtstart;
|
|
340
|
-
if ((_a = this.opts.
|
|
351
|
+
if (((_a = this.opts.byWeekNo) == null ? void 0 : _a.length) && ["DAILY", "HOURLY", "MINUTELY", "SECONDLY"].includes(this.opts.freq)) {
|
|
352
|
+
let targetWeek = this.opts.byWeekNo[0];
|
|
353
|
+
let targetYear = zdt.year;
|
|
354
|
+
while (targetYear <= zdt.year + 10) {
|
|
355
|
+
const jan1 = zdt.with({ year: targetYear, month: 1, day: 1 });
|
|
356
|
+
const dec31 = zdt.with({ year: targetYear, month: 12, day: 31 });
|
|
357
|
+
let hasTargetWeek = false;
|
|
358
|
+
if (targetWeek > 0) {
|
|
359
|
+
let maxWeek = 52;
|
|
360
|
+
if (jan1.dayOfWeek === 4 || dec31.dayOfWeek === 4) {
|
|
361
|
+
maxWeek = 53;
|
|
362
|
+
}
|
|
363
|
+
hasTargetWeek = targetWeek <= maxWeek;
|
|
364
|
+
} else {
|
|
365
|
+
let maxWeek = 52;
|
|
366
|
+
if (jan1.dayOfWeek === 4 || dec31.dayOfWeek === 4) {
|
|
367
|
+
maxWeek = 53;
|
|
368
|
+
}
|
|
369
|
+
hasTargetWeek = -targetWeek <= maxWeek;
|
|
370
|
+
}
|
|
371
|
+
if (hasTargetWeek) {
|
|
372
|
+
const firstThursday = jan1.add({ days: (4 - jan1.dayOfWeek + 7) % 7 });
|
|
373
|
+
let weekStart;
|
|
374
|
+
if (targetWeek > 0) {
|
|
375
|
+
weekStart = firstThursday.subtract({ days: 3 }).add({ weeks: targetWeek - 1 });
|
|
376
|
+
} else {
|
|
377
|
+
const lastWeek = jan1.dayOfWeek === 4 || dec31.dayOfWeek === 4 ? 53 : 52;
|
|
378
|
+
weekStart = firstThursday.subtract({ days: 3 }).add({ weeks: lastWeek + targetWeek });
|
|
379
|
+
}
|
|
380
|
+
if ((_b = this.opts.byDay) == null ? void 0 : _b.length) {
|
|
381
|
+
const dayMap = {
|
|
382
|
+
MO: 1,
|
|
383
|
+
TU: 2,
|
|
384
|
+
WE: 3,
|
|
385
|
+
TH: 4,
|
|
386
|
+
FR: 5,
|
|
387
|
+
SA: 6,
|
|
388
|
+
SU: 7
|
|
389
|
+
};
|
|
390
|
+
const targetDays = this.opts.byDay.map((tok) => {
|
|
391
|
+
var _a2;
|
|
392
|
+
return (_a2 = tok.match(/(MO|TU|WE|TH|FR|SA|SU)$/)) == null ? void 0 : _a2[1];
|
|
393
|
+
}).filter(Boolean).map((day) => dayMap[day]).filter(Boolean);
|
|
394
|
+
if (targetDays.length) {
|
|
395
|
+
const candidates = targetDays.map((dayOfWeek) => {
|
|
396
|
+
const delta = (dayOfWeek - weekStart.dayOfWeek + 7) % 7;
|
|
397
|
+
return weekStart.add({ days: delta });
|
|
398
|
+
});
|
|
399
|
+
const firstCandidate = candidates.sort((a, b) => import_polyfill.Temporal.ZonedDateTime.compare(a, b))[0];
|
|
400
|
+
if (firstCandidate && import_polyfill.Temporal.ZonedDateTime.compare(firstCandidate, this.originalDtstart) >= 0) {
|
|
401
|
+
zdt = firstCandidate;
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
} else {
|
|
406
|
+
if (import_polyfill.Temporal.ZonedDateTime.compare(weekStart, this.originalDtstart) >= 0) {
|
|
407
|
+
zdt = weekStart;
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
targetYear++;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (((_c = this.opts.byDay) == null ? void 0 : _c.length) && !this.opts.byWeekNo) {
|
|
341
416
|
const dayMap = {
|
|
342
417
|
MO: 1,
|
|
343
418
|
TU: 2,
|
|
@@ -349,9 +424,7 @@ var RRuleTemporal = class {
|
|
|
349
424
|
};
|
|
350
425
|
let deltas = [];
|
|
351
426
|
if (["DAILY", "HOURLY", "MINUTELY", "SECONDLY"].includes(this.opts.freq) && this.opts.byDay.every((tok) => /^[A-Z]{2}$/.test(tok))) {
|
|
352
|
-
deltas = this.opts.byDay.map(
|
|
353
|
-
(tok) => (dayMap[tok] - zdt.dayOfWeek + 7) % 7
|
|
354
|
-
);
|
|
427
|
+
deltas = this.opts.byDay.map((tok) => (dayMap[tok] - zdt.dayOfWeek + 7) % 7);
|
|
355
428
|
} else {
|
|
356
429
|
deltas = this.opts.byDay.map((tok) => {
|
|
357
430
|
var _a2;
|
|
@@ -364,42 +437,27 @@ var RRuleTemporal = class {
|
|
|
364
437
|
}
|
|
365
438
|
}
|
|
366
439
|
const { byHour, byMinute, bySecond } = this.opts;
|
|
440
|
+
if (this.opts.freq === "HOURLY" && !byHour && import_polyfill.Temporal.ZonedDateTime.compare(
|
|
441
|
+
zdt.with({ hour: 0, minute: 0, second: 0, microsecond: 0, nanosecond: 0 }),
|
|
442
|
+
this.originalDtstart
|
|
443
|
+
) > 0) {
|
|
444
|
+
zdt = zdt.with({ hour: 0, minute: 0, second: 0, microsecond: 0, nanosecond: 0 });
|
|
445
|
+
}
|
|
367
446
|
if (byHour || byMinute || bySecond) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
zdt = this.applyTimeOverride(this.rawAdvance(this.originalDtstart));
|
|
447
|
+
const candidates = this.expandByTime(zdt);
|
|
448
|
+
for (const candidate of candidates) {
|
|
449
|
+
if (import_polyfill.Temporal.ZonedDateTime.compare(candidate, this.originalDtstart) >= 0) {
|
|
450
|
+
return candidate;
|
|
451
|
+
}
|
|
374
452
|
}
|
|
453
|
+
zdt = this.applyTimeOverride(this.rawAdvance(zdt));
|
|
375
454
|
}
|
|
376
455
|
return zdt;
|
|
377
456
|
}
|
|
378
|
-
// inside class RRuleTemporal:
|
|
379
|
-
generateWeeklyOccurrences(sample) {
|
|
380
|
-
var _a;
|
|
381
|
-
const dayMap = {
|
|
382
|
-
MO: 1,
|
|
383
|
-
TU: 2,
|
|
384
|
-
WE: 3,
|
|
385
|
-
TH: 4,
|
|
386
|
-
FR: 5,
|
|
387
|
-
SA: 6,
|
|
388
|
-
SU: 7
|
|
389
|
-
};
|
|
390
|
-
const tokens = ((_a = this.opts.byDay) == null ? void 0 : _a.length) ? [...this.opts.byDay] : [Object.entries(dayMap).find(([, d]) => d === sample.dayOfWeek)[0]];
|
|
391
|
-
const occs = tokens.flatMap((tok) => {
|
|
392
|
-
const targetDow = dayMap[tok];
|
|
393
|
-
const delta = (targetDow - sample.dayOfWeek + 7) % 7;
|
|
394
|
-
const sameDate = sample.add({ days: delta });
|
|
395
|
-
return this.expandByTime(sameDate);
|
|
396
|
-
});
|
|
397
|
-
return occs.sort((a, b) => import_polyfill.Temporal.ZonedDateTime.compare(a, b));
|
|
398
|
-
}
|
|
399
457
|
// --- NEW: constraint checks ---
|
|
400
458
|
// 2) Replace your matchesByDay with this:
|
|
401
459
|
matchesByDay(zdt) {
|
|
402
|
-
const { byDay } = this.opts;
|
|
460
|
+
const { byDay, freq } = this.opts;
|
|
403
461
|
if (!byDay) return true;
|
|
404
462
|
const dayMap = {
|
|
405
463
|
MO: 1,
|
|
@@ -417,6 +475,10 @@ var RRuleTemporal = class {
|
|
|
417
475
|
const weekday = m[2];
|
|
418
476
|
if (!weekday) continue;
|
|
419
477
|
const wd = dayMap[weekday];
|
|
478
|
+
if (freq === "DAILY") {
|
|
479
|
+
if (zdt.dayOfWeek === wd) return true;
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
420
482
|
if (ord === 0) {
|
|
421
483
|
if (zdt.dayOfWeek === wd) return true;
|
|
422
484
|
continue;
|
|
@@ -442,9 +504,7 @@ var RRuleTemporal = class {
|
|
|
442
504
|
const { byMonthDay } = this.opts;
|
|
443
505
|
if (!byMonthDay) return true;
|
|
444
506
|
const lastDay = zdt.with({ day: 1 }).add({ months: 1 }).subtract({ days: 1 }).day;
|
|
445
|
-
return byMonthDay.some(
|
|
446
|
-
(d) => d > 0 ? zdt.day === d : zdt.day === lastDay + d + 1
|
|
447
|
-
);
|
|
507
|
+
return byMonthDay.some((d) => d > 0 ? zdt.day === d : zdt.day === lastDay + d + 1);
|
|
448
508
|
}
|
|
449
509
|
matchesAll(zdt) {
|
|
450
510
|
return this.matchesByDay(zdt) && this.matchesByMonth(zdt) && this.matchesByMonthDay(zdt) && this.matchesByYearDay(zdt) && this.matchesByWeekNo(zdt);
|
|
@@ -456,19 +516,31 @@ var RRuleTemporal = class {
|
|
|
456
516
|
const last = zdt.with({ month: 12, day: 31 }).dayOfYear;
|
|
457
517
|
return byYearDay.some((d) => d > 0 ? dayOfYear === d : dayOfYear === last + d + 1);
|
|
458
518
|
}
|
|
519
|
+
getIsoWeekInfo(zdt) {
|
|
520
|
+
const thursday = zdt.add({ days: 4 - zdt.dayOfWeek });
|
|
521
|
+
const year = thursday.year;
|
|
522
|
+
const firstThursday = thursday.with({ month: 1, day: 1 }).add({ days: (4 - thursday.with({ month: 1, day: 1 }).dayOfWeek + 7) % 7 });
|
|
523
|
+
const diffDays = thursday.toPlainDate().since(firstThursday.toPlainDate()).days;
|
|
524
|
+
const week = Math.floor(diffDays / 7) + 1;
|
|
525
|
+
return { week, year };
|
|
526
|
+
}
|
|
459
527
|
matchesByWeekNo(zdt) {
|
|
460
|
-
const { byWeekNo
|
|
528
|
+
const { byWeekNo } = this.opts;
|
|
461
529
|
if (!byWeekNo) return true;
|
|
462
|
-
const
|
|
463
|
-
const
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
530
|
+
const { week, year } = this.getIsoWeekInfo(zdt);
|
|
531
|
+
const jan1 = zdt.with({ year, month: 1, day: 1 });
|
|
532
|
+
const dec31 = zdt.with({ year, month: 12, day: 31 });
|
|
533
|
+
let lastWeek = 52;
|
|
534
|
+
if (jan1.dayOfWeek === 4 || dec31.dayOfWeek === 4) {
|
|
535
|
+
lastWeek = 53;
|
|
536
|
+
}
|
|
537
|
+
return byWeekNo.some((wn) => {
|
|
538
|
+
if (wn > 0) {
|
|
539
|
+
return week === wn;
|
|
540
|
+
} else {
|
|
541
|
+
return week === lastWeek + wn + 1;
|
|
542
|
+
}
|
|
543
|
+
});
|
|
472
544
|
}
|
|
473
545
|
options() {
|
|
474
546
|
return this.opts;
|
|
@@ -488,14 +560,14 @@ var RRuleTemporal = class {
|
|
|
488
560
|
if (this.opts.freq === "MONTHLY" && (this.opts.byDay || this.opts.byMonthDay)) {
|
|
489
561
|
const start = this.originalDtstart;
|
|
490
562
|
let monthCursor = start.with({ day: 1 });
|
|
491
|
-
let
|
|
563
|
+
let matchCount = 0;
|
|
492
564
|
if (this.includeDtstart && !this.matchesAll(start)) {
|
|
493
|
-
if (iterator && !iterator(start,
|
|
565
|
+
if (iterator && !iterator(start, matchCount)) {
|
|
494
566
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
495
567
|
}
|
|
496
568
|
dates.push(start);
|
|
497
|
-
|
|
498
|
-
if (this.shouldBreakForCountLimit(
|
|
569
|
+
matchCount++;
|
|
570
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
499
571
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
500
572
|
}
|
|
501
573
|
}
|
|
@@ -503,7 +575,8 @@ var RRuleTemporal = class {
|
|
|
503
575
|
if (++iterationCount > this.maxIterations) {
|
|
504
576
|
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
505
577
|
}
|
|
506
|
-
|
|
578
|
+
let occs = this.generateMonthlyOccurrences(monthCursor);
|
|
579
|
+
occs = this.applyBySetPos(occs);
|
|
507
580
|
if (monthCursor.month === start.month && occs.some((o) => import_polyfill.Temporal.ZonedDateTime.compare(o, start) < 0) && occs.some((o) => import_polyfill.Temporal.ZonedDateTime.compare(o, start) === 0)) {
|
|
508
581
|
monthCursor = monthCursor.add({ months: this.opts.interval });
|
|
509
582
|
continue outer_month;
|
|
@@ -513,12 +586,12 @@ var RRuleTemporal = class {
|
|
|
513
586
|
if (this.opts.until && import_polyfill.Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
|
|
514
587
|
break outer_month;
|
|
515
588
|
}
|
|
516
|
-
if (iterator && !iterator(occ,
|
|
589
|
+
if (iterator && !iterator(occ, matchCount)) {
|
|
517
590
|
break outer_month;
|
|
518
591
|
}
|
|
519
592
|
dates.push(occ);
|
|
520
|
-
|
|
521
|
-
if (this.shouldBreakForCountLimit(
|
|
593
|
+
matchCount++;
|
|
594
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
522
595
|
break outer_month;
|
|
523
596
|
}
|
|
524
597
|
}
|
|
@@ -527,6 +600,45 @@ var RRuleTemporal = class {
|
|
|
527
600
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
528
601
|
}
|
|
529
602
|
if (this.opts.freq === "WEEKLY") {
|
|
603
|
+
if (this.opts.byYearDay && this.opts.byYearDay.length > 0) {
|
|
604
|
+
const start2 = this.originalDtstart;
|
|
605
|
+
if (this.includeDtstart && !this.matchesAll(start2)) {
|
|
606
|
+
if (iterator && !iterator(start2, 0)) {
|
|
607
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
608
|
+
}
|
|
609
|
+
dates.push(start2);
|
|
610
|
+
if (this.shouldBreakForCountLimit(1)) {
|
|
611
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
let yearCursor = start2.with({ month: 1, day: 1 });
|
|
615
|
+
let matchCount2 = dates.length;
|
|
616
|
+
outer_year_for_weekly: while (true) {
|
|
617
|
+
if (++iterationCount > this.maxIterations) {
|
|
618
|
+
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
619
|
+
}
|
|
620
|
+
const occs = this.generateYearlyOccurrences(yearCursor);
|
|
621
|
+
for (const occ of occs) {
|
|
622
|
+
if (import_polyfill.Temporal.ZonedDateTime.compare(occ, start2) < 0) continue;
|
|
623
|
+
if (this.opts.until && import_polyfill.Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
|
|
624
|
+
break outer_year_for_weekly;
|
|
625
|
+
}
|
|
626
|
+
if (iterator && !iterator(occ, matchCount2)) {
|
|
627
|
+
break outer_year_for_weekly;
|
|
628
|
+
}
|
|
629
|
+
dates.push(occ);
|
|
630
|
+
matchCount2++;
|
|
631
|
+
if (this.shouldBreakForCountLimit(matchCount2)) {
|
|
632
|
+
break outer_year_for_weekly;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (this.opts.until && yearCursor.year > this.opts.until.year) {
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
yearCursor = yearCursor.add({ years: 1 });
|
|
639
|
+
}
|
|
640
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
641
|
+
}
|
|
530
642
|
const start = this.originalDtstart;
|
|
531
643
|
if (this.includeDtstart && !this.matchesAll(start)) {
|
|
532
644
|
if (iterator && !iterator(start, 0)) {
|
|
@@ -546,39 +658,44 @@ var RRuleTemporal = class {
|
|
|
546
658
|
SA: 6,
|
|
547
659
|
SU: 7
|
|
548
660
|
};
|
|
549
|
-
const tokens = this.opts.byDay ? [...this.opts.byDay] : [Object.entries(dayMap).find(([, d]) => d === start.dayOfWeek)[0]];
|
|
550
|
-
const dows = tokens.map((tok) => dayMap[tok]).filter((d) => d !== void 0).sort((a, b) => a - b);
|
|
661
|
+
const tokens = this.opts.byDay ? [...this.opts.byDay] : this.opts.byMonthDay && this.opts.byMonthDay.length > 0 ? Object.keys(dayMap) : [Object.entries(dayMap).find(([, d]) => d === start.dayOfWeek)[0]];
|
|
662
|
+
const dows = tokens.map((tok) => dayMap[tok.slice(-2)]).filter((d) => d !== void 0).sort((a, b) => a - b);
|
|
551
663
|
const firstWeekDates = dows.map((dw) => {
|
|
552
664
|
const delta = (dw - start.dayOfWeek + 7) % 7;
|
|
553
665
|
return start.add({ days: delta });
|
|
554
666
|
});
|
|
555
|
-
let firstOccurrence = firstWeekDates.reduce(
|
|
556
|
-
(a, b) => import_polyfill.Temporal.ZonedDateTime.compare(a, b) <= 0 ? a : b
|
|
557
|
-
);
|
|
667
|
+
let firstOccurrence = firstWeekDates.reduce((a, b) => import_polyfill.Temporal.ZonedDateTime.compare(a, b) <= 0 ? a : b);
|
|
558
668
|
const wkstDay = (_a = dayMap[this.opts.wkst || "MO"]) != null ? _a : 1;
|
|
559
669
|
const firstOccWeekOffset = (firstOccurrence.dayOfWeek - wkstDay + 7) % 7;
|
|
560
670
|
let weekCursor = firstOccurrence.subtract({ days: firstOccWeekOffset });
|
|
561
|
-
let
|
|
671
|
+
let matchCount = 0;
|
|
562
672
|
outer_week: while (true) {
|
|
563
673
|
if (++iterationCount > this.maxIterations) {
|
|
564
674
|
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
565
675
|
}
|
|
566
|
-
|
|
676
|
+
let occs = dows.flatMap((dw) => {
|
|
567
677
|
const delta = (dw - wkstDay + 7) % 7;
|
|
568
678
|
const sameDate = weekCursor.add({ days: delta });
|
|
569
679
|
return this.expandByTime(sameDate);
|
|
570
680
|
}).sort((a, b) => import_polyfill.Temporal.ZonedDateTime.compare(a, b));
|
|
681
|
+
occs = this.applyBySetPos(occs);
|
|
571
682
|
for (const occ of occs) {
|
|
572
683
|
if (import_polyfill.Temporal.ZonedDateTime.compare(occ, start) < 0) continue;
|
|
573
684
|
if (this.opts.until && import_polyfill.Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
|
|
574
685
|
break outer_week;
|
|
575
686
|
}
|
|
576
|
-
if (
|
|
687
|
+
if (!this.matchesByMonth(occ)) {
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (!this.matchesByMonthDay(occ)) {
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
if (iterator && !iterator(occ, matchCount)) {
|
|
577
694
|
break outer_week;
|
|
578
695
|
}
|
|
579
696
|
dates.push(occ);
|
|
580
|
-
|
|
581
|
-
if (this.shouldBreakForCountLimit(
|
|
697
|
+
matchCount++;
|
|
698
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
582
699
|
break outer_week;
|
|
583
700
|
}
|
|
584
701
|
}
|
|
@@ -586,7 +703,7 @@ var RRuleTemporal = class {
|
|
|
586
703
|
}
|
|
587
704
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
588
705
|
}
|
|
589
|
-
if (this.opts.freq === "MONTHLY" && this.opts.byMonth && !this.opts.byDay && !this.opts.byMonthDay) {
|
|
706
|
+
if (this.opts.freq === "MONTHLY" && this.opts.byMonth && !this.opts.byDay && !this.opts.byMonthDay && !this.opts.byYearDay) {
|
|
590
707
|
const start = this.originalDtstart;
|
|
591
708
|
if (this.includeDtstart && !this.matchesAll(start)) {
|
|
592
709
|
if (iterator && !iterator(start, 0)) {
|
|
@@ -599,7 +716,7 @@ var RRuleTemporal = class {
|
|
|
599
716
|
}
|
|
600
717
|
const months = [...this.opts.byMonth].sort((a, b) => a - b);
|
|
601
718
|
let monthOffset = 0;
|
|
602
|
-
let
|
|
719
|
+
let matchCount = dates.length;
|
|
603
720
|
let startMonthIndex = months.findIndex((m) => m >= start.month);
|
|
604
721
|
if (startMonthIndex === -1) {
|
|
605
722
|
startMonthIndex = 0;
|
|
@@ -620,12 +737,12 @@ var RRuleTemporal = class {
|
|
|
620
737
|
break;
|
|
621
738
|
}
|
|
622
739
|
if (import_polyfill.Temporal.ZonedDateTime.compare(candidate, start) >= 0) {
|
|
623
|
-
if (iterator && !iterator(candidate,
|
|
740
|
+
if (iterator && !iterator(candidate, matchCount)) {
|
|
624
741
|
break;
|
|
625
742
|
}
|
|
626
743
|
dates.push(candidate);
|
|
627
|
-
|
|
628
|
-
if (this.shouldBreakForCountLimit(
|
|
744
|
+
matchCount++;
|
|
745
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
629
746
|
break;
|
|
630
747
|
}
|
|
631
748
|
}
|
|
@@ -633,7 +750,7 @@ var RRuleTemporal = class {
|
|
|
633
750
|
}
|
|
634
751
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
635
752
|
}
|
|
636
|
-
if (this.opts.freq === "YEARLY" && this.opts.byMonth && !this.opts.byDay && !this.opts.byMonthDay) {
|
|
753
|
+
if (this.opts.freq === "YEARLY" && this.opts.byMonth && !this.opts.byDay && !this.opts.byMonthDay && !this.opts.byYearDay && !this.opts.byWeekNo) {
|
|
637
754
|
const start = this.originalDtstart;
|
|
638
755
|
if (this.includeDtstart && !this.matchesAll(start)) {
|
|
639
756
|
if (iterator && !iterator(start, 0)) {
|
|
@@ -646,7 +763,7 @@ var RRuleTemporal = class {
|
|
|
646
763
|
}
|
|
647
764
|
const months = [...this.opts.byMonth].sort((a, b) => a - b);
|
|
648
765
|
let yearOffset = 0;
|
|
649
|
-
let
|
|
766
|
+
let matchCount = 0;
|
|
650
767
|
while (true) {
|
|
651
768
|
if (++iterationCount > this.maxIterations) {
|
|
652
769
|
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
@@ -661,12 +778,12 @@ var RRuleTemporal = class {
|
|
|
661
778
|
if (this.opts.until && import_polyfill.Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
|
|
662
779
|
return dates;
|
|
663
780
|
}
|
|
664
|
-
if (iterator && !iterator(occ,
|
|
781
|
+
if (iterator && !iterator(occ, matchCount)) {
|
|
665
782
|
return dates;
|
|
666
783
|
}
|
|
667
784
|
dates.push(occ);
|
|
668
|
-
|
|
669
|
-
if (this.shouldBreakForCountLimit(
|
|
785
|
+
matchCount++;
|
|
786
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
670
787
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
671
788
|
}
|
|
672
789
|
}
|
|
@@ -686,7 +803,7 @@ var RRuleTemporal = class {
|
|
|
686
803
|
}
|
|
687
804
|
}
|
|
688
805
|
let yearCursor = start.with({ month: 1, day: 1 });
|
|
689
|
-
let
|
|
806
|
+
let matchCount = 0;
|
|
690
807
|
outer_year: while (true) {
|
|
691
808
|
if (++iterationCount > this.maxIterations) {
|
|
692
809
|
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
@@ -697,12 +814,12 @@ var RRuleTemporal = class {
|
|
|
697
814
|
if (this.opts.until && import_polyfill.Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
|
|
698
815
|
break outer_year;
|
|
699
816
|
}
|
|
700
|
-
if (iterator && !iterator(occ,
|
|
817
|
+
if (iterator && !iterator(occ, matchCount)) {
|
|
701
818
|
break outer_year;
|
|
702
819
|
}
|
|
703
820
|
dates.push(occ);
|
|
704
|
-
|
|
705
|
-
if (this.shouldBreakForCountLimit(
|
|
821
|
+
matchCount++;
|
|
822
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
706
823
|
break outer_year;
|
|
707
824
|
}
|
|
708
825
|
}
|
|
@@ -722,7 +839,7 @@ var RRuleTemporal = class {
|
|
|
722
839
|
}
|
|
723
840
|
}
|
|
724
841
|
let yearCursor = start.with({ month: 1, day: 1 });
|
|
725
|
-
let
|
|
842
|
+
let matchCount = 0;
|
|
726
843
|
outer_year2: while (true) {
|
|
727
844
|
if (++iterationCount > this.maxIterations) {
|
|
728
845
|
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
@@ -733,12 +850,12 @@ var RRuleTemporal = class {
|
|
|
733
850
|
if (this.opts.until && import_polyfill.Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
|
|
734
851
|
break outer_year2;
|
|
735
852
|
}
|
|
736
|
-
if (iterator && !iterator(occ,
|
|
853
|
+
if (iterator && !iterator(occ, matchCount)) {
|
|
737
854
|
break outer_year2;
|
|
738
855
|
}
|
|
739
856
|
dates.push(occ);
|
|
740
|
-
|
|
741
|
-
if (this.shouldBreakForCountLimit(
|
|
857
|
+
matchCount++;
|
|
858
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
742
859
|
break outer_year2;
|
|
743
860
|
}
|
|
744
861
|
}
|
|
@@ -746,36 +863,141 @@ var RRuleTemporal = class {
|
|
|
746
863
|
}
|
|
747
864
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
748
865
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
if (
|
|
753
|
-
|
|
866
|
+
if (this.opts.freq === "MONTHLY" && this.opts.byYearDay && this.opts.byYearDay.length > 0 && !this.opts.byDay && !this.opts.byMonthDay) {
|
|
867
|
+
const start = this.originalDtstart;
|
|
868
|
+
let matchCount = 0;
|
|
869
|
+
if (this.includeDtstart && !this.matchesAll(start)) {
|
|
870
|
+
if (iterator && !iterator(start, matchCount)) {
|
|
871
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
872
|
+
}
|
|
873
|
+
dates.push(start);
|
|
874
|
+
matchCount++;
|
|
875
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
876
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
877
|
+
}
|
|
754
878
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
879
|
+
let year = start.year;
|
|
880
|
+
const yearDays = [...this.opts.byYearDay].sort((a, b) => a - b);
|
|
881
|
+
const interval = this.opts.interval;
|
|
882
|
+
const startMonthAbs = start.year * 12 + start.month;
|
|
883
|
+
outer_loop: while (true) {
|
|
884
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
if (++iterationCount > this.maxIterations) {
|
|
888
|
+
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
889
|
+
}
|
|
890
|
+
const yearStart = start.with({ year, month: 1, day: 1 });
|
|
891
|
+
const lastDayOfYear = yearStart.with({ month: 12, day: 31 }).dayOfYear;
|
|
892
|
+
for (const yd of yearDays) {
|
|
893
|
+
const dayNum = yd > 0 ? yd : lastDayOfYear + yd + 1;
|
|
894
|
+
if (dayNum <= 0 || dayNum > lastDayOfYear) continue;
|
|
895
|
+
const baseOcc = yearStart.add({ days: dayNum - 1 });
|
|
896
|
+
for (const occ of this.expandByTime(baseOcc)) {
|
|
897
|
+
if (import_polyfill.Temporal.ZonedDateTime.compare(occ, start) < 0) continue;
|
|
898
|
+
if (dates.some((d) => import_polyfill.Temporal.ZonedDateTime.compare(d, occ) === 0)) continue;
|
|
899
|
+
const occMonthAbs = occ.year * 12 + occ.month;
|
|
900
|
+
if ((occMonthAbs - startMonthAbs) % interval !== 0) {
|
|
901
|
+
continue;
|
|
902
|
+
}
|
|
903
|
+
if (!this.matchesByMonth(occ)) {
|
|
904
|
+
continue;
|
|
905
|
+
}
|
|
906
|
+
if (this.opts.until && import_polyfill.Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
|
|
907
|
+
break outer_loop;
|
|
908
|
+
}
|
|
909
|
+
if (iterator && !iterator(occ, matchCount)) {
|
|
910
|
+
break outer_loop;
|
|
911
|
+
}
|
|
912
|
+
dates.push(occ);
|
|
913
|
+
matchCount++;
|
|
914
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
915
|
+
break outer_loop;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
year++;
|
|
920
|
+
if (this.opts.until && year > this.opts.until.year + 2) {
|
|
921
|
+
break;
|
|
922
|
+
}
|
|
923
|
+
if (!this.opts.until && this.opts.count) {
|
|
924
|
+
const yearsToScan = Math.ceil(this.opts.count / (this.opts.byYearDay.length || 1)) * interval + 5;
|
|
925
|
+
if (year > start.year + yearsToScan) {
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
759
929
|
}
|
|
930
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
760
931
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
932
|
+
if (this.opts.freq === "DAILY" && this.opts.bySetPos) {
|
|
933
|
+
let start = this.originalDtstart;
|
|
934
|
+
let matchCount = 0;
|
|
935
|
+
if (this.includeDtstart && !this.matchesAll(start)) {
|
|
936
|
+
if (iterator && !iterator(start, matchCount)) {
|
|
937
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
938
|
+
}
|
|
939
|
+
dates.push(start);
|
|
940
|
+
matchCount++;
|
|
941
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
942
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
943
|
+
}
|
|
764
944
|
}
|
|
765
|
-
|
|
766
|
-
|
|
945
|
+
let dayCursor = start.with({ hour: 0, minute: 0, second: 0, microsecond: 0, nanosecond: 0 });
|
|
946
|
+
outer_daily: while (true) {
|
|
947
|
+
if (++iterationCount > this.maxIterations) {
|
|
948
|
+
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
949
|
+
}
|
|
950
|
+
let dayOccs = this.expandByTime(dayCursor);
|
|
951
|
+
dayOccs = dayOccs.filter((occ) => this.matchesAll(occ));
|
|
952
|
+
dayOccs = this.applyBySetPos(dayOccs);
|
|
953
|
+
for (const occ of dayOccs) {
|
|
954
|
+
if (import_polyfill.Temporal.ZonedDateTime.compare(occ, start) < 0) continue;
|
|
955
|
+
if (this.opts.until && import_polyfill.Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) {
|
|
956
|
+
break outer_daily;
|
|
957
|
+
}
|
|
958
|
+
if (iterator && !iterator(occ, matchCount)) {
|
|
959
|
+
break outer_daily;
|
|
960
|
+
}
|
|
961
|
+
dates.push(occ);
|
|
962
|
+
matchCount++;
|
|
963
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
964
|
+
break outer_daily;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
dayCursor = dayCursor.add({ days: this.opts.interval });
|
|
767
968
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
969
|
+
} else {
|
|
970
|
+
let current = this.computeFirst();
|
|
971
|
+
let matchCount = 0;
|
|
972
|
+
if (this.includeDtstart && import_polyfill.Temporal.ZonedDateTime.compare(current, this.originalDtstart) > 0) {
|
|
973
|
+
if (iterator && !iterator(this.originalDtstart, matchCount)) {
|
|
974
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
771
975
|
}
|
|
772
|
-
dates.push(
|
|
976
|
+
dates.push(this.originalDtstart);
|
|
773
977
|
matchCount++;
|
|
774
978
|
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
979
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
while (true) {
|
|
983
|
+
if (++iterationCount > this.maxIterations) {
|
|
984
|
+
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
985
|
+
}
|
|
986
|
+
if (this.opts.until && import_polyfill.Temporal.ZonedDateTime.compare(current, this.opts.until) > 0) {
|
|
775
987
|
break;
|
|
776
988
|
}
|
|
989
|
+
if (this.matchesAll(current)) {
|
|
990
|
+
if (iterator && !iterator(current, matchCount)) {
|
|
991
|
+
break;
|
|
992
|
+
}
|
|
993
|
+
dates.push(current);
|
|
994
|
+
matchCount++;
|
|
995
|
+
if (this.shouldBreakForCountLimit(matchCount)) {
|
|
996
|
+
break;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
current = this.nextCandidateSameDate(current);
|
|
777
1000
|
}
|
|
778
|
-
current = this.nextCandidateSameDate(current);
|
|
779
1001
|
}
|
|
780
1002
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
781
1003
|
}
|
|
@@ -804,9 +1026,7 @@ var RRuleTemporal = class {
|
|
|
804
1026
|
excludeExDates(dates) {
|
|
805
1027
|
if (!this.opts.exDate || this.opts.exDate.length === 0) return dates;
|
|
806
1028
|
return dates.filter((date) => {
|
|
807
|
-
return !this.opts.exDate.some(
|
|
808
|
-
(exDate) => import_polyfill.Temporal.ZonedDateTime.compare(date, exDate) === 0
|
|
809
|
-
);
|
|
1029
|
+
return !this.opts.exDate.some((exDate) => import_polyfill.Temporal.ZonedDateTime.compare(date, exDate) === 0);
|
|
810
1030
|
});
|
|
811
1031
|
}
|
|
812
1032
|
/**
|
|
@@ -856,140 +1076,20 @@ var RRuleTemporal = class {
|
|
|
856
1076
|
between(after, before, inc = false) {
|
|
857
1077
|
const startInst = after instanceof Date ? import_polyfill.Temporal.Instant.from(after.toISOString()) : after.toInstant();
|
|
858
1078
|
const endInst = before instanceof Date ? import_polyfill.Temporal.Instant.from(before.toISOString()) : before.toInstant();
|
|
859
|
-
const
|
|
860
|
-
|
|
861
|
-
if (
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
const startOk = inc ? import_polyfill.Temporal.Instant.compare(inst, startInst) >= 0 : import_polyfill.Temporal.Instant.compare(inst, startInst) > 0;
|
|
874
|
-
if (startOk) {
|
|
875
|
-
results.push(occ);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
monthCursor = monthCursor.add({ months: this.opts.interval });
|
|
879
|
-
}
|
|
880
|
-
return this.mergeRDates(results, startInst, endInst, inc);
|
|
881
|
-
}
|
|
882
|
-
if (this.opts.freq === "YEARLY" && this.opts.byMonth && !this.opts.byDay && !this.opts.byMonthDay) {
|
|
883
|
-
const start = this.originalDtstart;
|
|
884
|
-
const months = [...this.opts.byMonth].sort((a, b) => a - b);
|
|
885
|
-
let yearOffset = 0;
|
|
886
|
-
outer: while (true) {
|
|
887
|
-
if (++iterationCount > this.maxIterations) {
|
|
888
|
-
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in between()`);
|
|
889
|
-
}
|
|
890
|
-
const year = start.year + yearOffset * this.opts.interval;
|
|
891
|
-
for (const month of months) {
|
|
892
|
-
let occ = start.with({ year, month });
|
|
893
|
-
occ = this.applyTimeOverride(occ);
|
|
894
|
-
const inst = occ.toInstant();
|
|
895
|
-
if (inc ? import_polyfill.Temporal.Instant.compare(inst, endInst) > 0 : import_polyfill.Temporal.Instant.compare(inst, endInst) >= 0) {
|
|
896
|
-
break outer;
|
|
897
|
-
}
|
|
898
|
-
const startOk = inc ? import_polyfill.Temporal.Instant.compare(inst, startInst) >= 0 : import_polyfill.Temporal.Instant.compare(inst, startInst) > 0;
|
|
899
|
-
if (startOk) {
|
|
900
|
-
results.push(occ);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
yearOffset++;
|
|
904
|
-
}
|
|
905
|
-
return this.mergeRDates(results, startInst, endInst, inc);
|
|
906
|
-
}
|
|
907
|
-
if (this.opts.freq === "YEARLY" && (this.opts.byDay || this.opts.byMonthDay)) {
|
|
908
|
-
const start = this.originalDtstart;
|
|
909
|
-
let yearCursor = start.with({ month: 1, day: 1 });
|
|
910
|
-
outer_year: while (true) {
|
|
911
|
-
if (++iterationCount > this.maxIterations) {
|
|
912
|
-
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in between()`);
|
|
913
|
-
}
|
|
914
|
-
const occs = this.generateYearlyOccurrences(yearCursor);
|
|
915
|
-
for (const occ of occs) {
|
|
916
|
-
const inst = occ.toInstant();
|
|
917
|
-
if (inc ? import_polyfill.Temporal.Instant.compare(inst, endInst) > 0 : import_polyfill.Temporal.Instant.compare(inst, endInst) >= 0) {
|
|
918
|
-
break outer_year;
|
|
919
|
-
}
|
|
920
|
-
const startOk = inc ? import_polyfill.Temporal.Instant.compare(inst, startInst) >= 0 : import_polyfill.Temporal.Instant.compare(inst, startInst) > 0;
|
|
921
|
-
if (startOk) {
|
|
922
|
-
results.push(occ);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
yearCursor = yearCursor.add({ years: this.opts.interval });
|
|
926
|
-
}
|
|
927
|
-
return this.mergeRDates(results, startInst, endInst, inc);
|
|
928
|
-
}
|
|
929
|
-
if (this.opts.freq === "YEARLY" && (this.opts.byYearDay || this.opts.byWeekNo)) {
|
|
930
|
-
const start = this.originalDtstart;
|
|
931
|
-
let yearCursor = start.with({ month: 1, day: 1 });
|
|
932
|
-
outer_year2: while (true) {
|
|
933
|
-
if (++iterationCount > this.maxIterations) {
|
|
934
|
-
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in between()`);
|
|
935
|
-
}
|
|
936
|
-
const occs = this.generateYearlyOccurrences(yearCursor);
|
|
937
|
-
for (const occ of occs) {
|
|
938
|
-
const inst = occ.toInstant();
|
|
939
|
-
if (inc ? import_polyfill.Temporal.Instant.compare(inst, endInst) > 0 : import_polyfill.Temporal.Instant.compare(inst, endInst) >= 0) {
|
|
940
|
-
break outer_year2;
|
|
941
|
-
}
|
|
942
|
-
const startOk = inc ? import_polyfill.Temporal.Instant.compare(inst, startInst) >= 0 : import_polyfill.Temporal.Instant.compare(inst, startInst) > 0;
|
|
943
|
-
if (startOk) {
|
|
944
|
-
results.push(occ);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
yearCursor = yearCursor.add({ years: this.opts.interval });
|
|
948
|
-
}
|
|
949
|
-
return this.mergeRDates(results, startInst, endInst, inc);
|
|
950
|
-
}
|
|
951
|
-
if (this.opts.freq === "WEEKLY") {
|
|
952
|
-
const startInst2 = after instanceof Date ? import_polyfill.Temporal.Instant.from(after.toISOString()) : after.toInstant();
|
|
953
|
-
const endInst2 = before instanceof Date ? import_polyfill.Temporal.Instant.from(before.toISOString()) : before.toInstant();
|
|
954
|
-
let weekCursor = this.computeFirst();
|
|
955
|
-
const results2 = [];
|
|
956
|
-
outer: while (true) {
|
|
957
|
-
if (++iterationCount > this.maxIterations) {
|
|
958
|
-
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in between()`);
|
|
959
|
-
}
|
|
960
|
-
const occs = this.generateWeeklyOccurrences(weekCursor);
|
|
961
|
-
for (const occ of occs) {
|
|
962
|
-
const inst = occ.toInstant();
|
|
963
|
-
if (inc ? import_polyfill.Temporal.Instant.compare(inst, endInst2) > 0 : import_polyfill.Temporal.Instant.compare(inst, endInst2) >= 0) {
|
|
964
|
-
break outer;
|
|
965
|
-
}
|
|
966
|
-
const startOk = inc ? import_polyfill.Temporal.Instant.compare(inst, startInst2) >= 0 : import_polyfill.Temporal.Instant.compare(inst, startInst2) > 0;
|
|
967
|
-
if (startOk) {
|
|
968
|
-
results2.push(occ);
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
weekCursor = weekCursor.add({ weeks: this.opts.interval });
|
|
972
|
-
}
|
|
973
|
-
return this.mergeRDates(results2, startInst2, endInst2, inc);
|
|
974
|
-
}
|
|
975
|
-
let current = this.computeFirst();
|
|
976
|
-
while (true) {
|
|
977
|
-
if (++iterationCount > this.maxIterations) {
|
|
978
|
-
throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in between()`);
|
|
979
|
-
}
|
|
980
|
-
const inst = current.toInstant();
|
|
981
|
-
if (inc) {
|
|
982
|
-
if (import_polyfill.Temporal.Instant.compare(inst, endInst) > 0) break;
|
|
983
|
-
} else {
|
|
984
|
-
if (import_polyfill.Temporal.Instant.compare(inst, endInst) >= 0) break;
|
|
985
|
-
}
|
|
986
|
-
const startOk = inc ? import_polyfill.Temporal.Instant.compare(inst, startInst) >= 0 : import_polyfill.Temporal.Instant.compare(inst, startInst) > 0;
|
|
987
|
-
if (startOk && this.matchesAll(current)) {
|
|
988
|
-
results.push(current);
|
|
989
|
-
}
|
|
990
|
-
current = this.nextCandidateSameDate(current);
|
|
991
|
-
}
|
|
992
|
-
return this.mergeRDates(results, startInst, endInst, inc);
|
|
1079
|
+
const beforeZdt = import_polyfill.Temporal.Instant.from(endInst).toZonedDateTimeISO(this.tzid);
|
|
1080
|
+
const tempOpts = __spreadValues({}, this.opts);
|
|
1081
|
+
if (!tempOpts.until || import_polyfill.Temporal.ZonedDateTime.compare(beforeZdt, tempOpts.until) < 0) {
|
|
1082
|
+
tempOpts.until = beforeZdt;
|
|
1083
|
+
}
|
|
1084
|
+
delete tempOpts.count;
|
|
1085
|
+
const tempRule = new _RRuleTemporal(tempOpts);
|
|
1086
|
+
const allDates = tempRule.all();
|
|
1087
|
+
return allDates.filter((date) => {
|
|
1088
|
+
const inst = date.toInstant();
|
|
1089
|
+
const afterStart = inc ? import_polyfill.Temporal.Instant.compare(inst, startInst) >= 0 : import_polyfill.Temporal.Instant.compare(inst, startInst) > 0;
|
|
1090
|
+
const beforeEnd = inc ? import_polyfill.Temporal.Instant.compare(inst, endInst) <= 0 : import_polyfill.Temporal.Instant.compare(inst, endInst) < 0;
|
|
1091
|
+
return afterStart && beforeEnd;
|
|
1092
|
+
});
|
|
993
1093
|
}
|
|
994
1094
|
/**
|
|
995
1095
|
* Returns the next occurrence of the rule after a specified date.
|
|
@@ -1098,10 +1198,12 @@ var RRuleTemporal = class {
|
|
|
1098
1198
|
return [];
|
|
1099
1199
|
}
|
|
1100
1200
|
const dates = byMonthDayHits.map((d) => sample.with({ day: d }));
|
|
1101
|
-
|
|
1201
|
+
let expanded2 = dates.flatMap((z) => this.expandByTime(z)).sort((a, b) => import_polyfill.Temporal.ZonedDateTime.compare(a, b));
|
|
1202
|
+
return expanded2;
|
|
1102
1203
|
}
|
|
1103
1204
|
if (!byDay) {
|
|
1104
|
-
|
|
1205
|
+
const expanded2 = this.expandByTime(sample);
|
|
1206
|
+
return expanded2;
|
|
1105
1207
|
}
|
|
1106
1208
|
const dayMap = {
|
|
1107
1209
|
MO: 1,
|
|
@@ -1145,7 +1247,6 @@ var RRuleTemporal = class {
|
|
|
1145
1247
|
}
|
|
1146
1248
|
const hits = finalDays.map((d) => sample.with({ day: d }));
|
|
1147
1249
|
let expanded = hits.flatMap((z) => this.expandByTime(z)).sort((a, b) => import_polyfill.Temporal.ZonedDateTime.compare(a, b));
|
|
1148
|
-
expanded = this.applyBySetPos(expanded);
|
|
1149
1250
|
return expanded;
|
|
1150
1251
|
}
|
|
1151
1252
|
/**
|
|
@@ -1155,9 +1256,10 @@ var RRuleTemporal = class {
|
|
|
1155
1256
|
*/
|
|
1156
1257
|
generateYearlyOccurrences(sample) {
|
|
1157
1258
|
var _a;
|
|
1158
|
-
const months = this.opts.byMonth ? [...this.opts.byMonth].sort((a, b) => a - b) : [this.originalDtstart.month];
|
|
1259
|
+
const months = this.opts.byMonth ? [...this.opts.byMonth].sort((a, b) => a - b) : this.opts.byMonthDay ? [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] : [this.originalDtstart.month];
|
|
1159
1260
|
let occs = [];
|
|
1160
|
-
|
|
1261
|
+
const hasOrdinalByDay = this.opts.byDay && this.opts.byDay.some((t) => /^[+-]?\d/.test(t));
|
|
1262
|
+
if (hasOrdinalByDay && !this.opts.byMonth) {
|
|
1161
1263
|
const dayMap = {
|
|
1162
1264
|
MO: 1,
|
|
1163
1265
|
TU: 2,
|
|
@@ -1182,9 +1284,7 @@ var RRuleTemporal = class {
|
|
|
1182
1284
|
const delta = (dec31.dayOfWeek - wd + 7) % 7;
|
|
1183
1285
|
dt = dec31.subtract({ days: delta + 7 * (-ord - 1) });
|
|
1184
1286
|
}
|
|
1185
|
-
|
|
1186
|
-
occs.push(...this.expandByTime(dt));
|
|
1187
|
-
}
|
|
1287
|
+
occs.push(...this.expandByTime(dt));
|
|
1188
1288
|
}
|
|
1189
1289
|
} else if (!this.opts.byYearDay && !this.opts.byWeekNo) {
|
|
1190
1290
|
occs = months.flatMap((m) => {
|
|
@@ -1251,36 +1351,11 @@ var RRuleTemporal = class {
|
|
|
1251
1351
|
}
|
|
1252
1352
|
return out.sort((a, b) => import_polyfill.Temporal.ZonedDateTime.compare(a, b));
|
|
1253
1353
|
}
|
|
1254
|
-
mergeRDates(list2, startInst, endInst, inc) {
|
|
1255
|
-
if (!this.opts.rDate) return this.excludeExDates(list2);
|
|
1256
|
-
for (const z of this.opts.rDate) {
|
|
1257
|
-
const inst = z.toInstant();
|
|
1258
|
-
const startOk = inc ? import_polyfill.Temporal.Instant.compare(inst, startInst) >= 0 : import_polyfill.Temporal.Instant.compare(inst, startInst) > 0;
|
|
1259
|
-
const endOk = inc ? import_polyfill.Temporal.Instant.compare(inst, endInst) <= 0 : import_polyfill.Temporal.Instant.compare(inst, endInst) < 0;
|
|
1260
|
-
if (startOk && endOk) list2.push(z);
|
|
1261
|
-
}
|
|
1262
|
-
list2.sort((a, b) => import_polyfill.Temporal.ZonedDateTime.compare(a, b));
|
|
1263
|
-
const dedup = [];
|
|
1264
|
-
for (const d of list2) {
|
|
1265
|
-
if (dedup.length === 0 || import_polyfill.Temporal.ZonedDateTime.compare(d, dedup[dedup.length - 1]) !== 0) {
|
|
1266
|
-
dedup.push(d);
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
return this.excludeExDates(dedup);
|
|
1270
|
-
}
|
|
1271
1354
|
};
|
|
1272
1355
|
|
|
1273
1356
|
// src/totext.ts
|
|
1274
1357
|
var en = {
|
|
1275
|
-
weekdayNames: [
|
|
1276
|
-
"Monday",
|
|
1277
|
-
"Tuesday",
|
|
1278
|
-
"Wednesday",
|
|
1279
|
-
"Thursday",
|
|
1280
|
-
"Friday",
|
|
1281
|
-
"Saturday",
|
|
1282
|
-
"Sunday"
|
|
1283
|
-
],
|
|
1358
|
+
weekdayNames: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
|
1284
1359
|
monthNames: [
|
|
1285
1360
|
"January",
|
|
1286
1361
|
"February",
|
|
@@ -1447,20 +1522,7 @@ var hi = {
|
|
|
1447
1522
|
};
|
|
1448
1523
|
var yue = {
|
|
1449
1524
|
weekdayNames: ["\u661F\u671F\u4E00", "\u661F\u671F\u4E8C", "\u661F\u671F\u4E09", "\u661F\u671F\u56DB", "\u661F\u671F\u4E94", "\u661F\u671F\u516D", "\u661F\u671F\u65E5"],
|
|
1450
|
-
monthNames: [
|
|
1451
|
-
"\u4E00\u6708",
|
|
1452
|
-
"\u4E8C\u6708",
|
|
1453
|
-
"\u4E09\u6708",
|
|
1454
|
-
"\u56DB\u6708",
|
|
1455
|
-
"\u4E94\u6708",
|
|
1456
|
-
"\u516D\u6708",
|
|
1457
|
-
"\u4E03\u6708",
|
|
1458
|
-
"\u516B\u6708",
|
|
1459
|
-
"\u4E5D\u6708",
|
|
1460
|
-
"\u5341\u6708",
|
|
1461
|
-
"\u5341\u4E00\u6708",
|
|
1462
|
-
"\u5341\u4E8C\u6708"
|
|
1463
|
-
],
|
|
1525
|
+
monthNames: ["\u4E00\u6708", "\u4E8C\u6708", "\u4E09\u6708", "\u56DB\u6708", "\u4E94\u6708", "\u516D\u6708", "\u4E03\u6708", "\u516B\u6708", "\u4E5D\u6708", "\u5341\u6708", "\u5341\u4E00\u6708", "\u5341\u4E8C\u6708"],
|
|
1464
1526
|
units: {
|
|
1465
1527
|
year: { singular: "\u5E74", plural: "\u5E74" },
|
|
1466
1528
|
month: { singular: "\u6708", plural: "\u6708" },
|
|
@@ -1500,15 +1562,7 @@ var yue = {
|
|
|
1500
1562
|
ordinal: (n) => n < 0 ? "\u6700\u5F8C" : `\u7B2C${Math.abs(n)}`
|
|
1501
1563
|
};
|
|
1502
1564
|
var ar = {
|
|
1503
|
-
weekdayNames: [
|
|
1504
|
-
"\u0627\u0644\u0627\u062B\u0646\u064A\u0646",
|
|
1505
|
-
"\u0627\u0644\u062B\u0644\u0627\u062B\u0627\u0621",
|
|
1506
|
-
"\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621",
|
|
1507
|
-
"\u0627\u0644\u062E\u0645\u064A\u0633",
|
|
1508
|
-
"\u0627\u0644\u062C\u0645\u0639\u0629",
|
|
1509
|
-
"\u0627\u0644\u0633\u0628\u062A",
|
|
1510
|
-
"\u0627\u0644\u0623\u062D\u062F"
|
|
1511
|
-
],
|
|
1565
|
+
weekdayNames: ["\u0627\u0644\u0627\u062B\u0646\u064A\u0646", "\u0627\u0644\u062B\u0644\u0627\u062B\u0627\u0621", "\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621", "\u0627\u0644\u062E\u0645\u064A\u0633", "\u0627\u0644\u062C\u0645\u0639\u0629", "\u0627\u0644\u0633\u0628\u062A", "\u0627\u0644\u0623\u062D\u062F"],
|
|
1512
1566
|
monthNames: [
|
|
1513
1567
|
"\u064A\u0646\u0627\u064A\u0631",
|
|
1514
1568
|
"\u0641\u0628\u0631\u0627\u064A\u0631",
|
|
@@ -1581,15 +1635,7 @@ var ar = {
|
|
|
1581
1635
|
}
|
|
1582
1636
|
};
|
|
1583
1637
|
var he = {
|
|
1584
|
-
weekdayNames: [
|
|
1585
|
-
"\u05D9\u05D5\u05DD \u05E9\u05E0\u05D9",
|
|
1586
|
-
"\u05D9\u05D5\u05DD \u05E9\u05DC\u05D9\u05E9\u05D9",
|
|
1587
|
-
"\u05D9\u05D5\u05DD \u05E8\u05D1\u05D9\u05E2\u05D9",
|
|
1588
|
-
"\u05D9\u05D5\u05DD \u05D7\u05DE\u05D9\u05E9\u05D9",
|
|
1589
|
-
"\u05D9\u05D5\u05DD \u05E9\u05D9\u05E9\u05D9",
|
|
1590
|
-
"\u05D9\u05D5\u05DD \u05E9\u05D1\u05EA",
|
|
1591
|
-
"\u05D9\u05D5\u05DD \u05E8\u05D0\u05E9\u05D5\u05DF"
|
|
1592
|
-
],
|
|
1638
|
+
weekdayNames: ["\u05D9\u05D5\u05DD \u05E9\u05E0\u05D9", "\u05D9\u05D5\u05DD \u05E9\u05DC\u05D9\u05E9\u05D9", "\u05D9\u05D5\u05DD \u05E8\u05D1\u05D9\u05E2\u05D9", "\u05D9\u05D5\u05DD \u05D7\u05DE\u05D9\u05E9\u05D9", "\u05D9\u05D5\u05DD \u05E9\u05D9\u05E9\u05D9", "\u05D9\u05D5\u05DD \u05E9\u05D1\u05EA", "\u05D9\u05D5\u05DD \u05E8\u05D0\u05E9\u05D5\u05DF"],
|
|
1593
1639
|
monthNames: [
|
|
1594
1640
|
"\u05D9\u05E0\u05D5\u05D0\u05E8",
|
|
1595
1641
|
"\u05E4\u05D1\u05E8\u05D5\u05D0\u05E8",
|
|
@@ -1663,20 +1709,7 @@ var he = {
|
|
|
1663
1709
|
};
|
|
1664
1710
|
var zh = {
|
|
1665
1711
|
weekdayNames: ["\u661F\u671F\u4E00", "\u661F\u671F\u4E8C", "\u661F\u671F\u4E09", "\u661F\u671F\u56DB", "\u661F\u671F\u4E94", "\u661F\u671F\u516D", "\u661F\u671F\u65E5"],
|
|
1666
|
-
monthNames: [
|
|
1667
|
-
"\u4E00\u6708",
|
|
1668
|
-
"\u4E8C\u6708",
|
|
1669
|
-
"\u4E09\u6708",
|
|
1670
|
-
"\u56DB\u6708",
|
|
1671
|
-
"\u4E94\u6708",
|
|
1672
|
-
"\u516D\u6708",
|
|
1673
|
-
"\u4E03\u6708",
|
|
1674
|
-
"\u516B\u6708",
|
|
1675
|
-
"\u4E5D\u6708",
|
|
1676
|
-
"\u5341\u6708",
|
|
1677
|
-
"\u5341\u4E00\u6708",
|
|
1678
|
-
"\u5341\u4E8C\u6708"
|
|
1679
|
-
],
|
|
1712
|
+
monthNames: ["\u4E00\u6708", "\u4E8C\u6708", "\u4E09\u6708", "\u56DB\u6708", "\u4E94\u6708", "\u516D\u6708", "\u4E03\u6708", "\u516B\u6708", "\u4E5D\u6708", "\u5341\u6708", "\u5341\u4E00\u6708", "\u5341\u4E8C\u6708"],
|
|
1680
1713
|
units: {
|
|
1681
1714
|
year: { singular: "\u5E74", plural: "\u5E74" },
|
|
1682
1715
|
month: { singular: "\u6708", plural: "\u6708" },
|
|
@@ -1826,28 +1859,46 @@ function toText(input, locale) {
|
|
|
1826
1859
|
}
|
|
1827
1860
|
}
|
|
1828
1861
|
if (freq === "WEEKLY" && byDay && !isWeekdays && !isEveryday) {
|
|
1829
|
-
parts.push(
|
|
1862
|
+
parts.push(
|
|
1863
|
+
data.words.on,
|
|
1864
|
+
list(byDay, (t) => formatByDayToken(t, data), data.words.and)
|
|
1865
|
+
);
|
|
1830
1866
|
} else if (byDay && freq !== "WEEKLY") {
|
|
1831
|
-
parts.push(
|
|
1867
|
+
parts.push(
|
|
1868
|
+
data.words.on,
|
|
1869
|
+
list(byDay, (t) => formatByDayToken(t, data), data.words.and)
|
|
1870
|
+
);
|
|
1832
1871
|
}
|
|
1833
1872
|
if (byMonth) {
|
|
1834
|
-
parts.push(
|
|
1873
|
+
parts.push(
|
|
1874
|
+
data.words.in,
|
|
1875
|
+
list(byMonth, (m) => data.monthNames[m - 1], data.words.and)
|
|
1876
|
+
);
|
|
1835
1877
|
}
|
|
1836
1878
|
if (byMonthDay) {
|
|
1837
|
-
parts.push(
|
|
1879
|
+
parts.push(
|
|
1880
|
+
data.words.on_the,
|
|
1881
|
+
list(byMonthDay, (d) => ordinal(d, data), data.words.and),
|
|
1882
|
+
data.words.day_of_month
|
|
1883
|
+
);
|
|
1838
1884
|
}
|
|
1839
1885
|
if (byYearDay) {
|
|
1840
|
-
parts.push(
|
|
1886
|
+
parts.push(
|
|
1887
|
+
data.words.on_the,
|
|
1888
|
+
list(byYearDay, (d) => ordinal(d, data), data.words.and),
|
|
1889
|
+
data.words.day_of_year
|
|
1890
|
+
);
|
|
1841
1891
|
}
|
|
1842
1892
|
if (byWeekNo) {
|
|
1843
|
-
parts.push(
|
|
1893
|
+
parts.push(
|
|
1894
|
+
data.words.in_week,
|
|
1895
|
+
list(byWeekNo, (n) => n.toString(), data.words.and)
|
|
1896
|
+
);
|
|
1844
1897
|
}
|
|
1845
1898
|
if (byHour) {
|
|
1846
1899
|
const minutes = byMinute != null ? byMinute : [0];
|
|
1847
1900
|
const seconds = bySecond != null ? bySecond : [0];
|
|
1848
|
-
const times = byHour.flatMap(
|
|
1849
|
-
(h) => minutes.flatMap((m) => seconds.map((s) => formatTime(h, m, s)))
|
|
1850
|
-
);
|
|
1901
|
+
const times = byHour.flatMap((h) => minutes.flatMap((m) => seconds.map((s) => formatTime(h, m, s))));
|
|
1851
1902
|
parts.push(data.words.at, list(times, void 0, data.words.and));
|
|
1852
1903
|
parts.push(tzAbbreviation(opts.dtstart));
|
|
1853
1904
|
}
|
|
@@ -1864,14 +1915,22 @@ function toText(input, locale) {
|
|
|
1864
1915
|
parts.push(data.words.for, count.toString(), count === 1 ? data.words.time : data.words.times);
|
|
1865
1916
|
}
|
|
1866
1917
|
if (bySetPos) {
|
|
1867
|
-
parts.push(
|
|
1918
|
+
parts.push(
|
|
1919
|
+
data.words.on_the,
|
|
1920
|
+
list(bySetPos, (n) => ordinal(n, data), data.words.and),
|
|
1921
|
+
data.words.instance
|
|
1922
|
+
);
|
|
1868
1923
|
}
|
|
1869
1924
|
if (wkst) {
|
|
1870
1925
|
const wkName = formatByDayToken(wkst, data);
|
|
1871
1926
|
parts.push(data.words.week_starts_on, wkName);
|
|
1872
1927
|
}
|
|
1873
1928
|
if (rDate && rDate.length) {
|
|
1874
|
-
parts.push(
|
|
1929
|
+
parts.push(
|
|
1930
|
+
data.words.with,
|
|
1931
|
+
`${rDate.length}`,
|
|
1932
|
+
rDate.length === 1 ? data.words.additional_date : data.words.additional_dates
|
|
1933
|
+
);
|
|
1875
1934
|
}
|
|
1876
1935
|
if (exDate && exDate.length) {
|
|
1877
1936
|
parts.push(data.words.excluding, `${exDate.length}`, exDate.length === 1 ? data.words.date : data.words.dates);
|