rrule-temporal 2.0.0 → 2.0.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 CHANGED
@@ -309,31 +309,37 @@ Uncached median ops/s from the benchmark suite on a MacBook Pro M2 Max
309
309
 
310
310
  | Scenario | TZ | rrule-temporal median ops/s | rrule median ops/s | vs rrule |
311
311
  | --- | --- | ---: | ---: | ---: |
312
- | 30 daily occurrences | UTC | 19,443 | 15,825 | 1.23x |
313
- | 30 daily occurrences | America/Chicago | 13,525 | 347 | 38.98x |
314
- | Daily weekdays across many cycles | UTC | 997 | 759 | 1.31x |
315
- | Daily weekdays across many cycles | America/Chicago | 751 | 17.9 | 41.96x |
316
- | 720 hourly occurrences | UTC | 713 | 653 | 1.09x |
317
- | 720 hourly occurrences | America/Chicago | 502 | 14.1 | 35.60x |
318
- | 1,440 minutely occurrences | UTC | 343 | 333 | 1.03x |
319
- | 1,440 minutely occurrences | America/Chicago | 259 | 6.6 | 39.24x |
320
- | Weekly MO/WE/FR across many cycles | UTC | 632 | 1,068 | 0.59x |
321
- | Weekly MO/WE/FR across many cycles | America/Chicago | 471 | 13.1 | 35.95x |
322
- | Monthly last weekday across 20 years | UTC | 1,120 | 1,010 | 1.11x |
323
- | Monthly last weekday across 20 years | America/Chicago | 980 | 36.7 | 26.70x |
324
- | Monthly first and last weekday across 20 years | UTC | 723 | 1,277 | 0.57x |
325
- | Monthly first and last weekday across 20 years | America/Chicago | 562 | 22.2 | 25.32x |
312
+ | 30 daily occurrences | UTC | 22,308 | 17,932 | 1.24x |
313
+ | 30 daily occurrences | America/Chicago | 15,358 | 384 | 40.00x |
314
+ | Daily weekdays across many cycles | UTC | 1,192 | 830 | 1.44x |
315
+ | Daily weekdays across many cycles | America/Chicago | 873 | 20.9 | 41.77x |
316
+ | Daily time-slot expansion | UTC | 611 | 1,199 | 0.51x |
317
+ | Daily time-slot expansion | America/Chicago | 448 | 11.7 | 38.29x |
318
+ | 720 hourly occurrences | UTC | 817 | 757 | 1.08x |
319
+ | 720 hourly occurrences | America/Chicago | 588 | 13.9 | 42.30x |
320
+ | 1,440 minutely occurrences | UTC | 392 | 364 | 1.08x |
321
+ | 1,440 minutely occurrences | America/Chicago | 287 | 7.4 | 38.78x |
322
+ | 3,600 secondly occurrences | UTC | 152 | 144 | 1.06x |
323
+ | 3,600 secondly occurrences | America/Chicago | 113 | 2.9 | 38.97x |
324
+ | Weekly MO/WE/FR across many cycles | UTC | 662 | 1,137 | 0.58x |
325
+ | Weekly MO/WE/FR across many cycles | America/Chicago | 493 | 14.7 | 33.54x |
326
+ | Weekly day and time-slot expansion | UTC | 502 | 1,207 | 0.42x |
327
+ | Weekly day and time-slot expansion | America/Chicago | 394 | 12.2 | 32.30x |
328
+ | Monthly last weekday across 20 years | UTC | 1,314 | 1,119 | 1.17x |
329
+ | Monthly last weekday across 20 years | America/Chicago | 1,043 | 41.7 | 25.01x |
330
+ | Monthly first and last weekday across 20 years | UTC | 804 | 1,326 | 0.61x |
331
+ | Monthly first and last weekday across 20 years | America/Chicago | 622 | 24.9 | 24.98x |
326
332
 
327
333
  Time-zone-aware rules iterate through an epoch-integer engine with a cached
328
334
  per-zone offset table, so named-zone scenarios now run 25–42x faster than
329
335
  `rrule` and within a small factor of their UTC equivalents. On UTC the two
330
- libraries are comparable on Node 25 (`rrule` stays ahead on two weekly/monthly
331
- scenarios where occurrence materialization dominates); on runtimes with native
332
- Temporal (Node 26+, Chrome 144+, Firefox 139+) materialization is much cheaper
333
- and `rrule-temporal` leads every scenario — e.g. monthly last weekday in
334
- Chicago reaches ~2,200 ops/s and daily weekdays ~2,800 ops/s. Repeated
335
- `all()` calls on the same rule are served from an internal cache (opt out per
336
- rule with `cache: false`).
336
+ libraries are comparable on Node 25 (`rrule` stays ahead in several expanded
337
+ and weekly/monthly scenarios where occurrence materialization dominates); on
338
+ runtimes with native Temporal (Node 26+, Chrome 144+, Firefox 139+)
339
+ materialization is much cheaper, and `rrule-temporal` led every measured core
340
+ scenario — e.g. monthly last weekday in Chicago reaches ~2,200 ops/s and daily
341
+ weekdays ~2,800 ops/s. Repeated `all()` calls on the same rule are served from
342
+ an internal cache (opt out per rule with `cache: false`).
337
343
 
338
344
  ## Further examples
339
345
 
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-B0RsDEOV.cjs");
2
+ const require_src = require("./src-BQ3CQXjR.cjs");
3
3
  exports.RRuleTemporal = require_src.RRuleTemporal;
4
4
  exports.allowedFreq = require_src.allowedFreq;
