rrule-temporal 1.1.5 → 1.1.7

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
@@ -224,3 +224,50 @@ const hits = ruleC.between(
224
224
  true
225
225
  );
226
226
  ```
227
+
228
+ ### Converting between **@js-temporal/polyfill** and **temporal-polyfill**
229
+
230
+ `rrule-temporal` ships with **`@js-temporal/polyfill`** and therefore returns `Temporal` objects that are from that implementation. If the rest of your codebase (or a third-party package) relies on the lighter **`temporal-polyfill`** package or a native Temporal implementation, those objects will **not** satisfy `instanceof` checks in your app.
231
+ This snippet shows how to re-hydrate each recurrence result into the polyfill your project expects.
232
+
233
+ ```ts
234
+ // rrule-temporal (and its internals) use @js-temporal/polyfill
235
+ import { Temporal as RRTTemporal } from "@js-temporal/polyfill";
236
+ // your application using temporal-polyfill or native Temporal
237
+ import { Temporal as AppTemporal } from "temporal-polyfill";
238
+
239
+ import { RRuleTemporal } from "rrule-temporal";
240
+
241
+ /** Weekly rule that fires 4 times starting 5 May 2025, 10 AM America/Chicago. */
242
+ const rule = new RRuleTemporal({
243
+ freq: "WEEKLY",
244
+ count: 4,
245
+ dtstart: RRTTemporal.ZonedDateTime.from(
246
+ "2025-05-05T10:00[America/Chicago]"
247
+ ),
248
+ });
249
+
250
+ // Occurrences are ZonedDateTime instances from @js-temporal/polyfill
251
+ const rawOccurrences = rule.all();
252
+
253
+ /** Convert each ZonedDateTime to temporal-polyfill ZonedDateTime. */
254
+ const appOccurrences = rawOccurrences.map((zdt) =>
255
+ AppTemporal.ZonedDateTime.from(zdt.toString())
256
+ );
257
+
258
+ // …now `appOccurrences` can be passed anywhere that expects temporal-polyfill in your app
259
+ ```
260
+
261
+ #### Why `.toString()`?
262
+
263
+ `Temporal.*.from()` accepts ISO 8601 strings (including bracketed time-zone annotations), so calling `toString()` sidesteps the internal-slot branding that makes polyfill objects incompatible.
264
+
265
+ #### Nanosecond precision variant
266
+
267
+ ```ts
268
+ const appOccurrences = rawOccurrences.map((zdt) =>
269
+ AppTemporal.ZonedDateTime.fromEpochNanoseconds(zdt.epochNanoseconds)
270
+ );
271
+ ```
272
+
273
+ Both approaches preserve the original calendar, time-zone and nanosecond accuracy.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rrule-temporal",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "Recurrence rule processing using Temporal PlainDate/PlainDateTime",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "scripts": {
21
- "build": "tsup",
21
+ "build": "rm -rf dist && tsup",
22
22
  "test": "jest --coverage=false",
23
23
  "coverage": "jest",
24
24
  "format": "./node_modules/.bin/prettier --write 'src/**/*.ts'",
@@ -42,7 +42,7 @@
42
42
  "bugs": {
43
43
  "url": "https://github.com/ggaabe/rrule-temporal/issues"
44
44
  },
45
- "homepage": "https://github.io/ggaabe/rrule-temporal",
45
+ "homepage": "https://ggaabe.github.io/rrule-temporal/",
46
46
  "files": [
47
47
  "dist"
48
48
  ],