rrule-temporal 1.6.0 → 2.0.1
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 +60 -34
- package/dist/index.cjs +5 -2761
- package/dist/index.d.cts +41 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +1 -2757
- package/dist/src-B0RsDEOV.cjs +7577 -0
- package/dist/src-DEpYefSo.js +7554 -0
- package/dist/totext.cjs +19 -21
- package/dist/totext.js +13 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ const firstTen = rule.all((_, i) => i < 10);
|
|
|
40
40
|
Per RFC 5545, DTSTART and RRULE are separate properties. You can provide them separately:
|
|
41
41
|
|
|
42
42
|
```typescript
|
|
43
|
-
import { Temporal } from "
|
|
43
|
+
import { Temporal } from "temporal-polyfill";
|
|
44
44
|
|
|
45
45
|
const rule = new RRuleTemporal({
|
|
46
46
|
rruleString: 'FREQ=DAILY;COUNT=5',
|
|
@@ -68,7 +68,7 @@ zone (converted to UTC when required). Set `strict: true` to reject it.
|
|
|
68
68
|
Instead of a full ICS string you can supply the recurrence parameters directly:
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
|
-
import { Temporal } from "
|
|
71
|
+
import { Temporal } from "temporal-polyfill";
|
|
72
72
|
|
|
73
73
|
const rule = new RRuleTemporal({
|
|
74
74
|
freq: "DAILY",
|
|
@@ -151,7 +151,7 @@ The `toText` helper converts a rule into a human readable description.
|
|
|
151
151
|
`UNTIL` (and optional `DTSTART`) dates are locale-aware via `toLocaleString`.
|
|
152
152
|
|
|
153
153
|
```typescript
|
|
154
|
-
import { Temporal } from "
|
|
154
|
+
import { Temporal } from "temporal-polyfill";
|
|
155
155
|
import { RRuleTemporal } from "rrule-temporal";
|
|
156
156
|
import { toText } from "rrule-temporal/totext";
|
|
157
157
|
|
|
@@ -303,27 +303,37 @@ Notes
|
|
|
303
303
|
|
|
304
304
|
## Benchmarks
|
|
305
305
|
|
|
306
|
-
Uncached median ops/s from the benchmark suite on a MacBook Pro M2 Max
|
|
307
|
-
The full three-library comparison, including
|
|
306
|
+
Uncached median ops/s from the benchmark suite on a MacBook Pro M2 Max
|
|
307
|
+
(Node 25, polyfill backend). The full three-library comparison, including
|
|
308
|
+
`rrule-rust` and cached-mode results, lives in `benchmarks/README.md`.
|
|
308
309
|
|
|
309
310
|
| Scenario | TZ | rrule-temporal median ops/s | rrule median ops/s | vs rrule |
|
|
310
311
|
| --- | --- | ---: | ---: | ---: |
|
|
311
|
-
| 30 daily occurrences | UTC |
|
|
312
|
-
| 30 daily occurrences | America/Chicago |
|
|
313
|
-
| Daily weekdays across many cycles | UTC |
|
|
314
|
-
| Daily weekdays across many cycles | America/Chicago |
|
|
315
|
-
| 720 hourly occurrences | UTC |
|
|
316
|
-
| 720 hourly occurrences | America/Chicago |
|
|
317
|
-
| 1,440 minutely occurrences | UTC |
|
|
318
|
-
| 1,440 minutely occurrences | America/Chicago |
|
|
319
|
-
| Weekly MO/WE/FR across many cycles | UTC |
|
|
320
|
-
| Weekly MO/WE/FR across many cycles | America/Chicago |
|
|
321
|
-
| Monthly last weekday across 20 years | UTC | 1,
|
|
322
|
-
| Monthly last weekday across 20 years | America/Chicago |
|
|
323
|
-
| Monthly first and last weekday across 20 years | UTC |
|
|
324
|
-
| Monthly first and last weekday across 20 years | America/Chicago |
|
|
325
|
-
|
|
326
|
-
|
|
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 |
|
|
326
|
+
|
|
327
|
+
Time-zone-aware rules iterate through an epoch-integer engine with a cached
|
|
328
|
+
per-zone offset table, so named-zone scenarios now run 25–42x faster than
|
|
329
|
+
`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`).
|
|
327
337
|
|
|
328
338
|
## Further examples
|
|
329
339
|
|
|
@@ -356,7 +366,7 @@ ruleB.all().forEach(dt => console.log(dt.toString()));
|
|
|
356
366
|
### Working with extra and excluded dates
|
|
357
367
|
|
|
358
368
|
```typescript
|
|
359
|
-
import { Temporal } from "
|
|
369
|
+
import { Temporal } from "temporal-polyfill";
|
|
360
370
|
|
|
361
371
|
const start = Temporal.ZonedDateTime.from({
|
|
362
372
|
year: 2025, month: 1, day: 1, hour: 12, timeZone: "UTC"
|
|
@@ -380,15 +390,24 @@ const hits = ruleC.between(
|
|
|
380
390
|
);
|
|
381
391
|
```
|
|
382
392
|
|
|
383
|
-
###
|
|
393
|
+
### Temporal implementations and interoperability
|
|
384
394
|
|
|
385
|
-
`rrule-temporal`
|
|
386
|
-
|
|
395
|
+
`rrule-temporal` uses the runtime's **native `Temporal`** when it exists
|
|
396
|
+
(Node 26+, Chrome 144+, Firefox 139+) and otherwise falls back to a bundled
|
|
397
|
+
copy of **`temporal-polyfill`** — no polyfill setup is required either way.
|
|
398
|
+
Inputs are accepted from **any** Temporal implementation: `dtstart`, `until`,
|
|
399
|
+
`rDate`, `exDate` and date filters are normalized internally, so you can pass
|
|
400
|
+
objects from `@js-temporal/polyfill`, `temporal-polyfill`, or native Temporal
|
|
401
|
+
interchangeably.
|
|
402
|
+
|
|
403
|
+
Returned occurrences come from the library's active implementation (native
|
|
404
|
+
when available, the bundled polyfill otherwise). They are fully spec-shaped,
|
|
405
|
+
but they will not satisfy `instanceof` checks against a *different*
|
|
406
|
+
implementation's classes. If your app needs instances of its own Temporal
|
|
407
|
+
implementation, re-hydrate them:
|
|
387
408
|
|
|
388
409
|
```ts
|
|
389
|
-
//
|
|
390
|
-
import { Temporal as RRTTemporal } from "@js-temporal/polyfill";
|
|
391
|
-
// your application using temporal-polyfill or native Temporal
|
|
410
|
+
// your application's Temporal implementation
|
|
392
411
|
import { Temporal as AppTemporal } from "temporal-polyfill";
|
|
393
412
|
|
|
394
413
|
import { RRuleTemporal } from "rrule-temporal";
|
|
@@ -397,25 +416,24 @@ import { RRuleTemporal } from "rrule-temporal";
|
|
|
397
416
|
const rule = new RRuleTemporal({
|
|
398
417
|
freq: "WEEKLY",
|
|
399
418
|
count: 4,
|
|
400
|
-
dtstart:
|
|
419
|
+
dtstart: AppTemporal.ZonedDateTime.from(
|
|
401
420
|
"2025-05-05T10:00[America/Chicago]"
|
|
402
421
|
),
|
|
403
422
|
});
|
|
404
423
|
|
|
405
|
-
// Occurrences are ZonedDateTime instances from @js-temporal/polyfill
|
|
406
424
|
const rawOccurrences = rule.all();
|
|
407
425
|
|
|
408
|
-
/** Convert each ZonedDateTime
|
|
426
|
+
/** Convert each ZonedDateTime into your app's implementation. */
|
|
409
427
|
const appOccurrences = rawOccurrences.map((zdt) =>
|
|
410
428
|
AppTemporal.ZonedDateTime.from(zdt.toString())
|
|
411
429
|
);
|
|
412
|
-
|
|
413
|
-
// …now `appOccurrences` can be passed anywhere that expects temporal-polyfill in your app
|
|
414
430
|
```
|
|
415
431
|
|
|
416
432
|
#### Why `.toString()`?
|
|
417
433
|
|
|
418
|
-
`Temporal.*.from()` accepts ISO 8601 strings (including bracketed time-zone
|
|
434
|
+
`Temporal.*.from()` accepts ISO 8601 strings (including bracketed time-zone
|
|
435
|
+
annotations), so calling `toString()` sidesteps the internal-slot branding
|
|
436
|
+
that makes objects from different implementations incompatible.
|
|
419
437
|
|
|
420
438
|
#### Nanosecond precision variant
|
|
421
439
|
|
|
@@ -427,6 +445,14 @@ const appOccurrences = rawOccurrences.map((zdt) =>
|
|
|
427
445
|
|
|
428
446
|
Both approaches preserve the original calendar, time-zone and nanosecond accuracy.
|
|
429
447
|
|
|
448
|
+
#### Non-Gregorian RSCALE rules
|
|
449
|
+
|
|
450
|
+
RFC 7529 `RSCALE` rules (Chinese, Hebrew, Indian) always compute calendar
|
|
451
|
+
math with the bundled polyfill, even when native Temporal is active:
|
|
452
|
+
implementations disagree on non-ISO calendar details (for example V8 numbers
|
|
453
|
+
Chinese calendar years in a continuous era), and recurrence results must not
|
|
454
|
+
change with the runtime.
|
|
455
|
+
|
|
430
456
|
## Sponsor
|
|
431
457
|
|
|
432
458
|
If this library saves you time, sponsorship helps keep it maintained.
|