5
5
  exports.allowedWeekdays = require_src.allowedWeekdays;
package/dist/index.d.cts CHANGED
@@ -107,6 +107,7 @@ declare class RRuleTemporal {
107
107
  private readonly hasOrdinalByDay;
108
108
  private readonly canUseEpochMillisecondsPrecisionFlag;
109
109
  private readonly timeSlotOffsetsMs?;
110
+ private readonly hasUniqueTimeSlotOffsets;
110
111
  private readonly numericByMonths?;
111
112
  private exDateEpochNs?;
112
113
  private allResultCache?;
@@ -172,7 +173,9 @@ declare class RRuleTemporal {
172
173
  private allUtcFastPath;
173
174
  private _allUtcFixedStepSimple;
174
175
  private _allUtcDailySimple;
176
+ private _allUtcDailyExpanded;
175
177
  private _allUtcWeeklySimple;
178
+ private _allUtcWeeklyExpanded;
176
179
  private hasSingleExpandedTimeSlot;
177
180
  private buildMonthlyOccurrenceOnDay;
178
181
  private applyBySetPosToSortedList;
@@ -199,8 +202,10 @@ declare class RRuleTemporal {
199
202
  private tzFastPathGapHazard;
200
203
  private allTzEpochFastPath;
201
204
  private _allTzDailySimple;
205
+ private _allTzDailyExpanded;
202
206
  private _allTzFixedStepSimple;
203
207
  private _allTzWeeklySimple;
208
+ private _allTzWeeklyExpanded;
204
209
  private _allTzMonthlyByDayOrMonthDay;
205
210
  private processOccurrences;
206
211
  /**
package/dist/index.d.ts CHANGED
@@ -107,6 +107,7 @@ declare class RRuleTemporal {
107
107
  private readonly hasOrdinalByDay;
108
108
  private readonly canUseEpochMillisecondsPrecisionFlag;
109
109
  private readonly timeSlotOffsetsMs?;
110
+ private readonly hasUniqueTimeSlotOffsets;
110
111
  private readonly numericByMonths?;
111
112
  private exDateEpochNs?;
112
113
  private allResultCache?;
@@ -172,7 +173,9 @@ declare class RRuleTemporal {
172
173
  private allUtcFastPath;
173
174
  private _allUtcFixedStepSimple;
174
175
  private _allUtcDailySimple;
176
+ private _allUtcDailyExpanded;
175
177
  private _allUtcWeeklySimple;
178
+ private _allUtcWeeklyExpanded;
176
179
  private hasSingleExpandedTimeSlot;
177
180
  private buildMonthlyOccurrenceOnDay;
178
181
  private applyBySetPosToSortedList;
@@ -199,8 +202,10 @@ declare class RRuleTemporal {
199
202
  private tzFastPathGapHazard;
200
203
  private allTzEpochFastPath;
201
204
  private _allTzDailySimple;
205
+ private _allTzDailyExpanded;
202
206
  private _allTzFixedStepSimple;
203
207
  private _allTzWeeklySimple;
208
+ private _allTzWeeklyExpanded;
204
209
  private _allTzMonthlyByDayOrMonthDay;
205
210
  private processOccurrences;
206
211
  /**
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as weekdayToIsoDay, n as allowedFreq, r as allowedWeekdays, t as RRuleTemporal } from "./src-DEpYefSo.js";
1
+ import { i as weekdayToIsoDay, n as allowedFreq, r as allowedWeekdays, t as RRuleTemporal } from "./src-PFG2hz2E.js";
2
2
  export { RRuleTemporal, allowedFreq, allowedWeekdays, weekdayToIsoDay };
@@ -4967,6 +4967,7 @@ var RRuleTemporal = class RRuleTemporal {
4967
4967
  this.hasOrdinalByDay = this.parsedByDayTokens?.some((token) => token.ord !== 0) ?? false;
4968
4968
  this.canUseEpochMillisecondsPrecisionFlag = this.originalDtstart.microsecond === 0 && this.originalDtstart.nanosecond === 0 && (!this.opts.until || this.opts.until.microsecond === 0 && this.opts.until.nanosecond === 0);
4969
4969
  this.timeSlotOffsetsMs = this.buildTimeSlotOffsetsMs();
4970
+ this.hasUniqueTimeSlotOffsets = this.timeSlotOffsetsMs === void 0 || new Set(this.timeSlotOffsetsMs).size === this.timeSlotOffsetsMs.length;
4970
4971
  this.numericByMonths = this.opts.byMonth?.filter((value) => typeof value === "number");
4971
4972
  }
4972
4973
  buildParsedByDayTokens(byDay) {
@@ -5504,14 +5505,15 @@ var RRuleTemporal = class RRuleTemporal {
5504
5505
  if (iterator || this.tzid !== "UTC" || this.opts.rscale || this.opts.rDate || this.opts.exDate) return false;
5505
5506
  if (this.opts.byMonth || this.opts.byMonthDay || this.opts.byYearDay || this.opts.byWeekNo || this.opts.bySetPos) return false;
5506
5507
  switch (this.opts.freq) {
5507
- case "DAILY": return !this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond && !this.hasOrdinalByDay;
5508
+ case "DAILY": return !this.hasOrdinalByDay && (!this.opts.byHour || this.canUseEpochMillisecondsPrecisionFlag) && (!this.opts.byMinute || this.canUseEpochMillisecondsPrecisionFlag) && (!this.opts.bySecond || this.canUseEpochMillisecondsPrecisionFlag);
5508
5509
  case "HOURLY":
5509
- case "MINUTELY": return !this.opts.byDay && !this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond;
5510
+ case "MINUTELY":
5511
+ case "SECONDLY": return !this.opts.byDay && !this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond;
5510
5512
  default: return false;
5511
5513
  }
5512
5514
  }
5513
5515
  canUseUtcWeeklyFastPath(iterator) {
5514
- 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.opts.byMinute && !this.opts.bySecond && !this.hasOrdinalByDay;
5516
+ 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;
5515
5517
  }
5516
5518
  canUseUtcMonthlyFastPath(iterator) {
5517
5519
  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);
@@ -5545,12 +5547,13 @@ var RRuleTemporal = class RRuleTemporal {
5545
5547
  }
5546
5548
  allUtcFastPath(iterator) {
5547
5549
  if (this.canUseUtcLinearFastPath(iterator)) switch (this.opts.freq) {
5548
- case "DAILY": return this._allUtcDailySimple();
5550
+ case "DAILY": return this.opts.byHour || this.opts.byMinute || this.opts.bySecond ? this.hasUniqueTimeSlotOffsets ? this._allUtcDailyExpanded() : null : this._allUtcDailySimple();
5549
5551
  case "HOURLY": return this._allUtcFixedStepSimple(NS_PER_HOUR * BigInt(this.opts.interval));
5550
5552
  case "MINUTELY": return this._allUtcFixedStepSimple(NS_PER_MINUTE * BigInt(this.opts.interval));
5553
+ case "SECONDLY": return this._allUtcFixedStepSimple(NS_PER_SECOND * BigInt(this.opts.interval));
5551
5554
  }
5552
5555
  if (this.canUseUtcMonthlyFastPath(iterator)) return this._allUtcMonthlyByDayOrMonthDay();
5553
- if (this.canUseUtcWeeklyFastPath(iterator)) return this._allUtcWeeklySimple();
5556
+ if (this.canUseUtcWeeklyFastPath(iterator)) return this.opts.byHour || this.opts.byMinute || this.opts.bySecond ? this.hasUniqueTimeSlotOffsets ? this._allUtcWeeklyExpanded() : null : this._allUtcWeeklySimple();
5554
5557
  return null;
5555
5558
  }
5556
5559
  _allUtcFixedStepSimple(stepNanoseconds) {
@@ -5632,6 +5635,39 @@ var RRuleTemporal = class RRuleTemporal {
5632
5635
  }
5633
5636
  return dates;
5634
5637
  }
5638
+ _allUtcDailyExpanded() {
5639
+ const dates = [];
5640
+ if (!this.addDtstartIfNeeded(dates)) return dates;
5641
+ const timeSlotOffsets = this.timeSlotOffsetsMs;
5642
+ const startMilliseconds = this.originalDtstart.epochMilliseconds;
5643
+ const untilMilliseconds = this.opts.until?.epochMilliseconds;
5644
+ const stepDays = this.opts.interval;
5645
+ const allowedDays = this.simpleByDayIsoDays;
5646
+ let epochDay = Math.floor(startMilliseconds / MS_PER_DAY);
5647
+ let dayOfWeek = this.originalDtstart.dayOfWeek;
5648
+ if (allowedDays?.length) {
5649
+ const firstMatchingDayOffset = this.findFirstMatchingDailyStep(dayOfWeek, 1, allowedDays);
5650
+ if (firstMatchingDayOffset === null) return dates;
5651
+ epochDay += firstMatchingDayOffset;
5652
+ dayOfWeek = addIsoDays(dayOfWeek, firstMatchingDayOffset);
5653
+ }
5654
+ let iterationCount = 0;
5655
+ while (true) {
5656
+ if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
5657
+ if (!allowedDays || allowedDays.includes(dayOfWeek)) {
5658
+ const dayStartMilliseconds = epochDay * MS_PER_DAY;
5659
+ for (const timeSlotOffset of timeSlotOffsets) {
5660
+ const occurrenceMilliseconds = dayStartMilliseconds + timeSlotOffset;
5661
+ if (occurrenceMilliseconds < startMilliseconds) continue;
5662
+ if (untilMilliseconds !== void 0 && occurrenceMilliseconds > untilMilliseconds) return dates;
5663
+ dates.push(this.utcZdtFromEpochMilliseconds(occurrenceMilliseconds));
5664
+ if (this.shouldBreakForCountLimit(dates.length)) return dates;
5665
+ }
5666
+ }
5667
+ epochDay += stepDays;
5668
+ dayOfWeek = addIsoDays(dayOfWeek, stepDays);
5669
+ }
5670
+ }
5635
5671
  _allUtcWeeklySimple() {
5636
5672
  const dates = [];
5637
5673
  if (!this.addDtstartIfNeeded(dates)) return dates;
@@ -5673,6 +5709,35 @@ var RRuleTemporal = class RRuleTemporal {
5673
5709
  weekStartNanoseconds += weekStepNanoseconds;
5674
5710
  }
5675
5711
  }
5712
+ _allUtcWeeklyExpanded() {
5713
+ const dates = [];
5714
+ if (!this.addDtstartIfNeeded(dates)) return dates;
5715
+ const start = this.originalDtstart;
5716
+ const startMilliseconds = start.epochMilliseconds;
5717
+ const startEpochDay = Math.floor(startMilliseconds / MS_PER_DAY);
5718
+ const untilMilliseconds = this.opts.until?.epochMilliseconds;
5719
+ const timeSlotOffsets = this.timeSlotOffsetsMs;
5720
+ const wkstDay = weekdayToIsoDay[extractWeekdayToken(this.opts.wkst || "MO") ?? "MO"] ?? 1;
5721
+ const dayOffsets = (this.opts.byDay ? [...this.allByDayIsoDays ?? []] : [start.dayOfWeek]).map((day) => (day - wkstDay + 7) % 7).sort((a, b) => a - b);
5722
+ const weekStartOffset = (start.dayOfWeek - wkstDay + 7) % 7;
5723
+ const stepDaysPerWeek = this.opts.interval * 7;
5724
+ let weekStartDay = startEpochDay - weekStartOffset;
5725
+ let iterationCount = 0;
5726
+ while (true) {
5727
+ if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
5728
+ for (const dayOffset of dayOffsets) {
5729
+ const dayStartMilliseconds = (weekStartDay + dayOffset) * MS_PER_DAY;
5730
+ for (const timeSlotOffset of timeSlotOffsets) {
5731
+ const occurrenceMilliseconds = dayStartMilliseconds + timeSlotOffset;
5732
+ if (occurrenceMilliseconds < startMilliseconds) continue;
5733
+ if (untilMilliseconds !== void 0 && occurrenceMilliseconds > untilMilliseconds) return dates;
5734
+ dates.push(this.utcZdtFromEpochMilliseconds(occurrenceMilliseconds));
5735
+ if (this.shouldBreakForCountLimit(dates.length)) return dates;
5736
+ }
5737
+ }
5738
+ weekStartDay += stepDaysPerWeek;
5739
+ }
5740
+ }
5676
5741
  hasSingleExpandedTimeSlot() {
5677
5742
  if (this.timeSlotOffsetsMs) return this.timeSlotOffsetsMs.length === 1;
5678
5743
  const hours = this.opts.byHour ?? [this.originalDtstart.hour];
@@ -5903,18 +5968,19 @@ var RRuleTemporal = class RRuleTemporal {
5903
5968
  const linearEligible = !this.opts.byMonth && !this.opts.byMonthDay && !this.opts.byYearDay && !this.opts.byWeekNo && !this.opts.bySetPos;
5904
5969
  if (linearEligible) switch (this.opts.freq) {
5905
5970
  case "DAILY":
5906
- if (!this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond && !this.hasOrdinalByDay) return this._allTzDailySimple();
5971
+ if (!this.hasOrdinalByDay) return this.opts.byHour || this.opts.byMinute || this.opts.bySecond ? this.hasUniqueTimeSlotOffsets ? this._allTzDailyExpanded() : null : this._allTzDailySimple();
5907
5972
  break;
5908
5973
  case "HOURLY":
5909
5974
  case "MINUTELY":
5975
+ case "SECONDLY":
5910
5976
  if (!this.opts.byDay && !this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond) {
5911
- const stepMs = this.opts.freq === "HOURLY" ? MS_PER_HOUR : MS_PER_MINUTE;
5977
+ const stepMs = this.opts.freq === "HOURLY" ? MS_PER_HOUR : this.opts.freq === "MINUTELY" ? MS_PER_MINUTE : MS_PER_SECOND;
5912
5978
  return this._allTzFixedStepSimple(stepMs * this.opts.interval);
5913
5979
  }
5914
5980
  break;
5915
5981
  }
5916
5982
  if (this.opts.freq === "MONTHLY" && !this.opts.byYearDay && !this.opts.byWeekNo && !!(this.opts.byDay || this.opts.byMonthDay)) return this._allTzMonthlyByDayOrMonthDay();
5917
- if (this.opts.freq === "WEEKLY" && linearEligible && !this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond && !this.hasOrdinalByDay) return this._allTzWeeklySimple();
5983
+ if (this.opts.freq === "WEEKLY" && linearEligible && !this.hasOrdinalByDay && this.hasUniqueTimeSlotOffsets) return this.opts.byHour || this.opts.byMinute || this.opts.bySecond ? this._allTzWeeklyExpanded() : this._allTzWeeklySimple();
5918
5984
  return null;
5919
5985
  }
5920
5986
  _allTzDailySimple() {
@@ -5950,6 +6016,43 @@ var RRuleTemporal = class RRuleTemporal {
5950
6016
  }
5951
6017
  return dates;
5952
6018
  }
6019
+ _allTzDailyExpanded() {
6020
+ const dates = [];
6021
+ if (!this.addDtstartIfNeeded(dates)) return dates;
6022
+ const resolver = this.getZoneResolver();
6023
+ const startEpochMs = this.originalDtstart.epochMilliseconds;
6024
+ const startWallMs = this.wallMsOf(this.originalDtstart);
6025
+ const timeSlotOffsets = this.timeSlotOffsetsMs;
6026
+ for (const timeSlotOffset of timeSlotOffsets) if (this.tzFastPathGapHazard(timeSlotOffset)) return null;
6027
+ const stepDays = this.opts.interval;
6028
+ const allowedDays = this.simpleByDayIsoDays;
6029
+ const untilMs = this.opts.until?.epochMilliseconds;
6030
+ let epochDay = Math.floor(startWallMs / MS_PER_DAY);
6031
+ let dayOfWeek = isoDayOfWeekOfEpochDay(epochDay);
6032
+ if (allowedDays?.length) {
6033
+ const firstMatchingDayOffset = this.findFirstMatchingDailyStep(dayOfWeek, 1, allowedDays);
6034
+ if (firstMatchingDayOffset === null) return dates;
6035
+ epochDay += firstMatchingDayOffset;
6036
+ dayOfWeek = addIsoDays(dayOfWeek, firstMatchingDayOffset);
6037
+ }
6038
+ let iterationCount = 0;
6039
+ while (true) {
6040
+ if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
6041
+ if (!allowedDays || allowedDays.includes(dayOfWeek)) {
6042
+ const dayStartWallMs = epochDay * MS_PER_DAY;
6043
+ for (const timeSlotOffset of timeSlotOffsets) {
6044
+ const resolution = resolver.epochMsForWall(dayStartWallMs + timeSlotOffset);
6045
+ if (resolution.pushed) return null;
6046
+ if (resolution.epochMs < startEpochMs) continue;
6047
+ if (untilMs !== void 0 && resolution.epochMs > untilMs) return dates;
6048
+ dates.push(this.zdtFromEpochMs(resolution.epochMs));
6049
+ if (this.shouldBreakForCountLimit(dates.length)) return dates;
6050
+ }
6051
+ }
6052
+ epochDay += stepDays;
6053
+ dayOfWeek = addIsoDays(dayOfWeek, stepDays);
6054
+ }
6055
+ }
5953
6056
  _allTzFixedStepSimple(stepMs) {
5954
6057
  const dates = [];
5955
6058
  if (!this.addDtstartIfNeeded(dates)) return dates;
@@ -6004,6 +6107,40 @@ var RRuleTemporal = class RRuleTemporal {
6004
6107
  weekStartDay += stepDaysPerWeek;
6005
6108
  }
6006
6109
  }
6110
+ _allTzWeeklyExpanded() {
6111
+ const dates = [];
6112
+ if (!this.addDtstartIfNeeded(dates)) return dates;
6113
+ const resolver = this.getZoneResolver();
6114
+ const start = this.originalDtstart;
6115
+ const startEpochMs = start.epochMilliseconds;
6116
+ const startWallMs = this.wallMsOf(start);
6117
+ const startEpochDay = Math.floor(startWallMs / MS_PER_DAY);
6118
+ const timeSlotOffsets = this.timeSlotOffsetsMs;
6119
+ for (const timeSlotOffset of timeSlotOffsets) if (this.tzFastPathGapHazard(timeSlotOffset)) return null;
6120
+ const startDayOfWeek = isoDayOfWeekOfEpochDay(startEpochDay);
6121
+ const wkstDay = weekdayToIsoDay[extractWeekdayToken(this.opts.wkst || "MO") ?? "MO"] ?? 1;
6122
+ const dayOffsets = (this.opts.byDay ? [...this.allByDayIsoDays ?? []] : [startDayOfWeek]).map((day) => (day - wkstDay + 7) % 7).sort((a, b) => a - b);
6123
+ const weekStartOffset = (startDayOfWeek - wkstDay + 7) % 7;
6124
+ const untilMs = this.opts.until?.epochMilliseconds;
6125
+ const stepDaysPerWeek = this.opts.interval * 7;
6126
+ let weekStartDay = startEpochDay - weekStartOffset;
6127
+ let iterationCount = 0;
6128
+ while (true) {
6129
+ if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
6130
+ for (const dayOffset of dayOffsets) {
6131
+ const dayStartWallMs = (weekStartDay + dayOffset) * MS_PER_DAY;
6132
+ for (const timeSlotOffset of timeSlotOffsets) {
6133
+ const resolution = resolver.epochMsForWall(dayStartWallMs + timeSlotOffset);
6134
+ if (resolution.pushed) return null;
6135
+ if (resolution.epochMs < startEpochMs) continue;
6136
+ if (untilMs !== void 0 && resolution.epochMs > untilMs) return dates;
6137
+ dates.push(this.zdtFromEpochMs(resolution.epochMs));
6138
+ if (this.shouldBreakForCountLimit(dates.length)) return dates;
6139
+ }
6140
+ }
6141
+ weekStartDay += stepDaysPerWeek;
6142
+ }
6143
+ }
6007
6144
  _allTzMonthlyByDayOrMonthDay() {
6008
6145
  const dates = [];
6009
6146
  if (!this.addDtstartIfNeeded(dates)) return dates;
@@ -4967,6 +4967,7 @@ var RRuleTemporal = class RRuleTemporal {
4967
4967
  this.hasOrdinalByDay = this.parsedByDayTokens?.some((token) => token.ord !== 0) ?? false;
4968
4968
  this.canUseEpochMillisecondsPrecisionFlag = this.originalDtstart.microsecond === 0 && this.originalDtstart.nanosecond === 0 && (!this.opts.until || this.opts.until.microsecond === 0 && this.opts.until.nanosecond === 0);
4969
4969
  this.timeSlotOffsetsMs = this.buildTimeSlotOffsetsMs();
4970
+ this.hasUniqueTimeSlotOffsets = this.timeSlotOffsetsMs === void 0 || new Set(this.timeSlotOffsetsMs).size === this.timeSlotOffsetsMs.length;
4970
4971
  this.numericByMonths = this.opts.byMonth?.filter((value) => typeof value === "number");
4971
4972
  }
4972
4973
  buildParsedByDayTokens(byDay) {
@@ -5504,14 +5505,15 @@ var RRuleTemporal = class RRuleTemporal {
5504
5505
  if (iterator || this.tzid !== "UTC" || this.opts.rscale || this.opts.rDate || this.opts.exDate) return false;
5505
5506
  if (this.opts.byMonth || this.opts.byMonthDay || this.opts.byYearDay || this.opts.byWeekNo || this.opts.bySetPos) return false;
5506
5507
  switch (this.opts.freq) {
5507
- case "DAILY": return !this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond && !this.hasOrdinalByDay;
5508
+ case "DAILY": return !this.hasOrdinalByDay && (!this.opts.byHour || this.canUseEpochMillisecondsPrecisionFlag) && (!this.opts.byMinute || this.canUseEpochMillisecondsPrecisionFlag) && (!this.opts.bySecond || this.canUseEpochMillisecondsPrecisionFlag);
5508
5509
  case "HOURLY":
5509
- case "MINUTELY": return !this.opts.byDay && !this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond;
5510
+ case "MINUTELY":
5511
+ case "SECONDLY": return !this.opts.byDay && !this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond;
5510
5512
  default: return false;
5511
5513
  }
5512
5514
  }
5513
5515
  canUseUtcWeeklyFastPath(iterator) {
5514
- 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.opts.byMinute && !this.opts.bySecond && !this.hasOrdinalByDay;
5516
+ 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;
5515
5517
  }
5516
5518
  canUseUtcMonthlyFastPath(iterator) {
5517
5519
  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);
@@ -5545,12 +5547,13 @@ var RRuleTemporal = class RRuleTemporal {
5545
5547
  }
5546
5548
  allUtcFastPath(iterator) {
5547
5549
  if (this.canUseUtcLinearFastPath(iterator)) switch (this.opts.freq) {
5548
- case "DAILY": return this._allUtcDailySimple();
5550
+ case "DAILY": return this.opts.byHour || this.opts.byMinute || this.opts.bySecond ? this.hasUniqueTimeSlotOffsets ? this._allUtcDailyExpanded() : null : this._allUtcDailySimple();
5549
5551
  case "HOURLY": return this._allUtcFixedStepSimple(NS_PER_HOUR * BigInt(this.opts.interval));
5550
5552
  case "MINUTELY": return this._allUtcFixedStepSimple(NS_PER_MINUTE * BigInt(this.opts.interval));
5553
+ case "SECONDLY": return this._allUtcFixedStepSimple(NS_PER_SECOND * BigInt(this.opts.interval));
5551
5554
  }
5552
5555
  if (this.canUseUtcMonthlyFastPath(iterator)) return this._allUtcMonthlyByDayOrMonthDay();
5553
- if (this.canUseUtcWeeklyFastPath(iterator)) return this._allUtcWeeklySimple();
5556
+ if (this.canUseUtcWeeklyFastPath(iterator)) return this.opts.byHour || this.opts.byMinute || this.opts.bySecond ? this.hasUniqueTimeSlotOffsets ? this._allUtcWeeklyExpanded() : null : this._allUtcWeeklySimple();
5554
5557
  return null;
5555
5558
  }
5556
5559
  _allUtcFixedStepSimple(stepNanoseconds) {
@@ -5632,6 +5635,39 @@ var RRuleTemporal = class RRuleTemporal {
5632
5635
  }
5633
5636
  return dates;
5634
5637
  }
5638
+ _allUtcDailyExpanded() {
5639
+ const dates = [];
5640
+ if (!this.addDtstartIfNeeded(dates)) return dates;
5641
+ const timeSlotOffsets = this.timeSlotOffsetsMs;
5642
+ const startMilliseconds = this.originalDtstart.epochMilliseconds;
5643
+ const untilMilliseconds = this.opts.until?.epochMilliseconds;
5644
+ const stepDays = this.opts.interval;
5645
+ const allowedDays = this.simpleByDayIsoDays;
5646
+ let epochDay = Math.floor(startMilliseconds / MS_PER_DAY);
5647
+ let dayOfWeek = this.originalDtstart.dayOfWeek;
5648
+ if (allowedDays?.length) {
5649
+ const firstMatchingDayOffset = this.findFirstMatchingDailyStep(dayOfWeek, 1, allowedDays);
5650
+ if (firstMatchingDayOffset === null) return dates;
5651
+ epochDay += firstMatchingDayOffset;
5652
+ dayOfWeek = addIsoDays(dayOfWeek, firstMatchingDayOffset);
5653
+ }
5654
+ let iterationCount = 0;
5655
+ while (true) {
5656
+ if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
5657
+ if (!allowedDays || allowedDays.includes(dayOfWeek)) {
5658
+ const dayStartMilliseconds = epochDay * MS_PER_DAY;
5659
+ for (const timeSlotOffset of timeSlotOffsets) {
5660
+ const occurrenceMilliseconds = dayStartMilliseconds + timeSlotOffset;
5661
+ if (occurrenceMilliseconds < startMilliseconds) continue;
5662
+ if (untilMilliseconds !== void 0 && occurrenceMilliseconds > untilMilliseconds) return dates;
5663
+ dates.push(this.utcZdtFromEpochMilliseconds(occurrenceMilliseconds));
5664
+ if (this.shouldBreakForCountLimit(dates.length)) return dates;
5665
+ }
5666
+ }
5667
+ epochDay += stepDays;
5668
+ dayOfWeek = addIsoDays(dayOfWeek, stepDays);
5669
+ }
5670
+ }
5635
5671
  _allUtcWeeklySimple() {
5636
5672
  const dates = [];
5637
5673
  if (!this.addDtstartIfNeeded(dates)) return dates;
@@ -5673,6 +5709,35 @@ var RRuleTemporal = class RRuleTemporal {
5673
5709
  weekStartNanoseconds += weekStepNanoseconds;
5674
5710
  }
5675
5711
  }
5712
+ _allUtcWeeklyExpanded() {
5713
+ const dates = [];
5714
+ if (!this.addDtstartIfNeeded(dates)) return dates;
5715
+ const start = this.originalDtstart;
5716
+ const startMilliseconds = start.epochMilliseconds;
5717
+ const startEpochDay = Math.floor(startMilliseconds / MS_PER_DAY);
5718
+ const untilMilliseconds = this.opts.until?.epochMilliseconds;
5719
+ const timeSlotOffsets = this.timeSlotOffsetsMs;
5720
+ const wkstDay = weekdayToIsoDay[extractWeekdayToken(this.opts.wkst || "MO") ?? "MO"] ?? 1;
5721
+ const dayOffsets = (this.opts.byDay ? [...this.allByDayIsoDays ?? []] : [start.dayOfWeek]).map((day) => (day - wkstDay + 7) % 7).sort((a, b) => a - b);
5722
+ const weekStartOffset = (start.dayOfWeek - wkstDay + 7) % 7;
5723
+ const stepDaysPerWeek = this.opts.interval * 7;
5724
+ let weekStartDay = startEpochDay - weekStartOffset;
5725
+ let iterationCount = 0;
5726
+ while (true) {
5727
+ if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
5728
+ for (const dayOffset of dayOffsets) {
5729
+ const dayStartMilliseconds = (weekStartDay + dayOffset) * MS_PER_DAY;
5730
+ for (const timeSlotOffset of timeSlotOffsets) {
5731
+ const occurrenceMilliseconds = dayStartMilliseconds + timeSlotOffset;
5732
+ if (occurrenceMilliseconds < startMilliseconds) continue;
5733
+ if (untilMilliseconds !== void 0 && occurrenceMilliseconds > untilMilliseconds) return dates;
5734
+ dates.push(this.utcZdtFromEpochMilliseconds(occurrenceMilliseconds));
5735
+ if (this.shouldBreakForCountLimit(dates.length)) return dates;
5736
+ }
5737
+ }
5738
+ weekStartDay += stepDaysPerWeek;
5739
+ }
5740
+ }
5676
5741
  hasSingleExpandedTimeSlot() {
5677
5742
  if (this.timeSlotOffsetsMs) return this.timeSlotOffsetsMs.length === 1;
5678
5743
  const hours = this.opts.byHour ?? [this.originalDtstart.hour];
@@ -5903,18 +5968,19 @@ var RRuleTemporal = class RRuleTemporal {
5903
5968
  const linearEligible = !this.opts.byMonth && !this.opts.byMonthDay && !this.opts.byYearDay && !this.opts.byWeekNo && !this.opts.bySetPos;
5904
5969
  if (linearEligible) switch (this.opts.freq) {
5905
5970
  case "DAILY":
5906
- if (!this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond && !this.hasOrdinalByDay) return this._allTzDailySimple();
5971
+ if (!this.hasOrdinalByDay) return this.opts.byHour || this.opts.byMinute || this.opts.bySecond ? this.hasUniqueTimeSlotOffsets ? this._allTzDailyExpanded() : null : this._allTzDailySimple();
5907
5972
  break;
5908
5973
  case "HOURLY":
5909
5974
  case "MINUTELY":
5975
+ case "SECONDLY":
5910
5976
  if (!this.opts.byDay && !this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond) {
5911
- const stepMs = this.opts.freq === "HOURLY" ? MS_PER_HOUR : MS_PER_MINUTE;
5977
+ const stepMs = this.opts.freq === "HOURLY" ? MS_PER_HOUR : this.opts.freq === "MINUTELY" ? MS_PER_MINUTE : MS_PER_SECOND;
5912
5978
  return this._allTzFixedStepSimple(stepMs * this.opts.interval);
5913
5979
  }
5914
5980
  break;
5915
5981
  }
5916
5982
  if (this.opts.freq === "MONTHLY" && !this.opts.byYearDay && !this.opts.byWeekNo && !!(this.opts.byDay || this.opts.byMonthDay)) return this._allTzMonthlyByDayOrMonthDay();
5917
- if (this.opts.freq === "WEEKLY" && linearEligible && !this.opts.byHour && !this.opts.byMinute && !this.opts.bySecond && !this.hasOrdinalByDay) return this._allTzWeeklySimple();
5983
+ if (this.opts.freq === "WEEKLY" && linearEligible && !this.hasOrdinalByDay && this.hasUniqueTimeSlotOffsets) return this.opts.byHour || this.opts.byMinute || this.opts.bySecond ? this._allTzWeeklyExpanded() : this._allTzWeeklySimple();
5918
5984
  return null;
5919
5985
  }
5920
5986
  _allTzDailySimple() {
@@ -5950,6 +6016,43 @@ var RRuleTemporal = class RRuleTemporal {
5950
6016
  }
5951
6017
  return dates;
5952
6018
  }
6019
+ _allTzDailyExpanded() {
6020
+ const dates = [];
6021
+ if (!this.addDtstartIfNeeded(dates)) return dates;
6022
+ const resolver = this.getZoneResolver();
6023
+ const startEpochMs = this.originalDtstart.epochMilliseconds;
6024
+ const startWallMs = this.wallMsOf(this.originalDtstart);
6025
+ const timeSlotOffsets = this.timeSlotOffsetsMs;
6026
+ for (const timeSlotOffset of timeSlotOffsets) if (this.tzFastPathGapHazard(timeSlotOffset)) return null;
6027
+ const stepDays = this.opts.interval;
6028
+ const allowedDays = this.simpleByDayIsoDays;
6029
+ const untilMs = this.opts.until?.epochMilliseconds;
6030
+ let epochDay = Math.floor(startWallMs / MS_PER_DAY);
6031
+ let dayOfWeek = isoDayOfWeekOfEpochDay(epochDay);
6032
+ if (allowedDays?.length) {
6033
+ const firstMatchingDayOffset = this.findFirstMatchingDailyStep(dayOfWeek, 1, allowedDays);
6034
+ if (firstMatchingDayOffset === null) return dates;
6035
+ epochDay += firstMatchingDayOffset;
6036
+ dayOfWeek = addIsoDays(dayOfWeek, firstMatchingDayOffset);
6037
+ }
6038
+ let iterationCount = 0;
6039
+ while (true) {
6040
+ if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
6041
+ if (!allowedDays || allowedDays.includes(dayOfWeek)) {
6042
+ const dayStartWallMs = epochDay * MS_PER_DAY;
6043
+ for (const timeSlotOffset of timeSlotOffsets) {
6044
+ const resolution = resolver.epochMsForWall(dayStartWallMs + timeSlotOffset);
6045
+ if (resolution.pushed) return null;
6046
+ if (resolution.epochMs < startEpochMs) continue;
6047
+ if (untilMs !== void 0 && resolution.epochMs > untilMs) return dates;
6048
+ dates.push(this.zdtFromEpochMs(resolution.epochMs));
6049
+ if (this.shouldBreakForCountLimit(dates.length)) return dates;
6050
+ }
6051
+ }
6052
+ epochDay += stepDays;
6053
+ dayOfWeek = addIsoDays(dayOfWeek, stepDays);
6054
+ }
6055
+ }
5953
6056
  _allTzFixedStepSimple(stepMs) {
5954
6057
  const dates = [];
5955
6058
  if (!this.addDtstartIfNeeded(dates)) return dates;
@@ -6004,6 +6107,40 @@ var RRuleTemporal = class RRuleTemporal {
6004
6107
  weekStartDay += stepDaysPerWeek;
6005
6108
  }
6006
6109
  }
6110
+ _allTzWeeklyExpanded() {
6111
+ const dates = [];
6112
+ if (!this.addDtstartIfNeeded(dates)) return dates;
6113
+ const resolver = this.getZoneResolver();
6114
+ const start = this.originalDtstart;
6115
+ const startEpochMs = start.epochMilliseconds;
6116
+ const startWallMs = this.wallMsOf(start);
6117
+ const startEpochDay = Math.floor(startWallMs / MS_PER_DAY);
6118
+ const timeSlotOffsets = this.timeSlotOffsetsMs;
6119
+ for (const timeSlotOffset of timeSlotOffsets) if (this.tzFastPathGapHazard(timeSlotOffset)) return null;
6120
+ const startDayOfWeek = isoDayOfWeekOfEpochDay(startEpochDay);
6121
+ const wkstDay = weekdayToIsoDay[extractWeekdayToken(this.opts.wkst || "MO") ?? "MO"] ?? 1;
6122
+ const dayOffsets = (this.opts.byDay ? [...this.allByDayIsoDays ?? []] : [startDayOfWeek]).map((day) => (day - wkstDay + 7) % 7).sort((a, b) => a - b);
6123
+ const weekStartOffset = (startDayOfWeek - wkstDay + 7) % 7;
6124
+ const untilMs = this.opts.until?.epochMilliseconds;
6125
+ const stepDaysPerWeek = this.opts.interval * 7;
6126
+ let weekStartDay = startEpochDay - weekStartOffset;
6127
+ let iterationCount = 0;
6128
+ while (true) {
6129
+ if (++iterationCount > this.maxIterations) throw new Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);
6130
+ for (const dayOffset of dayOffsets) {
6131
+ const dayStartWallMs = (weekStartDay + dayOffset) * MS_PER_DAY;
6132
+ for (const timeSlotOffset of timeSlotOffsets) {
6133
+ const resolution = resolver.epochMsForWall(dayStartWallMs + timeSlotOffset);
6134
+ if (resolution.pushed) return null;
6135
+ if (resolution.epochMs < startEpochMs) continue;
6136
+ if (untilMs !== void 0 && resolution.epochMs > untilMs) return dates;
6137
+ dates.push(this.zdtFromEpochMs(resolution.epochMs));
6138
+ if (this.shouldBreakForCountLimit(dates.length)) return dates;
6139
+ }
6140
+ }
6141
+ weekStartDay += stepDaysPerWeek;
6142
+ }
6143
+ }
6007
6144
  _allTzMonthlyByDayOrMonthDay() {
6008
6145
  const dates = [];
6009
6146
  if (!this.addDtstartIfNeeded(dates)) return dates;
package/dist/totext.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-B0RsDEOV.cjs");
2
+ const require_src = require("./src-BQ3CQXjR.cjs");
3
3
  //#region src/totext.ts
4
4
  const en = {
5
5
  weekdayNames: [
package/dist/totext.js CHANGED
@@ -1,4 +1,4 @@
1
- import { r as allowedWeekdays, t as RRuleTemporal } from "./src-DEpYefSo.js";
1
+ import { r as allowedWeekdays, t as RRuleTemporal } from "./src-PFG2hz2E.js";
2
2
  //#region src/totext.ts
3
3
  const en = {
4
4
  weekdayNames: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rrule-temporal",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Recurrence rule (rrule) processing using Temporal PlainDate/PlainDateTime, with cross-timezone and cross-calendar rrule support",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -47,9 +47,6 @@
47
47
  "files": [
48
48
  "dist"
49
49
  ],
50
- "engines": {
51
- "node": ">=20"
52
- },
53
50
  "devDependencies": {
54
51
  "@js-temporal/polyfill": "^0.5.1",
55
52
  "@types/node": "^25.5.0",