rrule-temporal 2.1.0 → 2.2.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 +52 -38
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +35 -22
- package/dist/index.d.ts +35 -22
- package/dist/index.js +1 -1
- package/dist/{src-b3FbAWaY.js → src-BY_Cxfjq.js} +37 -18
- package/dist/{src-BL9G7GR8.cjs → src-C6VoiyAb.cjs} +37 -18
- package/dist/totext.cjs +1 -1
- package/dist/totext.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,6 +114,7 @@ below. These correspond to the recurrence rule parts defined in RFC 5545:
|
|
|
114
114
|
| `maxIterations` | Safety cap when generating occurrences. |
|
|
115
115
|
| `includeDtstart` | Include `DTSTART` even if it does not match the pattern. |
|
|
116
116
|
| `strict` | Enforce RFC 5545 constraints strictly (defaults to false). |
|
|
117
|
+
| `temporal` | Optional Temporal namespace used for public output values and their inferred types. |
|
|
117
118
|
| `dtstart` | First occurrence as `Temporal.ZonedDateTime`. |
|
|
118
119
|
|
|
119
120
|
### Reusable Option Lists
|
|
@@ -324,36 +325,36 @@ warmed path reuses both that table and the immutable rule's numeric query plan.
|
|
|
324
325
|
|
|
325
326
|
### Full recurrence generation
|
|
326
327
|
|
|
327
|
-
Uncached median ops/s
|
|
328
|
-
(Node 25, polyfill backend).
|
|
329
|
-
|
|
330
|
-
[`benchmarks/README.md`](benchmarks/README.md).
|
|
328
|
+
Uncached median ops/s for `rrule-temporal` v2.1.0 on a MacBook Pro M2 Max
|
|
329
|
+
(Node 25, polyfill backend). Each result is the median of five 200 ms samples
|
|
330
|
+
after a 200 ms warmup. The three-library comparison, query methodology, and
|
|
331
|
+
cached-mode summary live in [`benchmarks/README.md`](benchmarks/README.md).
|
|
331
332
|
|
|
332
333
|
| Scenario | TZ | rrule-temporal median ops/s | rrule median ops/s | vs rrule |
|
|
333
334
|
| --- | --- | ---: | ---: | ---: |
|
|
334
|
-
| 30 daily occurrences | UTC |
|
|
335
|
-
| 30 daily occurrences | America/Chicago |
|
|
336
|
-
| Daily weekdays across many cycles | UTC |
|
|
337
|
-
| Daily weekdays across many cycles | America/Chicago |
|
|
338
|
-
| Daily time-slot expansion | UTC |
|
|
339
|
-
| Daily time-slot expansion | America/Chicago |
|
|
340
|
-
| 720 hourly occurrences | UTC |
|
|
341
|
-
| 720 hourly occurrences | America/Chicago |
|
|
342
|
-
| 1,440 minutely occurrences | UTC |
|
|
343
|
-
| 1,440 minutely occurrences | America/Chicago |
|
|
344
|
-
| 3,600 secondly occurrences | UTC |
|
|
345
|
-
| 3,600 secondly occurrences | America/Chicago |
|
|
346
|
-
| Weekly MO/WE/FR across many cycles | UTC |
|
|
347
|
-
| Weekly MO/WE/FR across many cycles | America/Chicago |
|
|
348
|
-
| Weekly day and time-slot expansion | UTC |
|
|
349
|
-
| Weekly day and time-slot expansion | America/Chicago |
|
|
350
|
-
| Monthly last weekday across 20 years | UTC | 1,
|
|
351
|
-
| Monthly last weekday across 20 years | America/Chicago |
|
|
352
|
-
| Monthly first and last weekday across 20 years | UTC |
|
|
353
|
-
| Monthly first and last weekday across 20 years | America/Chicago |
|
|
335
|
+
| 30 daily occurrences | UTC | 18,847 | 14,581 | 1.29x |
|
|
336
|
+
| 30 daily occurrences | America/Chicago | 12,796 | 328 | 39.01x |
|
|
337
|
+
| Daily weekdays across many cycles | UTC | 961 | 713 | 1.35x |
|
|
338
|
+
| Daily weekdays across many cycles | America/Chicago | 723 | 18.4 | 39.29x |
|
|
339
|
+
| Daily time-slot expansion | UTC | 488 | 1,006 | 0.49x |
|
|
340
|
+
| Daily time-slot expansion | America/Chicago | 371 | 10.7 | 34.67x |
|
|
341
|
+
| 720 hourly occurrences | UTC | 685 | 723 | 0.95x |
|
|
342
|
+
| 720 hourly occurrences | America/Chicago | 491 | 13.2 | 37.20x |
|
|
343
|
+
| 1,440 minutely occurrences | UTC | 326 | 332 | 0.98x |
|
|
344
|
+
| 1,440 minutely occurrences | America/Chicago | 245 | 6.8 | 36.03x |
|
|
345
|
+
| 3,600 secondly occurrences | UTC | 121 | 130 | 0.93x |
|
|
346
|
+
| 3,600 secondly occurrences | America/Chicago | 101 | 2.8 | 36.07x |
|
|
347
|
+
| Weekly MO/WE/FR across many cycles | UTC | 538 | 1,126 | 0.48x |
|
|
348
|
+
| Weekly MO/WE/FR across many cycles | America/Chicago | 418 | 13.8 | 30.29x |
|
|
349
|
+
| Weekly day and time-slot expansion | UTC | 426 | 1,197 | 0.36x |
|
|
350
|
+
| Weekly day and time-slot expansion | America/Chicago | 343 | 11.7 | 29.32x |
|
|
351
|
+
| Monthly last weekday across 20 years | UTC | 1,114 | 1,146 | 0.97x |
|
|
352
|
+
| Monthly last weekday across 20 years | America/Chicago | 921 | 43.5 | 21.17x |
|
|
353
|
+
| Monthly first and last weekday across 20 years | UTC | 664 | 1,287 | 0.52x |
|
|
354
|
+
| Monthly first and last weekday across 20 years | America/Chicago | 553 | 23.4 | 23.63x |
|
|
354
355
|
|
|
355
356
|
Time-zone-aware rules iterate through an epoch-integer engine with a cached
|
|
356
|
-
per-zone offset table, so named-zone scenarios now run
|
|
357
|
+
per-zone offset table, so named-zone scenarios now run 21–39x faster than
|
|
357
358
|
`rrule` and within a small factor of their UTC equivalents. On UTC the two
|
|
358
359
|
libraries are comparable on Node 25 (`rrule` stays ahead in several expanded
|
|
359
360
|
and weekly/monthly scenarios where occurrence materialization dominates); on
|
|
@@ -428,30 +429,43 @@ Inputs are accepted from **any** Temporal implementation: `dtstart`, `until`,
|
|
|
428
429
|
objects from `@js-temporal/polyfill`, `temporal-polyfill`, or native Temporal
|
|
429
430
|
interchangeably.
|
|
430
431
|
|
|
431
|
-
|
|
432
|
-
when available, the bundled polyfill otherwise)
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
432
|
+
By default, returned occurrences come from the library's active implementation
|
|
433
|
+
(native when available, the bundled polyfill otherwise) and use
|
|
434
|
+
implementation-neutral `temporal-spec` types. To return instances from your
|
|
435
|
+
application's Temporal implementation with its exact inferred TypeScript
|
|
436
|
+
types, pass the optional `temporal` namespace:
|
|
436
437
|
|
|
437
438
|
```ts
|
|
438
|
-
|
|
439
|
-
import { Temporal as AppTemporal } from "temporal-polyfill";
|
|
440
|
-
|
|
439
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
441
440
|
import { RRuleTemporal } from "rrule-temporal";
|
|
442
441
|
|
|
443
|
-
/** Weekly rule that fires 4 times starting 5 May 2025, 10 AM America/Chicago. */
|
|
444
442
|
const rule = new RRuleTemporal({
|
|
443
|
+
temporal: Temporal,
|
|
445
444
|
freq: "WEEKLY",
|
|
446
445
|
count: 4,
|
|
447
|
-
dtstart:
|
|
448
|
-
"
|
|
446
|
+
dtstart: Temporal.ZonedDateTime.from(
|
|
447
|
+
"2030-05-05T10:00[America/Chicago]"
|
|
449
448
|
),
|
|
450
449
|
});
|
|
451
450
|
|
|
452
|
-
const
|
|
451
|
+
const occurrence = rule.next(); // Temporal.ZonedDateTime | null
|
|
452
|
+
const date = occurrence?.toPlainDate(); // Temporal.PlainDate | undefined
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
The selected implementation is used for values returned by `all()`,
|
|
456
|
+
`between()`, `next()`, `previous()`, iterator callbacks, `options()`, and
|
|
457
|
+
rules created with `with()`. Recurrence calculations still use the optimized
|
|
458
|
+
active implementation internally. Omitting `temporal` preserves the default
|
|
459
|
+
behavior.
|
|
460
|
+
|
|
461
|
+
Returned values from different implementations are fully spec-shaped but do
|
|
462
|
+
not satisfy `instanceof` checks against each other's classes. If a rule was
|
|
463
|
+
created without `temporal`, you can still re-hydrate individual results:
|
|
464
|
+
|
|
465
|
+
```ts
|
|
466
|
+
import { Temporal as AppTemporal } from "@js-temporal/polyfill";
|
|
453
467
|
|
|
454
|
-
|
|
468
|
+
const rawOccurrences = existingRule.all();
|
|
455
469
|
const appOccurrences = rawOccurrences.map((zdt) =>
|
|
456
470
|
AppTemporal.ZonedDateTime.from(zdt.toString())
|
|
457
471
|
);
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_src = require("./src-
|
|
2
|
+
const require_src = require("./src-C6VoiyAb.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
|
@@ -9,7 +9,9 @@ declare const weekdayToIsoDay: Record<Weekday, number>;
|
|
|
9
9
|
/**
|
|
10
10
|
* Shared options for all rule constructors.
|
|
11
11
|
*/
|
|
12
|
-
interface BaseOpts {
|
|
12
|
+
interface BaseOpts<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
|
|
13
|
+
/** Temporal implementation used to construct public occurrence values. */
|
|
14
|
+
temporal?: TemporalImplementation<TOutput>;
|
|
13
15
|
/** Time zone identifier as defined in RFC 5545 §3.2.19. */
|
|
14
16
|
tzid?: string;
|
|
15
17
|
/** Safety cap when generating occurrences. */
|
|
@@ -34,13 +36,23 @@ interface TemporalZonedDateTimeInput {
|
|
|
34
36
|
interface TemporalPlainDateInput {
|
|
35
37
|
toString(): string;
|
|
36
38
|
}
|
|
37
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The subset of a Temporal namespace needed to construct public occurrence
|
|
41
|
+
* values. Supplying an implementation makes output values and their inferred
|
|
42
|
+
* TypeScript types come from that implementation.
|
|
43
|
+
*/
|
|
44
|
+
interface TemporalImplementation<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
|
|
45
|
+
readonly ZonedDateTime: {
|
|
46
|
+
from(value: string): TOutput;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
type RRuleTemporalIterator<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> = (date: TOutput, i: number) => boolean;
|
|
38
50
|
type DateFilter = Date | TemporalZonedDateTimeInput;
|
|
39
51
|
/**
|
|
40
52
|
* Manual rule definition following the recurrence rule parts defined in
|
|
41
53
|
* RFC 5545 §3.3.10.
|
|
42
54
|
*/
|
|
43
|
-
interface ManualOptions extends BaseOpts {
|
|
55
|
+
interface ManualOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> extends BaseOpts<TOutput> {
|
|
44
56
|
/** FREQ: recurrence frequency */
|
|
45
57
|
freq: Freq;
|
|
46
58
|
/** INTERVAL between each occurrence of {@link freq} */
|
|
@@ -76,7 +88,7 @@ interface ManualOptions extends BaseOpts {
|
|
|
76
88
|
/** DTSTART: first occurrence */
|
|
77
89
|
dtstart: TemporalZonedDateTimeInput;
|
|
78
90
|
}
|
|
79
|
-
interface IcsOptions extends BaseOpts {
|
|
91
|
+
interface IcsOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> extends BaseOpts<TOutput> {
|
|
80
92
|
rruleString: string;
|
|
81
93
|
dtstart?: TemporalZonedDateTimeInput;
|
|
82
94
|
/** COUNT: total number of occurrences, used when missing from rruleString */
|
|
@@ -88,17 +100,18 @@ interface IcsOptions extends BaseOpts {
|
|
|
88
100
|
/** EXDATE: exception dates to exclude */
|
|
89
101
|
exDate?: TemporalZonedDateTimeInput[];
|
|
90
102
|
}
|
|
91
|
-
type RRuleOptions = ManualOptions | IcsOptions
|
|
92
|
-
type RRuleResolvedOptions = Omit<ManualOptions
|
|
93
|
-
dtstart:
|
|
94
|
-
until?:
|
|
95
|
-
rDate?:
|
|
96
|
-
exDate?:
|
|
103
|
+
type RRuleOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> = ManualOptions<TOutput> | IcsOptions<TOutput>;
|
|
104
|
+
type RRuleResolvedOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> = Omit<ManualOptions<TOutput>, 'dtstart' | 'until' | 'rDate' | 'exDate'> & {
|
|
105
|
+
dtstart: TOutput;
|
|
106
|
+
until?: TOutput;
|
|
107
|
+
rDate?: TOutput[];
|
|
108
|
+
exDate?: TOutput[];
|
|
97
109
|
};
|
|
98
|
-
declare class RRuleTemporal {
|
|
110
|
+
declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
|
|
99
111
|
private readonly tzid;
|
|
100
112
|
private readonly originalDtstart;
|
|
101
113
|
private readonly opts;
|
|
114
|
+
private readonly outputTemporal?;
|
|
102
115
|
private readonly maxIterations;
|
|
103
116
|
private readonly includeDtstart;
|
|
104
117
|
private readonly parsedByDayTokens?;
|
|
@@ -120,10 +133,10 @@ declare class RRuleTemporal {
|
|
|
120
133
|
* This prevents type mismatches when mixing native and polyfill Temporal objects.
|
|
121
134
|
*/
|
|
122
135
|
private static normalizeToPolyfill;
|
|
123
|
-
private
|
|
124
|
-
private
|
|
125
|
-
private
|
|
126
|
-
constructor(params: RRuleOptions);
|
|
136
|
+
private toInternalIterator;
|
|
137
|
+
private toPublicDate;
|
|
138
|
+
private toPublicDates;
|
|
139
|
+
constructor(params: RRuleOptions<TOutput>);
|
|
127
140
|
private buildParsedByDayTokens;
|
|
128
141
|
private buildByDayIsoDays;
|
|
129
142
|
private sanitizeNumericArray;
|
|
@@ -150,7 +163,7 @@ declare class RRuleTemporal {
|
|
|
150
163
|
private matchesByYearDay;
|
|
151
164
|
private getIsoWeekInfo;
|
|
152
165
|
private matchesByWeekNo;
|
|
153
|
-
options(): RRuleResolvedOptions
|
|
166
|
+
options(): RRuleResolvedOptions<TOutput>;
|
|
154
167
|
private cloneOptions;
|
|
155
168
|
private cloneUpdateOptions;
|
|
156
169
|
/**
|
|
@@ -161,7 +174,7 @@ declare class RRuleTemporal {
|
|
|
161
174
|
* const updated = rule.with({byMonthDay: [3]});
|
|
162
175
|
* ```
|
|
163
176
|
*/
|
|
164
|
-
with(updates: Partial<ManualOptions
|
|
177
|
+
with(updates: Partial<ManualOptions<TOutput>>): RRuleTemporal<TOutput>;
|
|
165
178
|
private addDtstartIfNeeded;
|
|
166
179
|
private canUseUtcLinearFastPath;
|
|
167
180
|
private canUseUtcWeeklyFastPath;
|
|
@@ -238,7 +251,7 @@ declare class RRuleTemporal {
|
|
|
238
251
|
* @param iterator - An optional callback iterator function that can be used to filter or modify the occurrences.
|
|
239
252
|
* @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule.
|
|
240
253
|
*/
|
|
241
|
-
all(iterator?: RRuleTemporalIterator):
|
|
254
|
+
all(iterator?: RRuleTemporalIterator<TOutput>): TOutput[];
|
|
242
255
|
private allInternal;
|
|
243
256
|
/**
|
|
244
257
|
* RFC 7529: RSCALE present, simple monthly iteration with SKIP behavior.
|
|
@@ -294,7 +307,7 @@ declare class RRuleTemporal {
|
|
|
294
307
|
* @param inc - Optional boolean flag to include the start and end dates in the results.
|
|
295
308
|
* @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule within the specified time window.
|
|
296
309
|
*/
|
|
297
|
-
between(after: DateFilter, before: DateFilter, inc?: boolean):
|
|
310
|
+
between(after: DateFilter, before: DateFilter, inc?: boolean): TOutput[];
|
|
298
311
|
/**
|
|
299
312
|
* Compute a rule-phase-aligned DTSTART at or just before the given window
|
|
300
313
|
* start, jumping forward from the original DTSTART in whole multiples of
|
|
@@ -319,7 +332,7 @@ declare class RRuleTemporal {
|
|
|
319
332
|
* @param inc - Optional boolean flag to include occurrences on the start date.
|
|
320
333
|
* @returns The next occurrence of the rule after the specified date or null if no occurrences are found.
|
|
321
334
|
*/
|
|
322
|
-
next(after?: DateFilter, inc?: boolean):
|
|
335
|
+
next(after?: DateFilter, inc?: boolean): TOutput | null;
|
|
323
336
|
/**
|
|
324
337
|
* Build a temporary rule identical to this one but starting at the
|
|
325
338
|
* phase-aligned DTSTART for the given window start. The synthetic DTSTART
|
|
@@ -332,7 +345,7 @@ declare class RRuleTemporal {
|
|
|
332
345
|
* @param inc - Optional boolean flag to include occurrences on the end date.
|
|
333
346
|
* @returns The previous occurrence of the rule before the specified date or null if no occurrences are found.
|
|
334
347
|
*/
|
|
335
|
-
previous(before?: DateFilter, inc?: boolean):
|
|
348
|
+
previous(before?: DateFilter, inc?: boolean): TOutput | null;
|
|
336
349
|
/** A duration of `count` steps in this rule's frequency unit. */
|
|
337
350
|
private freqDuration;
|
|
338
351
|
toString(): string;
|
|
@@ -389,4 +402,4 @@ declare class RRuleTemporal {
|
|
|
389
402
|
private _allRscaleNonGregorian;
|
|
390
403
|
}
|
|
391
404
|
//#endregion
|
|
392
|
-
export { DateFilter, Freq, RRuleOptions, RRuleResolvedOptions, RRuleTemporal, RRuleTemporalIterator, TemporalPlainDate, TemporalPlainDateInput, TemporalZonedDateTime, TemporalZonedDateTimeInput, Weekday, allowedFreq, allowedWeekdays, weekdayToIsoDay };
|
|
405
|
+
export { DateFilter, Freq, RRuleOptions, RRuleResolvedOptions, RRuleTemporal, RRuleTemporalIterator, TemporalImplementation, TemporalPlainDate, TemporalPlainDateInput, TemporalZonedDateTime, TemporalZonedDateTimeInput, Weekday, allowedFreq, allowedWeekdays, weekdayToIsoDay };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ declare const weekdayToIsoDay: Record<Weekday, number>;
|
|
|
9
9
|
/**
|
|
10
10
|
* Shared options for all rule constructors.
|
|
11
11
|
*/
|
|
12
|
-
interface BaseOpts {
|
|
12
|
+
interface BaseOpts<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
|
|
13
|
+
/** Temporal implementation used to construct public occurrence values. */
|
|
14
|
+
temporal?: TemporalImplementation<TOutput>;
|
|
13
15
|
/** Time zone identifier as defined in RFC 5545 §3.2.19. */
|
|
14
16
|
tzid?: string;
|
|
15
17
|
/** Safety cap when generating occurrences. */
|
|
@@ -34,13 +36,23 @@ interface TemporalZonedDateTimeInput {
|
|
|
34
36
|
interface TemporalPlainDateInput {
|
|
35
37
|
toString(): string;
|
|
36
38
|
}
|
|
37
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The subset of a Temporal namespace needed to construct public occurrence
|
|
41
|
+
* values. Supplying an implementation makes output values and their inferred
|
|
42
|
+
* TypeScript types come from that implementation.
|
|
43
|
+
*/
|
|
44
|
+
interface TemporalImplementation<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
|
|
45
|
+
readonly ZonedDateTime: {
|
|
46
|
+
from(value: string): TOutput;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
type RRuleTemporalIterator<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> = (date: TOutput, i: number) => boolean;
|
|
38
50
|
type DateFilter = Date | TemporalZonedDateTimeInput;
|
|
39
51
|
/**
|
|
40
52
|
* Manual rule definition following the recurrence rule parts defined in
|
|
41
53
|
* RFC 5545 §3.3.10.
|
|
42
54
|
*/
|
|
43
|
-
interface ManualOptions extends BaseOpts {
|
|
55
|
+
interface ManualOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> extends BaseOpts<TOutput> {
|
|
44
56
|
/** FREQ: recurrence frequency */
|
|
45
57
|
freq: Freq;
|
|
46
58
|
/** INTERVAL between each occurrence of {@link freq} */
|
|
@@ -76,7 +88,7 @@ interface ManualOptions extends BaseOpts {
|
|
|
76
88
|
/** DTSTART: first occurrence */
|
|
77
89
|
dtstart: TemporalZonedDateTimeInput;
|
|
78
90
|
}
|
|
79
|
-
interface IcsOptions extends BaseOpts {
|
|
91
|
+
interface IcsOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> extends BaseOpts<TOutput> {
|
|
80
92
|
rruleString: string;
|
|
81
93
|
dtstart?: TemporalZonedDateTimeInput;
|
|
82
94
|
/** COUNT: total number of occurrences, used when missing from rruleString */
|
|
@@ -88,17 +100,18 @@ interface IcsOptions extends BaseOpts {
|
|
|
88
100
|
/** EXDATE: exception dates to exclude */
|
|
89
101
|
exDate?: TemporalZonedDateTimeInput[];
|
|
90
102
|
}
|
|
91
|
-
type RRuleOptions = ManualOptions | IcsOptions
|
|
92
|
-
type RRuleResolvedOptions = Omit<ManualOptions
|
|
93
|
-
dtstart:
|
|
94
|
-
until?:
|
|
95
|
-
rDate?:
|
|
96
|
-
exDate?:
|
|
103
|
+
type RRuleOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> = ManualOptions<TOutput> | IcsOptions<TOutput>;
|
|
104
|
+
type RRuleResolvedOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> = Omit<ManualOptions<TOutput>, 'dtstart' | 'until' | 'rDate' | 'exDate'> & {
|
|
105
|
+
dtstart: TOutput;
|
|
106
|
+
until?: TOutput;
|
|
107
|
+
rDate?: TOutput[];
|
|
108
|
+
exDate?: TOutput[];
|
|
97
109
|
};
|
|
98
|
-
declare class RRuleTemporal {
|
|
110
|
+
declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
|
|
99
111
|
private readonly tzid;
|
|
100
112
|
private readonly originalDtstart;
|
|
101
113
|
private readonly opts;
|
|
114
|
+
private readonly outputTemporal?;
|
|
102
115
|
private readonly maxIterations;
|
|
103
116
|
private readonly includeDtstart;
|
|
104
117
|
private readonly parsedByDayTokens?;
|
|
@@ -120,10 +133,10 @@ declare class RRuleTemporal {
|
|
|
120
133
|
* This prevents type mismatches when mixing native and polyfill Temporal objects.
|
|
121
134
|
*/
|
|
122
135
|
private static normalizeToPolyfill;
|
|
123
|
-
private
|
|
124
|
-
private
|
|
125
|
-
private
|
|
126
|
-
constructor(params: RRuleOptions);
|
|
136
|
+
private toInternalIterator;
|
|
137
|
+
private toPublicDate;
|
|
138
|
+
private toPublicDates;
|
|
139
|
+
constructor(params: RRuleOptions<TOutput>);
|
|
127
140
|
private buildParsedByDayTokens;
|
|
128
141
|
private buildByDayIsoDays;
|
|
129
142
|
private sanitizeNumericArray;
|
|
@@ -150,7 +163,7 @@ declare class RRuleTemporal {
|
|
|
150
163
|
private matchesByYearDay;
|
|
151
164
|
private getIsoWeekInfo;
|
|
152
165
|
private matchesByWeekNo;
|
|
153
|
-
options(): RRuleResolvedOptions
|
|
166
|
+
options(): RRuleResolvedOptions<TOutput>;
|
|
154
167
|
private cloneOptions;
|
|
155
168
|
private cloneUpdateOptions;
|
|
156
169
|
/**
|
|
@@ -161,7 +174,7 @@ declare class RRuleTemporal {
|
|
|
161
174
|
* const updated = rule.with({byMonthDay: [3]});
|
|
162
175
|
* ```
|
|
163
176
|
*/
|
|
164
|
-
with(updates: Partial<ManualOptions
|
|
177
|
+
with(updates: Partial<ManualOptions<TOutput>>): RRuleTemporal<TOutput>;
|
|
165
178
|
private addDtstartIfNeeded;
|
|
166
179
|
private canUseUtcLinearFastPath;
|
|
167
180
|
private canUseUtcWeeklyFastPath;
|
|
@@ -238,7 +251,7 @@ declare class RRuleTemporal {
|
|
|
238
251
|
* @param iterator - An optional callback iterator function that can be used to filter or modify the occurrences.
|
|
239
252
|
* @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule.
|
|
240
253
|
*/
|
|
241
|
-
all(iterator?: RRuleTemporalIterator):
|
|
254
|
+
all(iterator?: RRuleTemporalIterator<TOutput>): TOutput[];
|
|
242
255
|
private allInternal;
|
|
243
256
|
/**
|
|
244
257
|
* RFC 7529: RSCALE present, simple monthly iteration with SKIP behavior.
|
|
@@ -294,7 +307,7 @@ declare class RRuleTemporal {
|
|
|
294
307
|
* @param inc - Optional boolean flag to include the start and end dates in the results.
|
|
295
308
|
* @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule within the specified time window.
|
|
296
309
|
*/
|
|
297
|
-
between(after: DateFilter, before: DateFilter, inc?: boolean):
|
|
310
|
+
between(after: DateFilter, before: DateFilter, inc?: boolean): TOutput[];
|
|
298
311
|
/**
|
|
299
312
|
* Compute a rule-phase-aligned DTSTART at or just before the given window
|
|
300
313
|
* start, jumping forward from the original DTSTART in whole multiples of
|
|
@@ -319,7 +332,7 @@ declare class RRuleTemporal {
|
|
|
319
332
|
* @param inc - Optional boolean flag to include occurrences on the start date.
|
|
320
333
|
* @returns The next occurrence of the rule after the specified date or null if no occurrences are found.
|
|
321
334
|
*/
|
|
322
|
-
next(after?: DateFilter, inc?: boolean):
|
|
335
|
+
next(after?: DateFilter, inc?: boolean): TOutput | null;
|
|
323
336
|
/**
|
|
324
337
|
* Build a temporary rule identical to this one but starting at the
|
|
325
338
|
* phase-aligned DTSTART for the given window start. The synthetic DTSTART
|
|
@@ -332,7 +345,7 @@ declare class RRuleTemporal {
|
|
|
332
345
|
* @param inc - Optional boolean flag to include occurrences on the end date.
|
|
333
346
|
* @returns The previous occurrence of the rule before the specified date or null if no occurrences are found.
|
|
334
347
|
*/
|
|
335
|
-
previous(before?: DateFilter, inc?: boolean):
|
|
348
|
+
previous(before?: DateFilter, inc?: boolean): TOutput | null;
|
|
336
349
|
/** A duration of `count` steps in this rule's frequency unit. */
|
|
337
350
|
private freqDuration;
|
|
338
351
|
toString(): string;
|
|
@@ -389,4 +402,4 @@ declare class RRuleTemporal {
|
|
|
389
402
|
private _allRscaleNonGregorian;
|
|
390
403
|
}
|
|
391
404
|
//#endregion
|
|
392
|
-
export { DateFilter, Freq, RRuleOptions, RRuleResolvedOptions, RRuleTemporal, RRuleTemporalIterator, TemporalPlainDate, TemporalPlainDateInput, TemporalZonedDateTime, TemporalZonedDateTimeInput, Weekday, allowedFreq, allowedWeekdays, weekdayToIsoDay };
|
|
405
|
+
export { DateFilter, Freq, RRuleOptions, RRuleResolvedOptions, RRuleTemporal, RRuleTemporalIterator, TemporalImplementation, TemporalPlainDate, TemporalPlainDateInput, TemporalZonedDateTime, TemporalZonedDateTimeInput, Weekday, allowedFreq, allowedWeekdays, weekdayToIsoDay };
|
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-
|
|
1
|
+
import { i as weekdayToIsoDay, n as allowedFreq, r as allowedWeekdays, t as RRuleTemporal } from "./src-BY_Cxfjq.js";
|
|
2
2
|
export { RRuleTemporal, allowedFreq, allowedWeekdays, weekdayToIsoDay };
|
|
@@ -4951,16 +4951,22 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
4951
4951
|
static normalizeToPolyfill(zdt) {
|
|
4952
4952
|
return normalizeZonedDateTime(zdt, "Date");
|
|
4953
4953
|
}
|
|
4954
|
-
|
|
4955
|
-
return
|
|
4954
|
+
toInternalIterator(iterator) {
|
|
4955
|
+
if (!iterator) return void 0;
|
|
4956
|
+
return (date, i) => iterator(this.toPublicDate(date), i);
|
|
4956
4957
|
}
|
|
4957
|
-
|
|
4958
|
-
return
|
|
4958
|
+
toPublicDate(date) {
|
|
4959
|
+
if (!date) return null;
|
|
4960
|
+
const outputConstructor = this.outputTemporal?.ZonedDateTime;
|
|
4961
|
+
if (!outputConstructor || outputConstructor === Temporal.ZonedDateTime) return date;
|
|
4962
|
+
return outputConstructor.from(date.toString());
|
|
4959
4963
|
}
|
|
4960
|
-
|
|
4961
|
-
return dates;
|
|
4964
|
+
toPublicDates(dates) {
|
|
4965
|
+
if (!this.outputTemporal || this.outputTemporal.ZonedDateTime === Temporal.ZonedDateTime) return dates;
|
|
4966
|
+
return dates.map((date) => this.outputTemporal.ZonedDateTime.from(date.toString()));
|
|
4962
4967
|
}
|
|
4963
4968
|
constructor(params) {
|
|
4969
|
+
this.outputTemporal = params.temporal;
|
|
4964
4970
|
let manual;
|
|
4965
4971
|
if (isIcsOpts(params)) {
|
|
4966
4972
|
const parsed = parseRRuleString(params.rruleString, params.tzid, params.dtstart, params.strict ?? false);
|
|
@@ -4979,6 +4985,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
4979
4985
|
maxIterations: params.maxIterations,
|
|
4980
4986
|
includeDtstart: params.includeDtstart,
|
|
4981
4987
|
cache: params.cache,
|
|
4988
|
+
temporal: params.temporal,
|
|
4982
4989
|
tzid: this.tzid
|
|
4983
4990
|
};
|
|
4984
4991
|
} else {
|
|
@@ -5480,7 +5487,15 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
5480
5487
|
});
|
|
5481
5488
|
}
|
|
5482
5489
|
options() {
|
|
5483
|
-
|
|
5490
|
+
const { dtstart, until, rDate, exDate, temporal: _temporal, ...rest } = this.cloneOptions();
|
|
5491
|
+
return {
|
|
5492
|
+
...rest,
|
|
5493
|
+
...this.outputTemporal ? { temporal: this.outputTemporal } : {},
|
|
5494
|
+
dtstart: this.toPublicDate(dtstart),
|
|
5495
|
+
until: until ? this.toPublicDate(until) : void 0,
|
|
5496
|
+
rDate: rDate ? this.toPublicDates(rDate) : void 0,
|
|
5497
|
+
exDate: exDate ? this.toPublicDates(exDate) : void 0
|
|
5498
|
+
};
|
|
5484
5499
|
}
|
|
5485
5500
|
cloneOptions() {
|
|
5486
5501
|
const { byHour, byMinute, bySecond, byDay, byMonth, byMonthDay, byYearDay, byWeekNo, bySetPos, rDate, exDate, ...rest } = this.opts;
|
|
@@ -6874,9 +6889,9 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6874
6889
|
all(iterator) {
|
|
6875
6890
|
if (!iterator && this.opts.cache !== false) {
|
|
6876
6891
|
if (!this.allResultCache) this.allResultCache = this.allInternal();
|
|
6877
|
-
return
|
|
6892
|
+
return this.toPublicDates(this.allResultCache.slice());
|
|
6878
6893
|
}
|
|
6879
|
-
return
|
|
6894
|
+
return this.toPublicDates(this.allInternal(this.toInternalIterator(iterator)));
|
|
6880
6895
|
}
|
|
6881
6896
|
allInternal(iterator) {
|
|
6882
6897
|
if (this.opts.rscale && [
|
|
@@ -7185,14 +7200,17 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7185
7200
|
const startInst = after instanceof Date ? Temporal.Instant.from(after.toISOString()) : normalizeZonedDateTime(after, "after").toInstant();
|
|
7186
7201
|
const endInst = before instanceof Date ? Temporal.Instant.from(before.toISOString()) : normalizeZonedDateTime(before, "before").toInstant();
|
|
7187
7202
|
const numericResult = this.tryNumericBetween(startInst.epochNanoseconds, endInst.epochNanoseconds, inc);
|
|
7188
|
-
if (numericResult.handled) return
|
|
7203
|
+
if (numericResult.handled) return this.toPublicDates(numericResult.value);
|
|
7189
7204
|
const startZdt = Temporal.Instant.from(startInst).toZonedDateTimeISO(this.tzid);
|
|
7190
7205
|
const beforeZdt = Temporal.Instant.from(endInst).toZonedDateTimeISO(this.tzid);
|
|
7191
7206
|
const tempOpts = { ...this.opts };
|
|
7192
7207
|
if (!tempOpts.until || Temporal.ZonedDateTime.compare(beforeZdt, tempOpts.until) < 0) tempOpts.until = beforeZdt;
|
|
7193
7208
|
if (tempOpts.count === void 0) tempOpts.dtstart = this.jumpAlignedDtstart(startZdt);
|
|
7194
|
-
const allDates = new RRuleTemporal(
|
|
7195
|
-
|
|
7209
|
+
const allDates = new RRuleTemporal({
|
|
7210
|
+
...tempOpts,
|
|
7211
|
+
temporal: this.outputTemporal
|
|
7212
|
+
}).allInternal();
|
|
7213
|
+
return this.toPublicDates(allDates.filter((date) => {
|
|
7196
7214
|
const inst = date.toInstant();
|
|
7197
7215
|
const afterStart = inc ? Temporal.Instant.compare(inst, startInst) >= 0 : Temporal.Instant.compare(inst, startInst) > 0;
|
|
7198
7216
|
const beforeEnd = inc ? Temporal.Instant.compare(inst, endInst) <= 0 : Temporal.Instant.compare(inst, endInst) < 0;
|
|
@@ -7298,7 +7316,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7298
7316
|
next(after = /* @__PURE__ */ new Date(), inc = false) {
|
|
7299
7317
|
const afterInst = after instanceof Date ? Temporal.Instant.from(after.toISOString()) : normalizeZonedDateTime(after, "after").toInstant();
|
|
7300
7318
|
const numericResult = this.tryNumericNext(afterInst.epochNanoseconds, inc);
|
|
7301
|
-
if (numericResult.handled) return
|
|
7319
|
+
if (numericResult.handled) return this.toPublicDate(numericResult.value);
|
|
7302
7320
|
let result = null;
|
|
7303
7321
|
const scanFrom = (rule) => {
|
|
7304
7322
|
rule.allInternal((occ) => {
|
|
@@ -7312,7 +7330,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7312
7330
|
};
|
|
7313
7331
|
if (this.opts.count !== void 0) scanFrom(this);
|
|
7314
7332
|
else scanFrom(this.ruleFromAlignedDtstart(afterInst.toZonedDateTimeISO(this.tzid)));
|
|
7315
|
-
return
|
|
7333
|
+
return this.toPublicDate(result);
|
|
7316
7334
|
}
|
|
7317
7335
|
/**
|
|
7318
7336
|
* Build a temporary rule identical to this one but starting at the
|
|
@@ -7324,6 +7342,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7324
7342
|
if (aligned.epochNanoseconds === this.originalDtstart.epochNanoseconds) return this;
|
|
7325
7343
|
return new RRuleTemporal({
|
|
7326
7344
|
...this.opts,
|
|
7345
|
+
temporal: this.outputTemporal,
|
|
7327
7346
|
dtstart: aligned,
|
|
7328
7347
|
includeDtstart: false
|
|
7329
7348
|
});
|
|
@@ -7337,7 +7356,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7337
7356
|
previous(before = /* @__PURE__ */ new Date(), inc = false) {
|
|
7338
7357
|
const beforeInst = before instanceof Date ? Temporal.Instant.from(before.toISOString()) : normalizeZonedDateTime(before, "before").toInstant();
|
|
7339
7358
|
const numericResult = this.tryNumericPrevious(beforeInst.epochNanoseconds, inc);
|
|
7340
|
-
if (numericResult.handled) return
|
|
7359
|
+
if (numericResult.handled) return this.toPublicDate(numericResult.value);
|
|
7341
7360
|
const scanFrom = (rule) => {
|
|
7342
7361
|
let prev = null;
|
|
7343
7362
|
rule.allInternal((occ) => {
|
|
@@ -7348,7 +7367,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7348
7367
|
});
|
|
7349
7368
|
return prev;
|
|
7350
7369
|
};
|
|
7351
|
-
if (this.opts.count !== void 0) return
|
|
7370
|
+
if (this.opts.count !== void 0) return this.toPublicDate(scanFrom(this));
|
|
7352
7371
|
const beforeZdt = beforeInst.toZonedDateTimeISO(this.tzid);
|
|
7353
7372
|
const anchor = this.opts.until && Temporal.ZonedDateTime.compare(this.opts.until, beforeZdt) < 0 ? this.opts.until : beforeZdt;
|
|
7354
7373
|
const interval = this.opts.interval ?? 1;
|
|
@@ -7356,9 +7375,9 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7356
7375
|
const target = backoff === 0 ? anchor : anchor.subtract(this.freqDuration(interval * 4 ** backoff));
|
|
7357
7376
|
const rule = this.ruleFromAlignedDtstart(target);
|
|
7358
7377
|
const prev = scanFrom(rule);
|
|
7359
|
-
if (prev || rule === this) return
|
|
7378
|
+
if (prev || rule === this) return this.toPublicDate(prev);
|
|
7360
7379
|
}
|
|
7361
|
-
return
|
|
7380
|
+
return this.toPublicDate(scanFrom(this));
|
|
7362
7381
|
}
|
|
7363
7382
|
/** A duration of `count` steps in this rule's frequency unit. */
|
|
7364
7383
|
freqDuration(count) {
|
|
@@ -4951,16 +4951,22 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
4951
4951
|
static normalizeToPolyfill(zdt) {
|
|
4952
4952
|
return normalizeZonedDateTime(zdt, "Date");
|
|
4953
4953
|
}
|
|
4954
|
-
|
|
4955
|
-
return
|
|
4954
|
+
toInternalIterator(iterator) {
|
|
4955
|
+
if (!iterator) return void 0;
|
|
4956
|
+
return (date, i) => iterator(this.toPublicDate(date), i);
|
|
4956
4957
|
}
|
|
4957
|
-
|
|
4958
|
-
return
|
|
4958
|
+
toPublicDate(date) {
|
|
4959
|
+
if (!date) return null;
|
|
4960
|
+
const outputConstructor = this.outputTemporal?.ZonedDateTime;
|
|
4961
|
+
if (!outputConstructor || outputConstructor === Temporal.ZonedDateTime) return date;
|
|
4962
|
+
return outputConstructor.from(date.toString());
|
|
4959
4963
|
}
|
|
4960
|
-
|
|
4961
|
-
return dates;
|
|
4964
|
+
toPublicDates(dates) {
|
|
4965
|
+
if (!this.outputTemporal || this.outputTemporal.ZonedDateTime === Temporal.ZonedDateTime) return dates;
|
|
4966
|
+
return dates.map((date) => this.outputTemporal.ZonedDateTime.from(date.toString()));
|
|
4962
4967
|
}
|
|
4963
4968
|
constructor(params) {
|
|
4969
|
+
this.outputTemporal = params.temporal;
|
|
4964
4970
|
let manual;
|
|
4965
4971
|
if (isIcsOpts(params)) {
|
|
4966
4972
|
const parsed = parseRRuleString(params.rruleString, params.tzid, params.dtstart, params.strict ?? false);
|
|
@@ -4979,6 +4985,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
4979
4985
|
maxIterations: params.maxIterations,
|
|
4980
4986
|
includeDtstart: params.includeDtstart,
|
|
4981
4987
|
cache: params.cache,
|
|
4988
|
+
temporal: params.temporal,
|
|
4982
4989
|
tzid: this.tzid
|
|
4983
4990
|
};
|
|
4984
4991
|
} else {
|
|
@@ -5480,7 +5487,15 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
5480
5487
|
});
|
|
5481
5488
|
}
|
|
5482
5489
|
options() {
|
|
5483
|
-
|
|
5490
|
+
const { dtstart, until, rDate, exDate, temporal: _temporal, ...rest } = this.cloneOptions();
|
|
5491
|
+
return {
|
|
5492
|
+
...rest,
|
|
5493
|
+
...this.outputTemporal ? { temporal: this.outputTemporal } : {},
|
|
5494
|
+
dtstart: this.toPublicDate(dtstart),
|
|
5495
|
+
until: until ? this.toPublicDate(until) : void 0,
|
|
5496
|
+
rDate: rDate ? this.toPublicDates(rDate) : void 0,
|
|
5497
|
+
exDate: exDate ? this.toPublicDates(exDate) : void 0
|
|
5498
|
+
};
|
|
5484
5499
|
}
|
|
5485
5500
|
cloneOptions() {
|
|
5486
5501
|
const { byHour, byMinute, bySecond, byDay, byMonth, byMonthDay, byYearDay, byWeekNo, bySetPos, rDate, exDate, ...rest } = this.opts;
|
|
@@ -6874,9 +6889,9 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
6874
6889
|
all(iterator) {
|
|
6875
6890
|
if (!iterator && this.opts.cache !== false) {
|
|
6876
6891
|
if (!this.allResultCache) this.allResultCache = this.allInternal();
|
|
6877
|
-
return
|
|
6892
|
+
return this.toPublicDates(this.allResultCache.slice());
|
|
6878
6893
|
}
|
|
6879
|
-
return
|
|
6894
|
+
return this.toPublicDates(this.allInternal(this.toInternalIterator(iterator)));
|
|
6880
6895
|
}
|
|
6881
6896
|
allInternal(iterator) {
|
|
6882
6897
|
if (this.opts.rscale && [
|
|
@@ -7185,14 +7200,17 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7185
7200
|
const startInst = after instanceof Date ? Temporal.Instant.from(after.toISOString()) : normalizeZonedDateTime(after, "after").toInstant();
|
|
7186
7201
|
const endInst = before instanceof Date ? Temporal.Instant.from(before.toISOString()) : normalizeZonedDateTime(before, "before").toInstant();
|
|
7187
7202
|
const numericResult = this.tryNumericBetween(startInst.epochNanoseconds, endInst.epochNanoseconds, inc);
|
|
7188
|
-
if (numericResult.handled) return
|
|
7203
|
+
if (numericResult.handled) return this.toPublicDates(numericResult.value);
|
|
7189
7204
|
const startZdt = Temporal.Instant.from(startInst).toZonedDateTimeISO(this.tzid);
|
|
7190
7205
|
const beforeZdt = Temporal.Instant.from(endInst).toZonedDateTimeISO(this.tzid);
|
|
7191
7206
|
const tempOpts = { ...this.opts };
|
|
7192
7207
|
if (!tempOpts.until || Temporal.ZonedDateTime.compare(beforeZdt, tempOpts.until) < 0) tempOpts.until = beforeZdt;
|
|
7193
7208
|
if (tempOpts.count === void 0) tempOpts.dtstart = this.jumpAlignedDtstart(startZdt);
|
|
7194
|
-
const allDates = new RRuleTemporal(
|
|
7195
|
-
|
|
7209
|
+
const allDates = new RRuleTemporal({
|
|
7210
|
+
...tempOpts,
|
|
7211
|
+
temporal: this.outputTemporal
|
|
7212
|
+
}).allInternal();
|
|
7213
|
+
return this.toPublicDates(allDates.filter((date) => {
|
|
7196
7214
|
const inst = date.toInstant();
|
|
7197
7215
|
const afterStart = inc ? Temporal.Instant.compare(inst, startInst) >= 0 : Temporal.Instant.compare(inst, startInst) > 0;
|
|
7198
7216
|
const beforeEnd = inc ? Temporal.Instant.compare(inst, endInst) <= 0 : Temporal.Instant.compare(inst, endInst) < 0;
|
|
@@ -7298,7 +7316,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7298
7316
|
next(after = /* @__PURE__ */ new Date(), inc = false) {
|
|
7299
7317
|
const afterInst = after instanceof Date ? Temporal.Instant.from(after.toISOString()) : normalizeZonedDateTime(after, "after").toInstant();
|
|
7300
7318
|
const numericResult = this.tryNumericNext(afterInst.epochNanoseconds, inc);
|
|
7301
|
-
if (numericResult.handled) return
|
|
7319
|
+
if (numericResult.handled) return this.toPublicDate(numericResult.value);
|
|
7302
7320
|
let result = null;
|
|
7303
7321
|
const scanFrom = (rule) => {
|
|
7304
7322
|
rule.allInternal((occ) => {
|
|
@@ -7312,7 +7330,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7312
7330
|
};
|
|
7313
7331
|
if (this.opts.count !== void 0) scanFrom(this);
|
|
7314
7332
|
else scanFrom(this.ruleFromAlignedDtstart(afterInst.toZonedDateTimeISO(this.tzid)));
|
|
7315
|
-
return
|
|
7333
|
+
return this.toPublicDate(result);
|
|
7316
7334
|
}
|
|
7317
7335
|
/**
|
|
7318
7336
|
* Build a temporary rule identical to this one but starting at the
|
|
@@ -7324,6 +7342,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7324
7342
|
if (aligned.epochNanoseconds === this.originalDtstart.epochNanoseconds) return this;
|
|
7325
7343
|
return new RRuleTemporal({
|
|
7326
7344
|
...this.opts,
|
|
7345
|
+
temporal: this.outputTemporal,
|
|
7327
7346
|
dtstart: aligned,
|
|
7328
7347
|
includeDtstart: false
|
|
7329
7348
|
});
|
|
@@ -7337,7 +7356,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7337
7356
|
previous(before = /* @__PURE__ */ new Date(), inc = false) {
|
|
7338
7357
|
const beforeInst = before instanceof Date ? Temporal.Instant.from(before.toISOString()) : normalizeZonedDateTime(before, "before").toInstant();
|
|
7339
7358
|
const numericResult = this.tryNumericPrevious(beforeInst.epochNanoseconds, inc);
|
|
7340
|
-
if (numericResult.handled) return
|
|
7359
|
+
if (numericResult.handled) return this.toPublicDate(numericResult.value);
|
|
7341
7360
|
const scanFrom = (rule) => {
|
|
7342
7361
|
let prev = null;
|
|
7343
7362
|
rule.allInternal((occ) => {
|
|
@@ -7348,7 +7367,7 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7348
7367
|
});
|
|
7349
7368
|
return prev;
|
|
7350
7369
|
};
|
|
7351
|
-
if (this.opts.count !== void 0) return
|
|
7370
|
+
if (this.opts.count !== void 0) return this.toPublicDate(scanFrom(this));
|
|
7352
7371
|
const beforeZdt = beforeInst.toZonedDateTimeISO(this.tzid);
|
|
7353
7372
|
const anchor = this.opts.until && Temporal.ZonedDateTime.compare(this.opts.until, beforeZdt) < 0 ? this.opts.until : beforeZdt;
|
|
7354
7373
|
const interval = this.opts.interval ?? 1;
|
|
@@ -7356,9 +7375,9 @@ var RRuleTemporal = class RRuleTemporal {
|
|
|
7356
7375
|
const target = backoff === 0 ? anchor : anchor.subtract(this.freqDuration(interval * 4 ** backoff));
|
|
7357
7376
|
const rule = this.ruleFromAlignedDtstart(target);
|
|
7358
7377
|
const prev = scanFrom(rule);
|
|
7359
|
-
if (prev || rule === this) return
|
|
7378
|
+
if (prev || rule === this) return this.toPublicDate(prev);
|
|
7360
7379
|
}
|
|
7361
|
-
return
|
|
7380
|
+
return this.toPublicDate(scanFrom(this));
|
|
7362
7381
|
}
|
|
7363
7382
|
/** A duration of `count` steps in this rule's frequency unit. */
|
|
7364
7383
|
freqDuration(count) {
|
package/dist/totext.cjs
CHANGED
package/dist/totext.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrule-temporal",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
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",
|