rrule-temporal 2.2.0 → 2.2.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/index.cjs +1 -1
- package/dist/index.d.cts +44 -10
- package/dist/index.d.ts +44 -10
- package/dist/index.js +1 -1
- package/dist/{src-C6VoiyAb.cjs → src-B2AIB5jJ.cjs} +340 -169
- package/dist/{src-BY_Cxfjq.js → src-B2XO5sNr.js} +340 -169
- package/dist/totext.cjs +1 -1
- package/dist/totext.js +1 -1
- package/package.json +1 -1
|
@@ -4678,7 +4678,8 @@ function normalizeZonedDateTime(value, label) {
|
|
|
4678
4678
|
}
|
|
4679
4679
|
}
|
|
4680
4680
|
function normalizeZonedDateTimeList(values, label) {
|
|
4681
|
-
|
|
4681
|
+
if (!values?.length) return void 0;
|
|
4682
|
+
return values.map((value) => normalizeZonedDateTime(value, label));
|
|
4682
4683
|
}
|
|
4683
4684
|
function isIcsOpts(opts) {
|
|
4684
4685
|
return typeof opts.rruleString === "string";
|
|
@@ -4983,6 +4984,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
4983
4984
|
until: params.until ? RRuleTemporal.normalizeToPolyfill(params.until) : parsed.until,
|
|
4984
4985
|
strict: params.strict,
|
|
4985
4986
|
maxIterations: params.maxIterations,
|
|
4987
|
+
maxCandidateEvaluations: params.maxCandidateEvaluations,
|
|
4986
4988
|
includeDtstart: params.includeDtstart,
|
|
4987
4989
|
cache: params.cache,
|
|
4988
4990
|
temporal: params.temporal,
|
|
@@ -5006,6 +5008,8 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
5006
5008
|
if (manual.interval <= 0) throw new Error("Cannot create RRule: interval must be greater than 0");
|
|
5007
5009
|
this.opts = this.sanitizeOpts(manual);
|
|
5008
5010
|
this.maxIterations = manual.maxIterations ?? 1e4;
|
|
5011
|
+
this.maxCandidateEvaluations = manual.maxCandidateEvaluations ?? 1e6;
|
|
5012
|
+
if (!Number.isSafeInteger(this.maxCandidateEvaluations) || this.maxCandidateEvaluations <= 0) throw new Error("maxCandidateEvaluations must be a positive safe integer");
|
|
5009
5013
|
this.includeDtstart = manual.includeDtstart ?? false;
|
|
5010
5014
|
this.parsedByDayTokens = this.buildParsedByDayTokens(this.opts.byDay);
|
|
5011
5015
|
this.simpleByDayIsoDays = this.buildByDayIsoDays(this.parsedByDayTokens, false);
|
|
@@ -5037,25 +5041,35 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
5037
5041
|
}
|
|
5038
5042
|
sanitizeNumericArray(arr, min, max, allowZero = false, sort = false) {
|
|
5039
5043
|
if (!arr) return void 0;
|
|
5040
|
-
const sanitized =
|
|
5044
|
+
const sanitized = [];
|
|
5045
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5046
|
+
for (const value of arr) if (Number.isInteger(value) && value >= min && value <= max && (allowZero || value !== 0) && !seen.has(value)) {
|
|
5047
|
+
seen.add(value);
|
|
5048
|
+
sanitized.push(value);
|
|
5049
|
+
}
|
|
5041
5050
|
if (sanitized.length === 0) return void 0;
|
|
5042
5051
|
return sort ? sanitized.sort((a, b) => a - b) : sanitized;
|
|
5043
5052
|
}
|
|
5044
5053
|
sanitizeByDay(byDay) {
|
|
5045
|
-
const days = (byDay ?? []).filter((day) => Boolean(day) && typeof day === "string");
|
|
5046
5054
|
const normalized = [];
|
|
5047
|
-
|
|
5055
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5056
|
+
for (const day of byDay ?? []) {
|
|
5057
|
+
if (!day || typeof day !== "string") continue;
|
|
5048
5058
|
const token = day.toUpperCase();
|
|
5049
5059
|
const parsed = parseByDayToken(token);
|
|
5050
5060
|
if (!parsed) throw new Error(`Invalid BYDAY value: ${day}`);
|
|
5051
5061
|
if (parsed.ord === 0 && /^[+-]?\d/.test(token)) throw new Error(`Invalid BYDAY value: ${day}`);
|
|
5052
|
-
|
|
5062
|
+
if (!seen.has(token)) {
|
|
5063
|
+
seen.add(token);
|
|
5064
|
+
normalized.push(token);
|
|
5065
|
+
}
|
|
5053
5066
|
}
|
|
5054
5067
|
return normalized.length > 0 ? normalized : void 0;
|
|
5055
5068
|
}
|
|
5056
5069
|
enforceStrictRfc(opts) {
|
|
5057
5070
|
if (!opts.strict) return;
|
|
5058
5071
|
const freq = opts.freq;
|
|
5072
|
+
if (opts.count !== void 0 && opts.until !== void 0) throw new Error("COUNT and UNTIL MUST NOT occur in the same recurrence rule");
|
|
5059
5073
|
if (opts.byWeekNo && freq !== "YEARLY") throw new Error("BYWEEKNO MUST NOT be used unless FREQ=YEARLY");
|
|
5060
5074
|
if (opts.byYearDay && [
|
|
5061
5075
|
"DAILY",
|
|
@@ -5079,8 +5093,9 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
5079
5093
|
}
|
|
5080
5094
|
if (opts.byMonth) {
|
|
5081
5095
|
const numeric = opts.byMonth.filter((v) => typeof v === "number");
|
|
5082
|
-
const stringy = opts.byMonth.filter((v) => typeof v === "string");
|
|
5083
|
-
const
|
|
5096
|
+
const stringy = opts.byMonth.filter((v) => typeof v === "string").map((value) => value.toUpperCase());
|
|
5097
|
+
const sanitizedNum = this.sanitizeNumericArray(numeric, 1, 12, false, false) ?? [];
|
|
5098
|
+
const merged = [...new Set([...sanitizedNum, ...stringy])];
|
|
5084
5099
|
opts.byMonth = merged.length > 0 ? merged : void 0;
|
|
5085
5100
|
}
|
|
5086
5101
|
if (opts.rscale && !opts.skip) opts.skip = "OMIT";
|
|
@@ -5143,6 +5158,169 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
5143
5158
|
}));
|
|
5144
5159
|
return out.sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
|
|
5145
5160
|
}
|
|
5161
|
+
localDateKey(date) {
|
|
5162
|
+
return `${date.calendarId}:${date.year}:${date.month}:${date.day}`;
|
|
5163
|
+
}
|
|
5164
|
+
sortedUniqueDateCandidates(candidates) {
|
|
5165
|
+
const byLocalDate = /* @__PURE__ */ new Map();
|
|
5166
|
+
for (const candidate of candidates) {
|
|
5167
|
+
const key = this.localDateKey(candidate);
|
|
5168
|
+
if (!byLocalDate.has(key)) byLocalDate.set(key, candidate);
|
|
5169
|
+
}
|
|
5170
|
+
return [...byLocalDate.values()].sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
|
|
5171
|
+
}
|
|
5172
|
+
timeOfDayNanoseconds(date) {
|
|
5173
|
+
return ((date.hour * 60 * 60 + date.minute * 60 + date.second) * 1e3 + date.millisecond) * 1e6 + date.microsecond * 1e3 + date.nanosecond;
|
|
5174
|
+
}
|
|
5175
|
+
timeSlotNanoseconds(base, hour, minute, second) {
|
|
5176
|
+
return ((hour * 60 * 60 + minute * 60 + second) * 1e3 + base.millisecond) * 1e6 + base.microsecond * 1e3 + base.nanosecond;
|
|
5177
|
+
}
|
|
5178
|
+
/**
|
|
5179
|
+
* `ZonedDateTime.with()` can reorder or alias wall-clock slots on a day with
|
|
5180
|
+
* an offset transition (notably when a spring-forward gap is resolved). On
|
|
5181
|
+
* those uncommon dates we retain the legacy sort semantics with a bounded
|
|
5182
|
+
* one-day fallback instead of ever materializing a whole recurrence period.
|
|
5183
|
+
*/
|
|
5184
|
+
needsSortedTimeFallback(base) {
|
|
5185
|
+
try {
|
|
5186
|
+
const startOfDay = base.startOfDay();
|
|
5187
|
+
return startOfDay.add({ days: 1 }).startOfDay().epochNanoseconds - startOfDay.epochNanoseconds !== BigInt(864e11);
|
|
5188
|
+
} catch {
|
|
5189
|
+
return true;
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
5192
|
+
createCandidateWorkBudget() {
|
|
5193
|
+
return {
|
|
5194
|
+
evaluated: 0,
|
|
5195
|
+
seenOccurrences: /* @__PURE__ */ new Set()
|
|
5196
|
+
};
|
|
5197
|
+
}
|
|
5198
|
+
recordCandidateEvaluation(work) {
|
|
5199
|
+
work.evaluated += 1;
|
|
5200
|
+
if (work.evaluated > this.maxCandidateEvaluations) throw new Error(`Maximum candidate evaluations (${this.maxCandidateEvaluations}) exceeded in all()`);
|
|
5201
|
+
}
|
|
5202
|
+
/**
|
|
5203
|
+
* Visit BYHOUR x BYMINUTE x BYSECOND without allocating the Cartesian
|
|
5204
|
+
* product. Returning false from `visit` terminates the innermost traversal
|
|
5205
|
+
* immediately. The optional bounds are only supplied for the same local
|
|
5206
|
+
* calendar date by `visitDateTimeCandidates`.
|
|
5207
|
+
*/
|
|
5208
|
+
visitTimeSlots(base, direction, visit, notBefore, notAfter, work = this.createCandidateWorkBudget()) {
|
|
5209
|
+
const hours = this.opts.byHour ?? [base.hour];
|
|
5210
|
+
const minutes = this.opts.byMinute ?? [base.minute];
|
|
5211
|
+
const seconds = this.opts.bySecond ?? [base.second];
|
|
5212
|
+
if (this.needsSortedTimeFallback(base)) {
|
|
5213
|
+
const candidates = [];
|
|
5214
|
+
for (const hour of hours) for (const minute of minutes) for (const second of seconds) {
|
|
5215
|
+
this.recordCandidateEvaluation(work);
|
|
5216
|
+
const candidate = hour === base.hour && minute === base.minute && second === base.second ? base : base.with({
|
|
5217
|
+
hour,
|
|
5218
|
+
minute,
|
|
5219
|
+
second
|
|
5220
|
+
});
|
|
5221
|
+
if (notBefore && Temporal.ZonedDateTime.compare(candidate, notBefore) < 0) continue;
|
|
5222
|
+
if (notAfter && Temporal.ZonedDateTime.compare(candidate, notAfter) > 0) continue;
|
|
5223
|
+
candidates.push(candidate);
|
|
5224
|
+
}
|
|
5225
|
+
candidates.sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
|
|
5226
|
+
let previousEpoch;
|
|
5227
|
+
const start = direction === 1 ? 0 : candidates.length - 1;
|
|
5228
|
+
const end = direction === 1 ? candidates.length : -1;
|
|
5229
|
+
for (let index = start; index !== end; index += direction) {
|
|
5230
|
+
const candidate = candidates[index];
|
|
5231
|
+
if (candidate.epochNanoseconds === previousEpoch) continue;
|
|
5232
|
+
previousEpoch = candidate.epochNanoseconds;
|
|
5233
|
+
if (!visit(candidate)) return false;
|
|
5234
|
+
}
|
|
5235
|
+
return true;
|
|
5236
|
+
}
|
|
5237
|
+
const lowerTime = notBefore ? this.timeOfDayNanoseconds(notBefore) : void 0;
|
|
5238
|
+
const upperTime = notAfter ? this.timeOfDayNanoseconds(notAfter) : void 0;
|
|
5239
|
+
const hourStart = direction === 1 ? 0 : hours.length - 1;
|
|
5240
|
+
const hourEnd = direction === 1 ? hours.length : -1;
|
|
5241
|
+
for (let hourIndex = hourStart; hourIndex !== hourEnd; hourIndex += direction) {
|
|
5242
|
+
const hour = hours[hourIndex];
|
|
5243
|
+
const minuteStart = direction === 1 ? 0 : minutes.length - 1;
|
|
5244
|
+
const minuteEnd = direction === 1 ? minutes.length : -1;
|
|
5245
|
+
for (let minuteIndex = minuteStart; minuteIndex !== minuteEnd; minuteIndex += direction) {
|
|
5246
|
+
const minute = minutes[minuteIndex];
|
|
5247
|
+
const secondStart = direction === 1 ? 0 : seconds.length - 1;
|
|
5248
|
+
const secondEnd = direction === 1 ? seconds.length : -1;
|
|
5249
|
+
for (let secondIndex = secondStart; secondIndex !== secondEnd; secondIndex += direction) {
|
|
5250
|
+
const second = seconds[secondIndex];
|
|
5251
|
+
const slotTime = this.timeSlotNanoseconds(base, hour, minute, second);
|
|
5252
|
+
if (lowerTime !== void 0 && slotTime < lowerTime) continue;
|
|
5253
|
+
if (upperTime !== void 0 && slotTime > upperTime) continue;
|
|
5254
|
+
this.recordCandidateEvaluation(work);
|
|
5255
|
+
if (!visit(hour === base.hour && minute === base.minute && second === base.second ? base : base.with({
|
|
5256
|
+
hour,
|
|
5257
|
+
minute,
|
|
5258
|
+
second
|
|
5259
|
+
}))) return false;
|
|
5260
|
+
}
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
return true;
|
|
5264
|
+
}
|
|
5265
|
+
visitDateTimeCandidates(dateCandidates, direction, visit, notBefore, notAfter, work = this.createCandidateWorkBudget()) {
|
|
5266
|
+
const dates = this.sortedUniqueDateCandidates(dateCandidates);
|
|
5267
|
+
const localNotBefore = notBefore?.withTimeZone(this.tzid);
|
|
5268
|
+
const localNotAfter = notAfter?.withTimeZone(this.tzid);
|
|
5269
|
+
const notBeforeDate = localNotBefore?.toPlainDate();
|
|
5270
|
+
const notAfterDate = localNotAfter?.toPlainDate();
|
|
5271
|
+
const start = direction === 1 ? 0 : dates.length - 1;
|
|
5272
|
+
const end = direction === 1 ? dates.length : -1;
|
|
5273
|
+
let previousEpoch;
|
|
5274
|
+
for (let index = start; index !== end; index += direction) {
|
|
5275
|
+
const date = dates[index];
|
|
5276
|
+
const plainDate = date.toPlainDate();
|
|
5277
|
+
if (notBeforeDate && Temporal.PlainDate.compare(plainDate, notBeforeDate) < 0) continue;
|
|
5278
|
+
if (notAfterDate && Temporal.PlainDate.compare(plainDate, notAfterDate) > 0) continue;
|
|
5279
|
+
const sameAsLowerDate = notBeforeDate && Temporal.PlainDate.compare(plainDate, notBeforeDate) === 0;
|
|
5280
|
+
const sameAsUpperDate = notAfterDate && Temporal.PlainDate.compare(plainDate, notAfterDate) === 0;
|
|
5281
|
+
if (!this.visitTimeSlots(date, direction, (candidate) => {
|
|
5282
|
+
if (candidate.epochNanoseconds === previousEpoch) return true;
|
|
5283
|
+
previousEpoch = candidate.epochNanoseconds;
|
|
5284
|
+
return visit(candidate);
|
|
5285
|
+
}, sameAsLowerDate ? localNotBefore : void 0, sameAsUpperDate ? localNotAfter : void 0, work)) return false;
|
|
5286
|
+
}
|
|
5287
|
+
return true;
|
|
5288
|
+
}
|
|
5289
|
+
/** Apply BYSETPOS with bounded forward/reverse passes over one period. */
|
|
5290
|
+
visitPeriodCandidates(dateCandidates, visit, notBefore, notAfter, work = this.createCandidateWorkBudget()) {
|
|
5291
|
+
const positions = this.opts.bySetPos;
|
|
5292
|
+
if (!positions?.length) return this.visitDateTimeCandidates(dateCandidates, 1, visit, notBefore, notAfter, work);
|
|
5293
|
+
const positive = new Set(positions.filter((position) => position > 0));
|
|
5294
|
+
const negative = new Set(positions.filter((position) => position < 0).map((position) => -position));
|
|
5295
|
+
const selected = /* @__PURE__ */ new Map();
|
|
5296
|
+
if (positive.size > 0) {
|
|
5297
|
+
let lastPositive = 0;
|
|
5298
|
+
for (const position of positive) lastPositive = Math.max(lastPositive, position);
|
|
5299
|
+
let rank = 0;
|
|
5300
|
+
this.visitDateTimeCandidates(dateCandidates, 1, (candidate) => {
|
|
5301
|
+
rank += 1;
|
|
5302
|
+
if (positive.has(rank)) selected.set(candidate.epochNanoseconds, candidate);
|
|
5303
|
+
return rank < lastPositive;
|
|
5304
|
+
}, void 0, void 0, work);
|
|
5305
|
+
}
|
|
5306
|
+
if (negative.size > 0) {
|
|
5307
|
+
let lastNegative = 0;
|
|
5308
|
+
for (const position of negative) lastNegative = Math.max(lastNegative, position);
|
|
5309
|
+
let rank = 0;
|
|
5310
|
+
this.visitDateTimeCandidates(dateCandidates, -1, (candidate) => {
|
|
5311
|
+
rank += 1;
|
|
5312
|
+
if (negative.has(rank)) selected.set(candidate.epochNanoseconds, candidate);
|
|
5313
|
+
return rank < lastNegative;
|
|
5314
|
+
}, void 0, void 0, work);
|
|
5315
|
+
}
|
|
5316
|
+
const sorted = [...selected.values()].sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
|
|
5317
|
+
for (const candidate of sorted) {
|
|
5318
|
+
if (notBefore && Temporal.ZonedDateTime.compare(candidate, notBefore) < 0) continue;
|
|
5319
|
+
if (notAfter && Temporal.ZonedDateTime.compare(candidate, notAfter) > 0) continue;
|
|
5320
|
+
if (!visit(candidate)) return false;
|
|
5321
|
+
}
|
|
5322
|
+
return true;
|
|
5323
|
+
}
|
|
5146
5324
|
nextCandidateSameDate(zdt) {
|
|
5147
5325
|
const { freq, interval = 1, byHour, byMinute, bySecond } = this.opts;
|
|
5148
5326
|
if (freq === "HOURLY" && byHour && byHour.length === 1) return this.applyTimeOverride(zdt.add({ days: interval }));
|
|
@@ -5486,6 +5664,34 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
5486
5664
|
else return week === lastWeek + wn + 1;
|
|
5487
5665
|
});
|
|
5488
5666
|
}
|
|
5667
|
+
/**
|
|
5668
|
+
* Gregorian weekday and leap-year patterns repeat every 400 years. Checking
|
|
5669
|
+
* a complete cycle lets impossible BYYEARDAY + BYWEEKNO intersections stop
|
|
5670
|
+
* without incorrectly judging the rule from DTSTART's year alone.
|
|
5671
|
+
*/
|
|
5672
|
+
hasPossibleYearDayWeekNoCombination() {
|
|
5673
|
+
if (!this.opts.byYearDay || !this.opts.byWeekNo) return true;
|
|
5674
|
+
let yearStart = this.originalDtstart.with({
|
|
5675
|
+
year: 2e3,
|
|
5676
|
+
month: 1,
|
|
5677
|
+
day: 1,
|
|
5678
|
+
hour: 0,
|
|
5679
|
+
minute: 0,
|
|
5680
|
+
second: 0,
|
|
5681
|
+
millisecond: 0,
|
|
5682
|
+
microsecond: 0,
|
|
5683
|
+
nanosecond: 0
|
|
5684
|
+
});
|
|
5685
|
+
for (let offset = 0; offset < 400; offset++) {
|
|
5686
|
+
const daysInYear = yearStart.daysInYear;
|
|
5687
|
+
for (const yearDay of this.opts.byYearDay) {
|
|
5688
|
+
const resolvedDay = yearDay > 0 ? yearDay : daysInYear + yearDay + 1;
|
|
5689
|
+
if (resolvedDay >= 1 && resolvedDay <= daysInYear && this.matchesByWeekNo(yearStart.add({ days: resolvedDay - 1 }))) return true;
|
|
5690
|
+
}
|
|
5691
|
+
yearStart = yearStart.add({ years: 1 });
|
|
5692
|
+
}
|
|
5693
|
+
return false;
|
|
5694
|
+
}
|
|
5489
5695
|
options() {
|
|
5490
5696
|
const { dtstart, until, rDate, exDate, temporal: _temporal, ...rest } = this.cloneOptions();
|
|
5491
5697
|
return {
|
|
@@ -5570,7 +5776,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
5570
5776
|
return !iterator && this.tzid === "UTC" && this.opts.freq === "WEEKLY" && !this.opts.rscale && !this.opts.rDate && !this.opts.exDate && !this.opts.byMonth && !this.opts.byMonthDay && !this.opts.byYearDay && !this.opts.byWeekNo && !this.opts.bySetPos && (!this.opts.byHour || this.canUseEpochMillisecondsPrecisionFlag) && (!this.opts.byMinute || this.canUseEpochMillisecondsPrecisionFlag) && (!this.opts.bySecond || this.canUseEpochMillisecondsPrecisionFlag) && !this.hasOrdinalByDay;
|
|
5571
5777
|
}
|
|
5572
5778
|
canUseUtcMonthlyFastPath(iterator) {
|
|
5573
|
-
return !iterator && this.tzid === "UTC" && this.opts.freq === "MONTHLY" && !this.opts.rscale && !this.opts.rDate && !this.opts.exDate && !this.opts.byYearDay && !this.opts.byWeekNo && this.canUseEpochMillisecondsPrecisionFlag && !!(this.opts.byDay || this.opts.byMonthDay);
|
|
5779
|
+
return !iterator && this.tzid === "UTC" && this.opts.freq === "MONTHLY" && !this.opts.rscale && !this.opts.rDate && !this.opts.exDate && !this.opts.byYearDay && !this.opts.byWeekNo && this.canUseEpochMillisecondsPrecisionFlag && this.hasSingleExpandedTimeSlot() && !!(this.opts.byDay || this.opts.byMonthDay);
|
|
5574
5780
|
}
|
|
5575
5781
|
utcZdtFromEpochNanoseconds(epochNanoseconds) {
|
|
5576
5782
|
return new Temporal.ZonedDateTime(epochNanoseconds, "UTC");
|
|
@@ -6186,15 +6392,6 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6186
6392
|
}
|
|
6187
6393
|
return finalDays;
|
|
6188
6394
|
}
|
|
6189
|
-
generateMonthlyOccurrencesOptimizedBySetPos(sample) {
|
|
6190
|
-
if (!this.opts.bySetPos || !this.hasSingleExpandedTimeSlot()) return null;
|
|
6191
|
-
const monthStart = sample.day === 1 ? sample : sample.with({ day: 1 });
|
|
6192
|
-
const days = this.generateMonthlyOccurrenceDays(monthStart);
|
|
6193
|
-
if (days.length === 0) return [];
|
|
6194
|
-
const selectedDays = this.applyBySetPosToSortedList(days);
|
|
6195
|
-
if (selectedDays.length === 0) return [];
|
|
6196
|
-
return selectedDays.sort((a, b) => a - b).map((day) => this.buildMonthlyOccurrenceOnDay(monthStart, day));
|
|
6197
|
-
}
|
|
6198
6395
|
isGregorianLeapYear(year) {
|
|
6199
6396
|
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
6200
6397
|
}
|
|
@@ -6369,7 +6566,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6369
6566
|
}
|
|
6370
6567
|
break;
|
|
6371
6568
|
}
|
|
6372
|
-
if (this.opts.freq === "MONTHLY" && !this.opts.byYearDay && !this.opts.byWeekNo && !!(this.opts.byDay || this.opts.byMonthDay)) return this._allTzMonthlyByDayOrMonthDay();
|
|
6569
|
+
if (this.opts.freq === "MONTHLY" && !this.opts.byYearDay && !this.opts.byWeekNo && this.hasSingleExpandedTimeSlot() && !!(this.opts.byDay || this.opts.byMonthDay)) return this._allTzMonthlyByDayOrMonthDay();
|
|
6373
6570
|
if (this.opts.freq === "WEEKLY" && linearEligible && !this.hasOrdinalByDay && this.hasUniqueTimeSlotOffsets) return this.opts.byHour || this.opts.byMinute || this.opts.bySecond ? this._allTzWeeklyExpanded() : this._allTzWeeklySimple();
|
|
6374
6571
|
return null;
|
|
6375
6572
|
}
|
|
@@ -6556,53 +6753,54 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6556
6753
|
}
|
|
6557
6754
|
}
|
|
6558
6755
|
processOccurrences(occs, dates, start, iterator, extraFilters) {
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
if (
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
}
|
|
6577
|
-
}
|
|
6578
|
-
return { shouldBreak };
|
|
6756
|
+
for (const occ of occs) if (!this.processOccurrence(occ, dates, start, iterator, extraFilters)) return { shouldBreak: true };
|
|
6757
|
+
return { shouldBreak: false };
|
|
6758
|
+
}
|
|
6759
|
+
/** Process one occurrence and report whether generation should continue. */
|
|
6760
|
+
processOccurrence(occurrence, dates, start, iterator, extraFilters, work) {
|
|
6761
|
+
if (work) {
|
|
6762
|
+
if (work.seenOccurrences.size === 0 && dates.length > 0) for (const date of dates) work.seenOccurrences.add(date.epochNanoseconds);
|
|
6763
|
+
if (work.seenOccurrences.has(occurrence.epochNanoseconds)) return true;
|
|
6764
|
+
work.seenOccurrences.add(occurrence.epochNanoseconds);
|
|
6765
|
+
}
|
|
6766
|
+
if (Temporal.ZonedDateTime.compare(occurrence, start) < 0) return true;
|
|
6767
|
+
if (this.opts.until && Temporal.ZonedDateTime.compare(occurrence, this.opts.until) > 0) return false;
|
|
6768
|
+
if (extraFilters && !extraFilters(occurrence)) return true;
|
|
6769
|
+
if (iterator && this.isExcluded(occurrence)) return true;
|
|
6770
|
+
if (iterator && !iterator(occurrence, dates.length)) return false;
|
|
6771
|
+
dates.push(occurrence);
|
|
6772
|
+
return !this.shouldBreakForCountLimit(dates.length);
|
|
6579
6773
|
}
|
|
6580
6774
|
/**
|
|
6581
6775
|
* Returns all occurrences of the rule.
|
|
6582
6776
|
* @param iterator - An optional callback iterator function that can be used to filter or modify the occurrences.
|
|
6583
6777
|
* @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule.
|
|
6584
6778
|
*/
|
|
6585
|
-
_allMonthlyByDayOrMonthDay(iterator) {
|
|
6779
|
+
_allMonthlyByDayOrMonthDay(iterator, queryLowerBound) {
|
|
6586
6780
|
const dates = [];
|
|
6781
|
+
const work = this.createCandidateWorkBudget();
|
|
6587
6782
|
let iterationCount = 0;
|
|
6588
6783
|
const start = this.originalDtstart;
|
|
6589
6784
|
if (!this.addDtstartIfNeeded(dates, iterator)) return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
6590
6785
|
let monthCursor = start.with({ day: 1 });
|
|
6591
6786
|
while (true) {
|
|
6592
6787
|
if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6788
|
+
if (!this.visitPeriodCandidates(this.generateMonthlyDateCandidates(monthCursor), (candidate) => this.processOccurrence(candidate, dates, start, iterator, void 0, work), queryLowerBound ?? start, this.opts.until, work)) break;
|
|
6789
|
+
try {
|
|
6790
|
+
monthCursor = monthCursor.add({ months: this.opts.interval });
|
|
6791
|
+
} catch {
|
|
6792
|
+
break;
|
|
6793
|
+
}
|
|
6794
|
+
if (this.opts.until) {
|
|
6795
|
+
const localUntil = this.opts.until.withTimeZone(this.tzid);
|
|
6796
|
+
if (monthCursor.year * 12 + monthCursor.month > localUntil.year * 12 + localUntil.month) break;
|
|
6597
6797
|
}
|
|
6598
|
-
const { shouldBreak } = this.processOccurrences(occs, dates, start, iterator);
|
|
6599
|
-
if (shouldBreak) break;
|
|
6600
|
-
monthCursor = monthCursor.add({ months: this.opts.interval });
|
|
6601
6798
|
}
|
|
6602
6799
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
6603
6800
|
}
|
|
6604
|
-
_allWeekly(iterator) {
|
|
6801
|
+
_allWeekly(iterator, queryLowerBound) {
|
|
6605
6802
|
const dates = [];
|
|
6803
|
+
const work = this.createCandidateWorkBudget();
|
|
6606
6804
|
let iterationCount = 0;
|
|
6607
6805
|
const start = this.originalDtstart;
|
|
6608
6806
|
if (!this.addDtstartIfNeeded(dates, iterator)) return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
@@ -6617,15 +6815,20 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6617
6815
|
let weekCursor = firstOccurrence.subtract({ days: firstOccWeekOffset });
|
|
6618
6816
|
while (true) {
|
|
6619
6817
|
if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
6620
|
-
|
|
6818
|
+
const dateCandidates = dows.map((dw) => {
|
|
6621
6819
|
const delta = (dw - wkstDay + 7) % 7;
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6820
|
+
return weekCursor.add({ days: delta });
|
|
6821
|
+
});
|
|
6822
|
+
if (!this.visitPeriodCandidates(dateCandidates, (candidate) => this.processOccurrence(candidate, dates, start, iterator, (occurrence) => this.matchesByMonth(occurrence) && this.matchesByMonthDay(occurrence), work), queryLowerBound ?? start, this.opts.until, work)) break;
|
|
6823
|
+
try {
|
|
6824
|
+
weekCursor = weekCursor.add({ weeks: this.opts.interval });
|
|
6825
|
+
} catch {
|
|
6826
|
+
break;
|
|
6827
|
+
}
|
|
6828
|
+
if (this.opts.until) {
|
|
6829
|
+
const localUntil = this.opts.until.withTimeZone(this.tzid);
|
|
6830
|
+
if (Temporal.PlainDate.compare(weekCursor.toPlainDate(), localUntil.toPlainDate()) > 0) break;
|
|
6831
|
+
}
|
|
6629
6832
|
}
|
|
6630
6833
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
6631
6834
|
}
|
|
@@ -6687,28 +6890,29 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6687
6890
|
yearOffset++;
|
|
6688
6891
|
}
|
|
6689
6892
|
}
|
|
6690
|
-
_allYearlyComplex(iterator) {
|
|
6893
|
+
_allYearlyComplex(iterator, queryLowerBound) {
|
|
6691
6894
|
const dates = [];
|
|
6895
|
+
const work = this.createCandidateWorkBudget();
|
|
6692
6896
|
let iterationCount = 0;
|
|
6693
6897
|
const start = this.originalDtstart;
|
|
6694
6898
|
if (!this.addDtstartIfNeeded(dates, iterator)) return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
6899
|
+
if (this.opts.until && Temporal.ZonedDateTime.compare(this.opts.until, start) < 0) return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
6695
6900
|
let yearCursor = start.with({
|
|
6696
6901
|
month: 1,
|
|
6697
6902
|
day: 1
|
|
6698
6903
|
});
|
|
6904
|
+
const lastGenerationYear = this.opts.until ? this.opts.until.withTimeZone(this.tzid).year + (this.opts.byWeekNo ? 1 : 0) : void 0;
|
|
6699
6905
|
while (true) {
|
|
6700
6906
|
if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
6701
|
-
const
|
|
6702
|
-
|
|
6703
|
-
if (occs.length > 0) {
|
|
6704
|
-
uniqueOccs.push(occs[0]);
|
|
6705
|
-
for (let i = 1; i < occs.length; i++) if (Temporal.ZonedDateTime.compare(occs[i], occs[i - 1]) !== 0) uniqueOccs.push(occs[i]);
|
|
6706
|
-
}
|
|
6707
|
-
const { shouldBreak } = this.processOccurrences(uniqueOccs, dates, start, iterator);
|
|
6708
|
-
if (shouldBreak) break;
|
|
6907
|
+
const dateCandidates = this.generateYearlyDateCandidates(yearCursor);
|
|
6908
|
+
if (!this.visitPeriodCandidates(dateCandidates, (candidate) => this.processOccurrence(candidate, dates, start, iterator, void 0, work), queryLowerBound ?? start, this.opts.until, work)) break;
|
|
6709
6909
|
const interval = this.opts.freq === "WEEKLY" ? 1 : this.opts.interval;
|
|
6710
|
-
|
|
6711
|
-
|
|
6910
|
+
try {
|
|
6911
|
+
yearCursor = yearCursor.add({ years: interval });
|
|
6912
|
+
} catch {
|
|
6913
|
+
break;
|
|
6914
|
+
}
|
|
6915
|
+
if (lastGenerationYear !== void 0 && yearCursor.year > lastGenerationYear) break;
|
|
6712
6916
|
}
|
|
6713
6917
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
6714
6918
|
}
|
|
@@ -6733,8 +6937,9 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6733
6937
|
}
|
|
6734
6938
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
6735
6939
|
}
|
|
6736
|
-
_allMonthlyByWeekNo(iterator) {
|
|
6940
|
+
_allMonthlyByWeekNo(iterator, queryLowerBound) {
|
|
6737
6941
|
const dates = [];
|
|
6942
|
+
const work = this.createCandidateWorkBudget();
|
|
6738
6943
|
let iterationCount = 0;
|
|
6739
6944
|
const start = this.originalDtstart;
|
|
6740
6945
|
if (!this.addDtstartIfNeeded(dates, iterator)) return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
@@ -6749,15 +6954,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6749
6954
|
const year = current.year;
|
|
6750
6955
|
if (year !== lastYearProcessed && current.month >= start.month) {
|
|
6751
6956
|
lastYearProcessed = year;
|
|
6752
|
-
for (const weekNo of weekNos)
|
|
6753
|
-
const occs = this.generateOccurrencesForWeekInYear(year, weekNo);
|
|
6754
|
-
for (const occ of occs) if (Temporal.ZonedDateTime.compare(occ, start) >= 0) {
|
|
6755
|
-
if (iterator && this.isExcluded(occ)) continue;
|
|
6756
|
-
if (iterator && !iterator(occ, dates.length)) break outer_loop;
|
|
6757
|
-
dates.push(occ);
|
|
6758
|
-
if (this.shouldBreakForCountLimit(dates.length)) break outer_loop;
|
|
6759
|
-
}
|
|
6760
|
-
}
|
|
6957
|
+
for (const weekNo of weekNos) if (!this.visitDateTimeCandidates(this.generateDateCandidatesForWeekInYear(year, weekNo), 1, (candidate) => this.processOccurrence(candidate, dates, start, iterator, void 0, work), queryLowerBound ?? start, this.opts.until, work)) break outer_loop;
|
|
6761
6958
|
}
|
|
6762
6959
|
monthsAdvanced += interval;
|
|
6763
6960
|
current = start.add({ months: monthsAdvanced });
|
|
@@ -6765,8 +6962,9 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6765
6962
|
}
|
|
6766
6963
|
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
6767
6964
|
}
|
|
6768
|
-
_allMonthlyByYearDay(iterator) {
|
|
6965
|
+
_allMonthlyByYearDay(iterator, queryLowerBound) {
|
|
6769
6966
|
const dates = [];
|
|
6967
|
+
const work = this.createCandidateWorkBudget();
|
|
6770
6968
|
let iterationCount = 0;
|
|
6771
6969
|
const start = this.originalDtstart;
|
|
6772
6970
|
if (!this.addDtstartIfNeeded(dates, iterator)) return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
@@ -6786,22 +6984,17 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6786
6984
|
month: 12,
|
|
6787
6985
|
day: 31
|
|
6788
6986
|
}).dayOfYear;
|
|
6987
|
+
const dateCandidates = [];
|
|
6789
6988
|
for (const yd of yearDays) {
|
|
6790
6989
|
const dayNum = yd > 0 ? yd : lastDayOfYear + yd + 1;
|
|
6791
6990
|
if (dayNum <= 0 || dayNum > lastDayOfYear) continue;
|
|
6792
|
-
|
|
6793
|
-
for (const occ of this.expandByTime(baseOcc)) {
|
|
6794
|
-
if (Temporal.ZonedDateTime.compare(occ, start) < 0) continue;
|
|
6795
|
-
if (dates.some((d) => Temporal.ZonedDateTime.compare(d, occ) === 0)) continue;
|
|
6796
|
-
if ((occ.year * 12 + occ.month - startMonthAbs) % interval !== 0) continue;
|
|
6797
|
-
if (!this.matchesByMonth(occ)) continue;
|
|
6798
|
-
if (this.opts.until && Temporal.ZonedDateTime.compare(occ, this.opts.until) > 0) break outer_loop;
|
|
6799
|
-
if (iterator && this.isExcluded(occ)) continue;
|
|
6800
|
-
if (iterator && !iterator(occ, dates.length)) break outer_loop;
|
|
6801
|
-
dates.push(occ);
|
|
6802
|
-
if (this.shouldBreakForCountLimit(dates.length)) break outer_loop;
|
|
6803
|
-
}
|
|
6991
|
+
dateCandidates.push(yearStart.add({ days: dayNum - 1 }));
|
|
6804
6992
|
}
|
|
6993
|
+
if (!this.visitDateTimeCandidates(dateCandidates, 1, (candidate) => {
|
|
6994
|
+
if ((candidate.year * 12 + candidate.month - startMonthAbs) % interval !== 0) return true;
|
|
6995
|
+
if (!this.matchesByMonth(candidate)) return true;
|
|
6996
|
+
return this.processOccurrence(candidate, dates, start, iterator, void 0, work);
|
|
6997
|
+
}, queryLowerBound ?? start, this.opts.until, work)) break outer_loop;
|
|
6805
6998
|
year++;
|
|
6806
6999
|
if (this.opts.until && year > this.opts.until.year + 2) break;
|
|
6807
7000
|
if (!this.opts.until && this.opts.count) {
|
|
@@ -6893,7 +7086,15 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6893
7086
|
}
|
|
6894
7087
|
return this.toPublicDates(this.allInternal(this.toInternalIterator(iterator)));
|
|
6895
7088
|
}
|
|
6896
|
-
allInternal(iterator) {
|
|
7089
|
+
allInternal(iterator, queryLowerBound) {
|
|
7090
|
+
if (this.opts.count === void 0 && !this.opts.until && !iterator) throw new Error("all() requires iterator when no COUNT/UNTIL");
|
|
7091
|
+
if (iterator && (this.opts.rDate || this.opts.exDate)) return this.iterateRecurrenceSet(iterator);
|
|
7092
|
+
if (this.opts.count === 0) return this.applyCountLimitAndMergeRDates([], iterator);
|
|
7093
|
+
if (this.opts.until && Temporal.ZonedDateTime.compare(this.opts.until, this.originalDtstart) < 0) {
|
|
7094
|
+
const dates = [];
|
|
7095
|
+
this.addDtstartIfNeeded(dates, iterator);
|
|
7096
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
7097
|
+
}
|
|
6897
7098
|
if (this.opts.rscale && [
|
|
6898
7099
|
"CHINESE",
|
|
6899
7100
|
"HEBREW",
|
|
@@ -6903,48 +7104,25 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6903
7104
|
"YEARLY",
|
|
6904
7105
|
"MONTHLY",
|
|
6905
7106
|
"WEEKLY"
|
|
6906
|
-
].includes(this.opts.freq) || !!this.opts.byYearDay || !!this.opts.byWeekNo || this.opts.byMonthDay && this.opts.byMonthDay.length > 0) return this._allRscaleNonGregorian(iterator);
|
|
7107
|
+
].includes(this.opts.freq) || !!this.opts.byYearDay || !!this.opts.byWeekNo || this.opts.byMonthDay && this.opts.byMonthDay.length > 0) return this._allRscaleNonGregorian(iterator, queryLowerBound);
|
|
6907
7108
|
}
|
|
6908
|
-
if (this.opts.byWeekNo && this.opts.byYearDay) {
|
|
6909
|
-
const
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
hour: 0,
|
|
6913
|
-
minute: 0,
|
|
6914
|
-
second: 0,
|
|
6915
|
-
millisecond: 0
|
|
6916
|
-
});
|
|
6917
|
-
const yearDays = this.opts.byYearDay.map((yd) => {
|
|
6918
|
-
const lastDayOfYear = yearStart.with({
|
|
6919
|
-
month: 12,
|
|
6920
|
-
day: 31
|
|
6921
|
-
}).dayOfYear;
|
|
6922
|
-
return yd > 0 ? yd : lastDayOfYear + yd + 1;
|
|
6923
|
-
});
|
|
6924
|
-
let possibleDate = false;
|
|
6925
|
-
for (const yd of yearDays) {
|
|
6926
|
-
const date = yearStart.add({ days: yd - 1 });
|
|
6927
|
-
if (this.matchesByWeekNo(date)) {
|
|
6928
|
-
possibleDate = true;
|
|
6929
|
-
break;
|
|
6930
|
-
}
|
|
6931
|
-
}
|
|
6932
|
-
if (!possibleDate) return [];
|
|
7109
|
+
if (this.opts.byWeekNo && this.opts.byYearDay && !this.hasPossibleYearDayWeekNoCombination()) {
|
|
7110
|
+
const dates = [];
|
|
7111
|
+
this.addDtstartIfNeeded(dates, iterator);
|
|
7112
|
+
return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
6933
7113
|
}
|
|
6934
|
-
if (!this.opts.count && !this.opts.until && !iterator) throw new Error("all() requires iterator when no COUNT/UNTIL");
|
|
6935
|
-
if (iterator && (this.opts.rDate || this.opts.exDate)) return this.iterateRecurrenceSet(iterator);
|
|
6936
7114
|
const utcFastPathDates = this.allUtcFastPath(iterator);
|
|
6937
7115
|
if (utcFastPathDates) return utcFastPathDates;
|
|
6938
7116
|
const tzFastPathDates = this.allTzEpochFastPath(iterator);
|
|
6939
7117
|
if (tzFastPathDates) return tzFastPathDates;
|
|
6940
|
-
if (this.opts.freq === "MONTHLY" && (this.opts.byDay || this.opts.byMonthDay) && !this.opts.byWeekNo) return this._allMonthlyByDayOrMonthDay(iterator);
|
|
6941
|
-
if (this.opts.freq === "WEEKLY" && !(this.opts.byYearDay && this.opts.byYearDay.length > 0) && !(this.opts.byWeekNo && this.opts.byWeekNo.length > 0)) return this._allWeekly(iterator);
|
|
7118
|
+
if (this.opts.freq === "MONTHLY" && (this.opts.byDay || this.opts.byMonthDay) && !this.opts.byWeekNo) return this._allMonthlyByDayOrMonthDay(iterator, queryLowerBound);
|
|
7119
|
+
if (this.opts.freq === "WEEKLY" && !(this.opts.byYearDay && this.opts.byYearDay.length > 0) && !(this.opts.byWeekNo && this.opts.byWeekNo.length > 0)) return this._allWeekly(iterator, queryLowerBound);
|
|
6942
7120
|
if (this.opts.freq === "MONTHLY" && this.opts.byMonth && !this.opts.byDay && !this.opts.byMonthDay && !this.opts.byYearDay) return this._allMonthlyByMonth(iterator);
|
|
6943
7121
|
if (this.opts.freq === "YEARLY" && this.opts.byMonth && !this.opts.byDay && !this.opts.byMonthDay && !this.opts.byYearDay && !this.opts.byWeekNo) return this._allYearlyByMonth(iterator);
|
|
6944
|
-
if (this.opts.freq === "YEARLY" && (this.opts.byDay || this.opts.byMonthDay || this.opts.byYearDay || this.opts.byWeekNo) || this.opts.freq === "WEEKLY" && this.opts.byYearDay && this.opts.byYearDay.length > 0 || this.opts.freq === "WEEKLY" && this.opts.byWeekNo && this.opts.byWeekNo.length > 0) return this._allYearlyComplex(iterator);
|
|
7122
|
+
if (this.opts.freq === "YEARLY" && (this.opts.byDay || this.opts.byMonthDay || this.opts.byYearDay || this.opts.byWeekNo) || this.opts.freq === "WEEKLY" && this.opts.byYearDay && this.opts.byYearDay.length > 0 || this.opts.freq === "WEEKLY" && this.opts.byWeekNo && this.opts.byWeekNo.length > 0) return this._allYearlyComplex(iterator, queryLowerBound);
|
|
6945
7123
|
if ((this.opts.freq === "MINUTELY" || this.opts.freq === "SECONDLY") && (this.opts.byMonth || this.opts.byWeekNo || this.opts.byYearDay || this.opts.byMonthDay || this.opts.byDay)) return this._allMinutelySecondlyComplex(iterator);
|
|
6946
|
-
if (this.opts.freq === "MONTHLY" && this.opts.byWeekNo && this.opts.byWeekNo.length > 0) return this._allMonthlyByWeekNo(iterator);
|
|
6947
|
-
if (this.opts.freq === "MONTHLY" && this.opts.byYearDay && this.opts.byYearDay.length > 0 && !this.opts.byDay && !this.opts.byMonthDay) return this._allMonthlyByYearDay(iterator);
|
|
7124
|
+
if (this.opts.freq === "MONTHLY" && this.opts.byWeekNo && this.opts.byWeekNo.length > 0) return this._allMonthlyByWeekNo(iterator, queryLowerBound);
|
|
7125
|
+
if (this.opts.freq === "MONTHLY" && this.opts.byYearDay && this.opts.byYearDay.length > 0 && !this.opts.byDay && !this.opts.byMonthDay) return this._allMonthlyByYearDay(iterator, queryLowerBound);
|
|
6948
7126
|
if (this.opts.rscale && this.opts.freq === "MONTHLY" && !this.opts.byDay && !this.opts.byMonthDay && !this.opts.byWeekNo && !this.opts.byYearDay) return this._allMonthlyRscaleSimple(iterator);
|
|
6949
7127
|
if ((this.opts.freq === "MINUTELY" || this.opts.freq === "HOURLY" || this.opts.freq === "DAILY") && this.opts.bySetPos) return this._allDailyMinutelyHourlyWithBySetPos(iterator);
|
|
6950
7128
|
return this._allFallback(iterator);
|
|
@@ -7208,8 +7386,9 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7208
7386
|
if (tempOpts.count === void 0) tempOpts.dtstart = this.jumpAlignedDtstart(startZdt);
|
|
7209
7387
|
const allDates = new RRuleTemporal({
|
|
7210
7388
|
...tempOpts,
|
|
7389
|
+
strict: tempOpts.count !== void 0 ? false : tempOpts.strict,
|
|
7211
7390
|
temporal: this.outputTemporal
|
|
7212
|
-
}).allInternal();
|
|
7391
|
+
}).allInternal(void 0, tempOpts.count === void 0 ? startZdt : void 0);
|
|
7213
7392
|
return this.toPublicDates(allDates.filter((date) => {
|
|
7214
7393
|
const inst = date.toInstant();
|
|
7215
7394
|
const afterStart = inc ? Temporal.Instant.compare(inst, startInst) >= 0 : Temporal.Instant.compare(inst, startInst) > 0;
|
|
@@ -7424,22 +7603,25 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7424
7603
|
return dates.map((d) => this.formatIcsDateTime(d));
|
|
7425
7604
|
}
|
|
7426
7605
|
/**
|
|
7427
|
-
*
|
|
7428
|
-
*
|
|
7606
|
+
* Resolve the calendar dates selected within a month without expanding any
|
|
7607
|
+
* time BY-parts. This keeps the intermediate set bounded to calendar scale.
|
|
7429
7608
|
*/
|
|
7430
|
-
|
|
7609
|
+
generateMonthlyDateCandidates(sample) {
|
|
7431
7610
|
const monthStart = sample.day === 1 ? sample : sample.with({ day: 1 });
|
|
7432
|
-
if (!this.opts.byDay && !this.opts.byMonthDay) return
|
|
7611
|
+
if (!this.opts.byDay && !this.opts.byMonthDay) return [sample];
|
|
7433
7612
|
const finalDays = this.generateMonthlyOccurrenceDays(monthStart);
|
|
7434
7613
|
if (finalDays.length === 0) return [];
|
|
7435
|
-
return finalDays.map((
|
|
7614
|
+
return finalDays.map((day) => monthStart.with({ day }));
|
|
7615
|
+
}
|
|
7616
|
+
generateMonthlyOccurrences(sample) {
|
|
7617
|
+
return this.generateMonthlyDateCandidates(sample).flatMap((date) => this.expandByTime(date));
|
|
7436
7618
|
}
|
|
7437
7619
|
/**
|
|
7438
|
-
*
|
|
7439
|
-
*
|
|
7440
|
-
*
|
|
7620
|
+
* Resolve one recurrence year's matching calendar dates. BYHOUR,
|
|
7621
|
+
* BYMINUTE, BYSECOND, and BYSETPOS deliberately remain outside this helper;
|
|
7622
|
+
* callers consume the date x time product incrementally.
|
|
7441
7623
|
*/
|
|
7442
|
-
|
|
7624
|
+
generateYearlyDateCandidates(sample) {
|
|
7443
7625
|
const months = this.opts.byMonth ? this.opts.byMonth.filter((v) => typeof v === "number").sort((a, b) => a - b) : this.opts.byMonthDay || this.opts.byDay ? [
|
|
7444
7626
|
1,
|
|
7445
7627
|
2,
|
|
@@ -7478,7 +7660,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7478
7660
|
const delta = (dec31.dayOfWeek - wd + 7) % 7;
|
|
7479
7661
|
dt = dec31.subtract({ days: delta + 7 * (-ord - 1) });
|
|
7480
7662
|
}
|
|
7481
|
-
occs.push(
|
|
7663
|
+
occs.push(dt);
|
|
7482
7664
|
}
|
|
7483
7665
|
} else if (!this.opts.byYearDay && !this.opts.byWeekNo) {
|
|
7484
7666
|
occs = [];
|
|
@@ -7487,17 +7669,17 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7487
7669
|
month: m,
|
|
7488
7670
|
day: 1
|
|
7489
7671
|
});
|
|
7490
|
-
const monthOccs = this.
|
|
7672
|
+
const monthOccs = this.generateMonthlyDateCandidates(monthSample);
|
|
7491
7673
|
if (monthOccs.length === 0 && this.opts.rscale && this.opts.byMonthDay && this.opts.byMonthDay.length > 0) {
|
|
7492
7674
|
const lastDay = monthSample.add({ months: 1 }).subtract({ days: 1 }).day;
|
|
7493
7675
|
const target = this.opts.byMonthDay[0];
|
|
7494
7676
|
const absTarget = target > 0 ? target : lastDay + target + 1;
|
|
7495
7677
|
if (absTarget > lastDay || absTarget <= 0) {
|
|
7496
7678
|
const skip = this.opts.skip || "OMIT";
|
|
7497
|
-
if (skip === "BACKWARD") occs.push(
|
|
7679
|
+
if (skip === "BACKWARD") occs.push(monthSample.with({ day: lastDay }));
|
|
7498
7680
|
else if (skip === "FORWARD") {
|
|
7499
7681
|
const nextMonth = monthSample.add({ months: 1 }).with({ day: 1 });
|
|
7500
|
-
occs.push(
|
|
7682
|
+
occs.push(nextMonth);
|
|
7501
7683
|
}
|
|
7502
7684
|
}
|
|
7503
7685
|
} else occs.push(...monthOccs);
|
|
@@ -7522,7 +7704,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7522
7704
|
month: 1,
|
|
7523
7705
|
day: 1
|
|
7524
7706
|
}).add({ days: dayNum - 1 });
|
|
7525
|
-
if (!this.opts.byMonth || this.opts.byMonth.includes(dt.month)) occs.push(
|
|
7707
|
+
if (!this.opts.byMonth || this.opts.byMonth.includes(dt.month)) occs.push(dt);
|
|
7526
7708
|
}
|
|
7527
7709
|
}
|
|
7528
7710
|
if (this.opts.byWeekNo) {
|
|
@@ -7531,14 +7713,12 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7531
7713
|
if (weekNo > 0 && weekNo > lastWeek || weekNo < 0 && -weekNo > lastWeek) continue;
|
|
7532
7714
|
const weekIndex = weekNo > 0 ? weekNo - 1 : lastWeek + weekNo;
|
|
7533
7715
|
const weekStart = firstWeekStart.add({ weeks: weekIndex });
|
|
7534
|
-
occs.push(...this.
|
|
7716
|
+
occs.push(...this.addByDayDates(tokens, weekStart));
|
|
7535
7717
|
}
|
|
7536
7718
|
}
|
|
7537
|
-
|
|
7538
|
-
occs = this.applyBySetPos(occs);
|
|
7539
|
-
return occs;
|
|
7719
|
+
return this.sortedUniqueDateCandidates(occs);
|
|
7540
7720
|
}
|
|
7541
|
-
|
|
7721
|
+
addByDayDates(tokens, weekStart) {
|
|
7542
7722
|
const dayMap = weekdayToIsoDay;
|
|
7543
7723
|
const wkst = dayMap[this.opts.wkst || "MO"];
|
|
7544
7724
|
const entries = [];
|
|
@@ -7546,9 +7726,9 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7546
7726
|
if (!tok) continue;
|
|
7547
7727
|
const targetDow = dayMap[tok];
|
|
7548
7728
|
const inst = weekStart.add({ days: (targetDow - wkst + 7) % 7 });
|
|
7549
|
-
if (!this.opts.byMonth || this.opts.byMonth.includes(inst.month)) entries.push(
|
|
7729
|
+
if (!this.opts.byMonth || this.opts.byMonth.includes(inst.month)) entries.push(inst);
|
|
7550
7730
|
}
|
|
7551
|
-
return entries;
|
|
7731
|
+
return this.sortedUniqueDateCandidates(entries);
|
|
7552
7732
|
}
|
|
7553
7733
|
/**
|
|
7554
7734
|
* Helper to find the next valid value from a sorted array
|
|
@@ -7791,7 +7971,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7791
7971
|
/**
|
|
7792
7972
|
* Generate occurrences for a specific week number in a given year
|
|
7793
7973
|
*/
|
|
7794
|
-
|
|
7974
|
+
generateDateCandidatesForWeekInYear(year, weekNo) {
|
|
7795
7975
|
const occs = [];
|
|
7796
7976
|
const sample = this.originalDtstart.with({
|
|
7797
7977
|
year,
|
|
@@ -7802,8 +7982,8 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7802
7982
|
if (weekNo > 0 && weekNo > lastWeek || weekNo < 0 && -weekNo > lastWeek) return occs;
|
|
7803
7983
|
const weekIndex = weekNo > 0 ? weekNo - 1 : lastWeek + weekNo;
|
|
7804
7984
|
const weekStart = firstWeekStart.add({ weeks: weekIndex });
|
|
7805
|
-
occs.push(...this.
|
|
7806
|
-
return
|
|
7985
|
+
occs.push(...this.addByDayDates(tokens, weekStart));
|
|
7986
|
+
return this.sortedUniqueDateCandidates(occs);
|
|
7807
7987
|
}
|
|
7808
7988
|
getRscaleCalendarId() {
|
|
7809
7989
|
return {
|
|
@@ -7993,11 +8173,12 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7993
8173
|
}
|
|
7994
8174
|
return this.applyBySetPos(occs).sort((a, b) => Temporal.ZonedDateTime.compare(a, b));
|
|
7995
8175
|
}
|
|
7996
|
-
_allRscaleNonGregorian(iterator) {
|
|
8176
|
+
_allRscaleNonGregorian(iterator, queryLowerBound) {
|
|
7997
8177
|
const calId = this.getRscaleCalendarId();
|
|
7998
8178
|
if (!calId) return this._allFallback(iterator);
|
|
7999
8179
|
this.assertRscaleCalendarSupported(calId);
|
|
8000
8180
|
const dates = [];
|
|
8181
|
+
const work = this.createCandidateWorkBudget();
|
|
8001
8182
|
let iterationCount = 0;
|
|
8002
8183
|
const start = this.originalDtstart;
|
|
8003
8184
|
const seed = this.toRscaleZdt(start).withCalendar(calId);
|
|
@@ -8070,9 +8251,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
8070
8251
|
for (const ms of monthStarts) occs.push(...this.generateMonthlyOccurrencesRscale(calId, tgtYear, ms));
|
|
8071
8252
|
}
|
|
8072
8253
|
if (occs.length > 0) {
|
|
8073
|
-
|
|
8074
|
-
const { shouldBreak } = this.processOccurrences(sorted, dates, start, iterator);
|
|
8075
|
-
if (shouldBreak) break;
|
|
8254
|
+
if (!this.visitDateTimeCandidates(occs, 1, (candidate) => this.processOccurrence(candidate, dates, start, iterator, void 0, work), queryLowerBound ?? start, this.opts.until, work)) break;
|
|
8076
8255
|
}
|
|
8077
8256
|
yearOffset++;
|
|
8078
8257
|
if (this.opts.until && tgtYear > this.toRscaleZdt(this.opts.until).withCalendar(calId).year) break;
|
|
@@ -8109,9 +8288,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
8109
8288
|
occs.push(this.buildZdtFromPlainDate(pd));
|
|
8110
8289
|
}
|
|
8111
8290
|
if (occs.length) {
|
|
8112
|
-
|
|
8113
|
-
const { shouldBreak } = this.processOccurrences(sorted, dates, start, iterator);
|
|
8114
|
-
if (shouldBreak) return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
8291
|
+
if (!this.visitDateTimeCandidates(occs, 1, (candidate) => this.processOccurrence(candidate, dates, start, iterator, void 0, work), queryLowerBound ?? start, this.opts.until, work)) return this.applyCountLimitAndMergeRDates(dates, iterator);
|
|
8115
8292
|
}
|
|
8116
8293
|
weekStart = weekStart.add({ weeks: this.opts.interval ?? 1 });
|
|
8117
8294
|
if (this.opts.until) {
|
|
@@ -8131,9 +8308,8 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
8131
8308
|
const monthsTokens = this.opts.byMonth;
|
|
8132
8309
|
if (monthsTokens && monthsTokens.length > 0) proceed = monthsTokens.some((tok) => this.monthMatchesToken(monthStart.monthCode, tok));
|
|
8133
8310
|
if (proceed) {
|
|
8134
|
-
const
|
|
8135
|
-
|
|
8136
|
-
if (shouldBreak) break;
|
|
8311
|
+
const occs = this.generateMonthlyOccurrencesRscale(calId, year, monthStart);
|
|
8312
|
+
if (!this.visitDateTimeCandidates(occs, 1, (candidate) => this.processOccurrence(candidate, dates, start, iterator, void 0, work), queryLowerBound ?? start, this.opts.until, work)) break;
|
|
8137
8313
|
}
|
|
8138
8314
|
cursor = cursor.add({ months: this.opts.interval ?? 1 });
|
|
8139
8315
|
if (this.opts.until) {
|
|
@@ -8149,10 +8325,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
8149
8325
|
if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
8150
8326
|
if (this.rscaleDateMatches(calId, pd)) {
|
|
8151
8327
|
const base = this.buildZdtFromPlainDate(pd);
|
|
8152
|
-
|
|
8153
|
-
occs = this.applyBySetPos(occs);
|
|
8154
|
-
const { shouldBreak } = this.processOccurrences(occs, dates, start, iterator);
|
|
8155
|
-
if (shouldBreak) break;
|
|
8328
|
+
if (!this.visitPeriodCandidates([base], (candidate) => this.processOccurrence(candidate, dates, start, iterator, void 0, work), queryLowerBound ?? start, this.opts.until, work)) break;
|
|
8156
8329
|
}
|
|
8157
8330
|
pd = pd.add({ days: this.opts.interval ?? 1 });
|
|
8158
8331
|
if (this.opts.until) {
|
|
@@ -8172,13 +8345,11 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
8172
8345
|
if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
|
|
8173
8346
|
if (this.rscaleDateMatches(calId, pd)) {
|
|
8174
8347
|
const base = this.buildZdtFromPlainDate(pd);
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
return
|
|
8179
|
-
});
|
|
8180
|
-
const { shouldBreak } = this.processOccurrences(occs, dates, start, iterator);
|
|
8181
|
-
if (shouldBreak) break;
|
|
8348
|
+
if (!this.visitDateTimeCandidates([base], 1, (candidate) => {
|
|
8349
|
+
const delta = candidate.toInstant().epochMilliseconds - startInstantMs;
|
|
8350
|
+
if (Math.floor(delta / unitMs) % interval !== 0) return true;
|
|
8351
|
+
return this.processOccurrence(candidate, dates, start, iterator, void 0, work);
|
|
8352
|
+
}, queryLowerBound ?? start, this.opts.until, work)) break;
|
|
8182
8353
|
}
|
|
8183
8354
|
pd = pd.add({ days: 1 });
|
|
8184
8355
|
if (this.opts.until) {
|