rrule-temporal 2.2.8 → 2.3.0

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
@@ -6,6 +6,8 @@ The library accepts the familiar `RRULE` format and returns
6
6
 
7
7
  See the [demo site](https://ggaabe.github.io/rrule-temporal/) for an interactive playground.
8
8
 
9
+ If rrule-temporal saves you or your company time, please consider [sponsoring it](https://github.com/sponsors/ggaabe).
10
+
9
11
  > RRule-temporal was created to advance the JS RRule ecosystem to use Temporal instead of Date, and to properly support cross-timezone and calendar aware recurrence rules, as per the suggestion of rrule.js contributors.
10
12
  >https://github.com/jkbrzt/rrule/issues/450#issuecomment-1055853095
11
13
 
@@ -112,8 +114,9 @@ below. These correspond to the recurrence rule parts defined in RFC 5545:
112
114
  | `exDate` | Exception dates to exclude. |
113
115
  | `tzid` | Time zone identifier for interpreting dates. |
114
116
  | `maxIterations` | Safety cap for advancing outer recurrence periods (defaults to 10,000). |
115
- | `maxCandidateEvaluations` | Safety cap for candidate datetimes evaluated within recurrence periods (defaults to 1,000,000). |
117
+ | `maxCandidateEvaluations` | Safety cap for candidate datetimes evaluated within recurrence periods (defaults to 1,000,000). A query that passes it throws; raise it for a window of more dates. |
116
118
  | `includeDtstart` | Include `DTSTART` even if it does not match the pattern. |
119
+ | `allDay` | The rule has DATE values, as an all-day event does: `toString()` writes `DTSTART`, `RDATE` and `EXDATE` with `VALUE=DATE` and `UNTIL` as a date. Set for a rule read from a `VALUE=DATE` `DTSTART`. Takes effect when `dtstart` is the start of its day in the rule's time zone; the occurrences are the same either way. An `RDATE` or `EXDATE` with a time of day, or one that was read as a date-time, keeps its time. |
117
120
  | `strict` | Enforce RFC 5545 constraints strictly (defaults to false). |
118
121
  | `temporal` | Optional Temporal namespace used for public output values and their inferred types. |
119
122
  | `dtstart` | First occurrence as `Temporal.ZonedDateTime`. |
@@ -312,7 +315,7 @@ Notes
312
315
  | `occursOn(date)` | Convenience helper: true if any occurrence falls on the given `Temporal.PlainDate` in the rule's time zone (date-only, ignores time). |
313
316
  | `next(after?, inclusive?)` | Next occurrence after a given date. |
314
317
  | `previous(before?, inclusive?)` | Previous occurrence before a date. |
315
- | `toString()` | Convert the rule back into `DTSTART` and `RRULE` lines. |
318
+ | `toString()` | Convert the rule back into `DTSTART` and `RRULE` lines. An `allDay` rule, such as one read from a `VALUE=DATE` `DTSTART`, keeps `DTSTART`, `UNTIL`, `RDATE` and `EXDATE` as DATE values. |
316
319
  | `toText(rule, locale?, options?)` | Human readable description (`en`, `es`, `hi`, `yue`, `ar`, `he`, `zh`, `fr`). Options: `{ includeDtstart?: boolean, excludeTzAbbreviation?: boolean }`. |
317
320
  | `options()` | Return the normalized options object. |
318
321
 
@@ -492,6 +495,14 @@ change with the runtime.
492
495
 
493
496
  ## Sponsor
494
497
 
495
- If this library saves you time, sponsorship helps keep it maintained.
498
+ rrule-temporal powers RRULE scheduling in [pg-boss](https://github.com/timgit/pg-boss), is used by [node-ical](https://github.com/jens-maus/node-ical), and is installed millions of times a week. [Sponsoring it on GitHub](https://github.com/sponsors/ggaabe) helps keep it maintained. Company sponsors get a link here and on the [demo site](https://ggaabe.github.io/rrule-temporal/).
499
+
500
+ ### Bronze sponsors
501
+
502
+ > [PostalForm 💌](https://postalform.com/?utm_source=github&utm_medium=readme&utm_campaign=rrule-temporal) — upload a PDF and we print + mail it via USPS (no printer or stamps needed). The only mailing platform for AI Agents via MCP, and the easiest one for humans!
503
+
504
+ Need help with recurring events, time zones, or iCalendar in your own product? I'm available for consulting: reach me on [X](https://x.com/gabgarrett).
505
+
506
+ ## Author
496
507
 
497
- > This library is sponsored by [PostalForm 💌](https://postalform.com/?utm_source=github&utm_medium=readme&utm_campaign=rrule-temporal) — upload a PDF and we print + mail it via USPS (no printer or stamps needed). The only mailing platform for AI Agents via MCP, and the easiest one for humans!
508
+ Built and maintained by [Gabriel Garrett](https://github.com/ggaabe).
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./src-DcoDqR4A.cjs`);exports.RRuleTemporal=e.t,exports.allowedFreq=e.n,exports.allowedWeekdays=e.r,exports.weekdayToIsoDay=e.i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./src-nz0X2tSb.cjs`);exports.RRuleTemporal=e.t,exports.allowedFreq=e.n,exports.allowedWeekdays=e.r,exports.weekdayToIsoDay=e.i;
package/dist/index.d.cts CHANGED
@@ -28,6 +28,13 @@ interface BaseOpts<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDat
28
28
  skip?: 'OMIT' | 'BACKWARD' | 'FORWARD';
29
29
  /** Memoize the full occurrence list computed by all() (defaults to true). */
30
30
  cache?: boolean;
31
+ /**
32
+ * The rule has DATE values, as an all-day event does: toString() writes DTSTART, RDATE and
33
+ * EXDATE with VALUE=DATE and UNTIL as a date. Set for a rule read from a DTSTART with
34
+ * VALUE=DATE, and returned by options(). It takes effect when dtstart is the start of its
35
+ * day in the rule's time zone, and does not change which occurrences the rule has.
36
+ */
37
+ allDay?: boolean;
31
38
  }
32
39
  type TemporalZonedDateTime = Temporal.ZonedDateTime;
33
40
  type TemporalPlainDate = Temporal.PlainDate;
@@ -112,6 +119,11 @@ type RRuleResolvedOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZ
112
119
  declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
113
120
  private readonly tzid;
114
121
  private readonly originalDtstart;
122
+ /**
123
+ * The instants of RDATE and EXDATE values that an all-day rule read as date-times. toString()
124
+ * keeps them so, also when they are the start of a day.
125
+ */
126
+ private readDateTimes?;
115
127
  private originalPlainDtstart?;
116
128
  private readonly opts;
117
129
  private readonly outputTemporal?;
@@ -136,6 +148,7 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
136
148
  private numericQueryPlanCache;
137
149
  private periodQueryPlanCache;
138
150
  private dtstartIsOccurrenceCache?;
151
+ private yearlyDaysNeverMatchCache?;
139
152
  private static readonly rscaleCalendarSupport;
140
153
  /**
141
154
  * Normalize a ZonedDateTime to the polyfill implementation.
@@ -175,6 +188,12 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
175
188
  private needsSortedTimeFallback;
176
189
  private createCandidateWorkBudget;
177
190
  private recordCandidateEvaluation;
191
+ /**
192
+ * Charge a fast path's dates to the budget, as the general engine charges
193
+ * each candidate. A DTSTART that includeDtstart added is not a candidate.
194
+ */
195
+ private assertFastPathBudget;
196
+ private assertCandidateBudget;
178
197
  /**
179
198
  * Visit BYHOUR x BYMINUTE x BYSECOND without allocating the Cartesian
180
199
  * product. Returning false from `visit` terminates the innermost traversal
@@ -234,6 +253,15 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
234
253
  * without incorrectly judging the rule from DTSTART's year alone.
235
254
  */
236
255
  private hasPossibleYearDayWeekNoCombination;
256
+ /**
257
+ * BYDAY and BYMONTHDAY limit the days that a YEARLY rule gets from BYYEARDAY, or from an ordinal BYDAY
258
+ * counted over the year, so they can leave no day in any year (`BYYEARDAY=1;BYMONTHDAY=2`). Gregorian
259
+ * weekdays and leap years repeat every 400 years, so scanning 400 recurrence years decides it and the
260
+ * search can stop instead of running into maxIterations. A DTSTART in another calendar (for example
261
+ * `[u-ca=hebrew]`) counts its years in that calendar, whose years do not repeat that way, so the
262
+ * shortcut is left to the Gregorian calendar.
263
+ */
264
+ private yearlyDaysNeverMatch;
237
265
  options(): RRuleResolvedOptions<TOutput>;
238
266
  private cloneOptions;
239
267
  private cloneUpdateOptions;
@@ -270,6 +298,28 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
270
298
  private buildDailyNumericQueryPlan;
271
299
  private buildWeeklyNumericQueryPlan;
272
300
  private buildMonthlyNumericQueryPlan;
301
+ /**
302
+ * A MONTHLY or YEARLY period's candidates, sorted(days x time slots) and then
303
+ * narrowed by BYSETPOS, described by its day list alone. Days and slots are
304
+ * ascending and unique, and a slot is shorter than a day, so candidate k is
305
+ * day floor(k / S) at slot k % S, and BYSETPOS keeps the ascending, distinct
306
+ * indices it names. Null when the day list breaks that order.
307
+ */
308
+ private numericPeriodShape;
309
+ private numericPeriodWall;
310
+ /**
311
+ * Index of the first of a first period's ascending candidates at or after
312
+ * DTSTART, or null when one does not resolve or the kept ones are not a
313
+ * suffix. Every candidate is resolved, as when they were materialized.
314
+ */
315
+ private numericFirstPeriodSkip;
316
+ /**
317
+ * Rank/select over MONTHLY or YEARLY periods. A cached plan holds the first
318
+ * period's day list, a skip offset into it, per-period counts over at most
319
+ * one calendar cycle and the last selected period's day list, never a
320
+ * period's candidates.
321
+ */
322
+ private buildCalendarNumericQueryPlan;
273
323
  /**
274
324
  * Build one Gregorian recurrence year's matching epoch days, without time
275
325
  * expansion. This deliberately covers the common YEARLY shapes
@@ -277,7 +327,7 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
277
327
  */
278
328
  private generateYearlyOccurrenceDaysUtc;
279
329
  private generateYearlyOccurrenceEpochsUtc;
280
- private yearlyCandidateEvaluationCountUtc;
330
+ private yearlyCandidateEvaluationCount;
281
331
  private buildYearlyNumericQueryPlan;
282
332
  private buildNumericQueryPlan;
283
333
  private getNumericQueryPlan;
@@ -288,6 +338,8 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
288
338
  private buildPeriodQueryPlan;
289
339
  private getPeriodQueryPlan;
290
340
  private findFirstMatchingDailyStep;
341
+ /** First instant an expanded path has to build: DTSTART, or the query's lower bound once it's later. */
342
+ private firstExpandedEpochMs;
291
343
  private allUtcFastPath;
292
344
  private _allUtcFixedStepSimple;
293
345
  private _allUtcDailySimple;
@@ -507,6 +559,18 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
507
559
  /** A duration of `count` steps in this rule's frequency unit. */
508
560
  private freqDuration;
509
561
  toString(): string;
562
+ /**
563
+ * RDATE or EXDATE lines. With DATE values, a date at the start of its day is
564
+ * written as a DATE. One with a time of day, or one that was read as a
565
+ * date-time, keeps its time on a line of its own.
566
+ */
567
+ private formatDateLines;
568
+ /** An all-day rule has DATE values when its DTSTART is one: the start of its day, with no time of day. */
569
+ private hasDateValues;
570
+ /** Whether a date is the start of its day in the rule's zone, which is how a DATE value is read. */
571
+ private isStartOfDay;
572
+ /** The day of a date in the rule's zone, as a DATE value. */
573
+ private formatIcsDate;
510
574
  private formatIcsDateTime;
511
575
  private joinDates;
512
576
  /**
@@ -521,6 +585,12 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
521
585
  * callers consume the date x time product incrementally.
522
586
  */
523
587
  private generateYearlyDateCandidates;
588
+ /**
589
+ * BYDAY as a limit on a date of a YEARLY rule. An ordinal weekday counts
590
+ * within the month when BYMONTH is given and within the year otherwise,
591
+ * the same way the weekdays are generated.
592
+ */
593
+ private matchesYearlyByDay;
524
594
  private addByDayDates;
525
595
  /**
526
596
  * Helper to find the next valid value from a sorted array
package/dist/index.d.ts CHANGED
@@ -28,6 +28,13 @@ interface BaseOpts<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDat
28
28
  skip?: 'OMIT' | 'BACKWARD' | 'FORWARD';
29
29
  /** Memoize the full occurrence list computed by all() (defaults to true). */
30
30
  cache?: boolean;
31
+ /**
32
+ * The rule has DATE values, as an all-day event does: toString() writes DTSTART, RDATE and
33
+ * EXDATE with VALUE=DATE and UNTIL as a date. Set for a rule read from a DTSTART with
34
+ * VALUE=DATE, and returned by options(). It takes effect when dtstart is the start of its
35
+ * day in the rule's time zone, and does not change which occurrences the rule has.
36
+ */
37
+ allDay?: boolean;
31
38
  }
32
39
  type TemporalZonedDateTime = Temporal.ZonedDateTime;
33
40
  type TemporalPlainDate = Temporal.PlainDate;
@@ -112,6 +119,11 @@ type RRuleResolvedOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZ
112
119
  declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
113
120
  private readonly tzid;
114
121
  private readonly originalDtstart;
122
+ /**
123
+ * The instants of RDATE and EXDATE values that an all-day rule read as date-times. toString()
124
+ * keeps them so, also when they are the start of a day.
125
+ */
126
+ private readDateTimes?;
115
127
  private originalPlainDtstart?;
116
128
  private readonly opts;
117
129
  private readonly outputTemporal?;
@@ -136,6 +148,7 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
136
148
  private numericQueryPlanCache;
137
149
  private periodQueryPlanCache;
138
150
  private dtstartIsOccurrenceCache?;
151
+ private yearlyDaysNeverMatchCache?;
139
152
  private static readonly rscaleCalendarSupport;
140
153
  /**
141
154
  * Normalize a ZonedDateTime to the polyfill implementation.
@@ -175,6 +188,12 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
175
188
  private needsSortedTimeFallback;
176
189
  private createCandidateWorkBudget;
177
190
  private recordCandidateEvaluation;
191
+ /**
192
+ * Charge a fast path's dates to the budget, as the general engine charges
193
+ * each candidate. A DTSTART that includeDtstart added is not a candidate.
194
+ */
195
+ private assertFastPathBudget;
196
+ private assertCandidateBudget;
178
197
  /**
179
198
  * Visit BYHOUR x BYMINUTE x BYSECOND without allocating the Cartesian
180
199
  * product. Returning false from `visit` terminates the innermost traversal
@@ -234,6 +253,15 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
234
253
  * without incorrectly judging the rule from DTSTART's year alone.
235
254
  */
236
255
  private hasPossibleYearDayWeekNoCombination;
256
+ /**
257
+ * BYDAY and BYMONTHDAY limit the days that a YEARLY rule gets from BYYEARDAY, or from an ordinal BYDAY
258
+ * counted over the year, so they can leave no day in any year (`BYYEARDAY=1;BYMONTHDAY=2`). Gregorian
259
+ * weekdays and leap years repeat every 400 years, so scanning 400 recurrence years decides it and the
260
+ * search can stop instead of running into maxIterations. A DTSTART in another calendar (for example
261
+ * `[u-ca=hebrew]`) counts its years in that calendar, whose years do not repeat that way, so the
262
+ * shortcut is left to the Gregorian calendar.
263
+ */
264
+ private yearlyDaysNeverMatch;
237
265
  options(): RRuleResolvedOptions<TOutput>;
238
266
  private cloneOptions;
239
267
  private cloneUpdateOptions;
@@ -270,6 +298,28 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
270
298
  private buildDailyNumericQueryPlan;
271
299
  private buildWeeklyNumericQueryPlan;
272
300
  private buildMonthlyNumericQueryPlan;
301
+ /**
302
+ * A MONTHLY or YEARLY period's candidates, sorted(days x time slots) and then
303
+ * narrowed by BYSETPOS, described by its day list alone. Days and slots are
304
+ * ascending and unique, and a slot is shorter than a day, so candidate k is
305
+ * day floor(k / S) at slot k % S, and BYSETPOS keeps the ascending, distinct
306
+ * indices it names. Null when the day list breaks that order.
307
+ */
308
+ private numericPeriodShape;
309
+ private numericPeriodWall;
310
+ /**
311
+ * Index of the first of a first period's ascending candidates at or after
312
+ * DTSTART, or null when one does not resolve or the kept ones are not a
313
+ * suffix. Every candidate is resolved, as when they were materialized.
314
+ */
315
+ private numericFirstPeriodSkip;
316
+ /**
317
+ * Rank/select over MONTHLY or YEARLY periods. A cached plan holds the first
318
+ * period's day list, a skip offset into it, per-period counts over at most
319
+ * one calendar cycle and the last selected period's day list, never a
320
+ * period's candidates.
321
+ */
322
+ private buildCalendarNumericQueryPlan;
273
323
  /**
274
324
  * Build one Gregorian recurrence year's matching epoch days, without time
275
325
  * expansion. This deliberately covers the common YEARLY shapes
@@ -277,7 +327,7 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
277
327
  */
278
328
  private generateYearlyOccurrenceDaysUtc;
279
329
  private generateYearlyOccurrenceEpochsUtc;
280
- private yearlyCandidateEvaluationCountUtc;
330
+ private yearlyCandidateEvaluationCount;
281
331
  private buildYearlyNumericQueryPlan;
282
332
  private buildNumericQueryPlan;
283
333
  private getNumericQueryPlan;
@@ -288,6 +338,8 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
288
338
  private buildPeriodQueryPlan;
289
339
  private getPeriodQueryPlan;
290
340
  private findFirstMatchingDailyStep;
341
+ /** First instant an expanded path has to build: DTSTART, or the query's lower bound once it's later. */
342
+ private firstExpandedEpochMs;
291
343
  private allUtcFastPath;
292
344
  private _allUtcFixedStepSimple;
293
345
  private _allUtcDailySimple;
@@ -507,6 +559,18 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
507
559
  /** A duration of `count` steps in this rule's frequency unit. */
508
560
  private freqDuration;
509
561
  toString(): string;
562
+ /**
563
+ * RDATE or EXDATE lines. With DATE values, a date at the start of its day is
564
+ * written as a DATE. One with a time of day, or one that was read as a
565
+ * date-time, keeps its time on a line of its own.
566
+ */
567
+ private formatDateLines;
568
+ /** An all-day rule has DATE values when its DTSTART is one: the start of its day, with no time of day. */
569
+ private hasDateValues;
570
+ /** Whether a date is the start of its day in the rule's zone, which is how a DATE value is read. */
571
+ private isStartOfDay;
572
+ /** The day of a date in the rule's zone, as a DATE value. */
573
+ private formatIcsDate;
510
574
  private formatIcsDateTime;
511
575
  private joinDates;
512
576
  /**
@@ -521,6 +585,12 @@ declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = Tempora
521
585
  * callers consume the date x time product incrementally.
522
586
  */
523
587
  private generateYearlyDateCandidates;
588
+ /**
589
+ * BYDAY as a limit on a date of a YEARLY rule. An ordinal weekday counts
590
+ * within the month when BYMONTH is given and within the year otherwise,
591
+ * the same way the weekdays are generated.
592
+ */
593
+ private matchesYearlyByDay;
524
594
  private addByDayDates;
525
595
  /**
526
596
  * Helper to find the next valid value from a sorted array
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{i as e,n as t,r as n,t as r}from"./src-vjCiI_-u.js";export{r as RRuleTemporal,t as allowedFreq,n as allowedWeekdays,e as weekdayToIsoDay};
1
+ import{i as e,n as t,r as n,t as r}from"./src-IhLL05ky.js";export{r as RRuleTemporal,t as allowedFreq,n as allowedWeekdays,e as weekdayToIsoDay};