rrule-temporal 0.1.2 → 0.1.4

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.
@@ -194,3 +194,47 @@ describe("RRuleTemporal - BYMONTH with YEARLY freq (manual opts)", () => {
194
194
  }
195
195
  });
196
196
  });
197
+ describe("RRuleTemporal - Weekly BYDAY simple all()", () => {
198
+ const ics = `DTSTART;TZID=America/Chicago:20250406T000000
199
+ RRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=0;BYMINUTE=0;COUNT=4`.trim();
200
+ const rule = new RRuleTemporal({ rruleString: ics });
201
+ test("all() returns 4 consecutive Mondays", () => {
202
+ const dates = rule.all();
203
+ // dayOfWeek 1 == Monday
204
+ expect(dates).toHaveLength(4);
205
+ expect(dates.map((d) => d.day)).toEqual([7, 14, 21, 28]);
206
+ dates.forEach((d) => expect(d.dayOfWeek).toBe(1));
207
+ });
208
+ });
209
+ describe("RRuleTemporal - Weekly BYDAY simple between()", () => {
210
+ const ics = `DTSTART;TZID=America/Chicago:20250325T000000
211
+ RRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=0;BYMINUTE=0`.trim();
212
+ const rule = new RRuleTemporal({ rruleString: ics });
213
+ // Window: April 22 2025 UTC → May 20 2025 UTC
214
+ const start = new Date(Date.UTC(2025, 3, 22, 0, 0)); // April is month=3
215
+ const end = new Date(Date.UTC(2025, 4, 20, 0, 0)); // May is month=4
216
+ test("between() returns the Mondays falling in that window", () => {
217
+ const arrInc = rule.between(start, end, true);
218
+ // Expect 2025-04-28, 05-05, 05-12, 05-19
219
+ expect(arrInc.map((d) => d.day)).toEqual([28, 5, 12, 19]);
220
+ arrInc.forEach((d) => expect(d.dayOfWeek).toBe(1));
221
+ });
222
+ });
223
+ describe("RRuleTemporal - Weekly BYDAY frequencies without positional prefix", () => {
224
+ const ics = `DTSTART;TZID=America/Chicago:20250325T000000
225
+ RRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=0;BYMINUTE=0`.trim();
226
+ const rule = new RRuleTemporal({ rruleString: ics });
227
+ // 2025 Apr 22 00:00 UTC
228
+ const start = new Date(Date.UTC(2025, 3, 22, 0, 0));
229
+ // 2026 Apr 22 00:00 UTC
230
+ const end = new Date(Date.UTC(2026, 3, 22, 0, 0, 0));
231
+ test("between returns occurrences in window", () => {
232
+ const arrInc = rule.between(start, end, true);
233
+ console.log("arrInc: ", arrInc.map((d) => d.toString()));
234
+ expect(arrInc.map((d) => d.day)).toEqual([
235
+ 28, 5, 12, 19, 26, 2, 9, 16, 23, 30, 7, 14, 21, 28, 4, 11, 18, 25, 1, 8,
236
+ 15, 22, 29, 6, 13, 20, 27, 3, 10, 17, 24, 1, 8, 15, 22, 29, 5, 12, 19, 26,
237
+ 2, 9, 16, 23, 2, 9, 16, 23, 30, 6, 13, 20,
238
+ ]);
239
+ });
240
+ });
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "rrule-temporal",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Recurrence rule processing using Temporal PlainDate/PlainDateTime",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
5
  "types": "dist/index.d.ts",
8
6
  "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js"
12
+ }
13
+ },
9
14
  "scripts": {
10
- "build": "tsc --build",
15
+ "build": "tsup src/index.ts --format cjs,esm --dts",
11
16
  "test": "jest"
12
17
  },
13
18
  "repository": {
@@ -38,6 +43,7 @@
38
43
  "jest": "^29.7.0",
39
44
  "ts-jest": "^29.3.2",
40
45
  "ts-node": "^10.9.2",
46
+ "tsup": "^8.4.0",
41
47
  "typescript": "^5.8.3"
42
48
  },
43
49
  "dependencies": {