rrule-temporal 1.4.5 → 1.4.6
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 +6 -1
- package/dist/{chunk-5IREWES7.js → chunk-6K5NTVS6.js} +23 -10
- package/dist/index.cjs +23 -10
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/totext.cjs +70 -37
- package/dist/totext.d.cts +5 -2
- package/dist/totext.d.ts +5 -2
- package/dist/totext.js +48 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,6 +61,9 @@ Note on `UNTIL` (RFC 5545): if `DTSTART` is a DATE-TIME with a `TZID` or UTC (`Z
|
|
|
61
61
|
`UNTIL` must be a DATE-TIME in UTC (trailing `Z`). If `DTSTART` is `VALUE=DATE`,
|
|
62
62
|
`UNTIL` must be a DATE (no time). Floating DATE-TIME rules (no `TZID`, no `Z`)
|
|
63
63
|
allow a floating `UNTIL`.
|
|
64
|
+
In default mode (`strict: false`), `UNTIL=YYYYMMDD` with a DATE-TIME `DTSTART`
|
|
65
|
+
is accepted for compatibility and treated as inclusive end-of-day in `DTSTART`'s
|
|
66
|
+
zone (converted to UTC when required). Set `strict: true` to reject it.
|
|
64
67
|
|
|
65
68
|
## Creating a rule with options
|
|
66
69
|
|
|
@@ -133,6 +136,7 @@ const prev = rule.previous(new Date("2025-05-01T00:00Z"));
|
|
|
133
136
|
## Converting to human-readable text
|
|
134
137
|
|
|
135
138
|
The `toText` helper converts a rule into a human readable description.
|
|
139
|
+
`UNTIL` (and optional `DTSTART`) dates are locale-aware via `toLocaleString`.
|
|
136
140
|
|
|
137
141
|
```typescript
|
|
138
142
|
import { Temporal } from "@js-temporal/polyfill";
|
|
@@ -147,6 +151,7 @@ rule.toString();
|
|
|
147
151
|
// "DTSTART;TZID=UTC:20250101T090000\nRRULE:FREQ=DAILY;COUNT=3"
|
|
148
152
|
toText(rule); // uses the runtime locale, defaults to English
|
|
149
153
|
toText(rule, "es"); // Spanish description
|
|
154
|
+
toText(rule, "en", { includeDtstart: true }); // include "starting from <DTSTART date>"
|
|
150
155
|
toText(rule);
|
|
151
156
|
// "every day for 3 times"
|
|
152
157
|
|
|
@@ -280,7 +285,7 @@ Notes
|
|
|
280
285
|
| `next(after?, inclusive?)` | Next occurrence after a given date. |
|
|
281
286
|
| `previous(before?, inclusive?)` | Previous occurrence before a date. |
|
|
282
287
|
| `toString()` | Convert the rule back into `DTSTART` and `RRULE` lines. |
|
|
283
|
-
| `toText(rule, locale?)` | Human readable description (`en`, `es`, `hi`, `yue`, `ar`, `he`, `zh`, `fr`). |
|
|
288
|
+
| `toText(rule, locale?, options?)` | Human readable description (`en`, `es`, `hi`, `yue`, `ar`, `he`, `zh`, `fr`). Options: `{ includeDtstart?: boolean }`. |
|
|
284
289
|
| `options()` | Return the normalized options object. |
|
|
285
290
|
|
|
286
291
|
## Further examples
|
|
@@ -81,7 +81,7 @@ function parseByMonthArray(val) {
|
|
|
81
81
|
return Number.isFinite(n) ? n : t;
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
function parseRRuleString(input, targetTimezone, dtstart) {
|
|
84
|
+
function parseRRuleString(input, targetTimezone, dtstart, strict = false) {
|
|
85
85
|
var _a, _b, _c, _d, _e;
|
|
86
86
|
const unfoldedInput = unfoldLine(input).trim();
|
|
87
87
|
let parsedDtstart;
|
|
@@ -173,7 +173,20 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
173
173
|
break;
|
|
174
174
|
}
|
|
175
175
|
if (!untilHasTime) {
|
|
176
|
-
|
|
176
|
+
if (strict) {
|
|
177
|
+
throw new Error("UNTIL rule part MUST have the same value type as DTSTART");
|
|
178
|
+
}
|
|
179
|
+
const localEndOfDay = parseIcsDateTime(val, tzid || "UTC", "DATE").with({
|
|
180
|
+
hour: 23,
|
|
181
|
+
minute: 59,
|
|
182
|
+
second: 59,
|
|
183
|
+
millisecond: 0,
|
|
184
|
+
microsecond: 0,
|
|
185
|
+
nanosecond: 0
|
|
186
|
+
});
|
|
187
|
+
const requiresUtc2 = dtstartHasTzid || dtstartIsUtc;
|
|
188
|
+
opts.until = requiresUtc2 ? localEndOfDay.withTimeZone("UTC") : localEndOfDay;
|
|
189
|
+
break;
|
|
177
190
|
}
|
|
178
191
|
const requiresUtc = dtstartHasTzid || dtstartIsUtc;
|
|
179
192
|
if (requiresUtc && !val.endsWith("Z")) {
|
|
@@ -231,19 +244,19 @@ var _RRuleTemporal = class _RRuleTemporal {
|
|
|
231
244
|
return Temporal.ZonedDateTime.from(zdt.toString());
|
|
232
245
|
}
|
|
233
246
|
constructor(params) {
|
|
234
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
247
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
235
248
|
let manual;
|
|
236
249
|
if (isIcsOpts(params)) {
|
|
237
|
-
const parsed = parseRRuleString(params.rruleString, params.tzid, params.dtstart);
|
|
250
|
+
const parsed = parseRRuleString(params.rruleString, params.tzid, params.dtstart, (_a = params.strict) != null ? _a : false);
|
|
238
251
|
if (!parsed.dtstart) {
|
|
239
252
|
throw new Error("dtstart is required - provide it either in rruleString or as a separate parameter");
|
|
240
253
|
}
|
|
241
|
-
this.tzid = (
|
|
254
|
+
this.tzid = (_c = (_b = parsed.tzid) != null ? _b : params.tzid) != null ? _c : "UTC";
|
|
242
255
|
this.originalDtstart = _RRuleTemporal.normalizeToPolyfill(parsed.dtstart);
|
|
243
256
|
manual = __spreadProps(__spreadValues({}, parsed), {
|
|
244
257
|
// Allow explicit COUNT/UNTIL overrides when omitted from the RRULE string
|
|
245
|
-
count: (
|
|
246
|
-
until: (
|
|
258
|
+
count: (_d = params.count) != null ? _d : parsed.count,
|
|
259
|
+
until: (_e = params.until) != null ? _e : parsed.until,
|
|
247
260
|
strict: params.strict,
|
|
248
261
|
maxIterations: params.maxIterations,
|
|
249
262
|
includeDtstart: params.includeDtstart,
|
|
@@ -259,7 +272,7 @@ var _RRuleTemporal = class _RRuleTemporal {
|
|
|
259
272
|
this.originalDtstart = _RRuleTemporal.normalizeToPolyfill(manual.dtstart);
|
|
260
273
|
}
|
|
261
274
|
if (!manual.freq) throw new Error("RRULE must include FREQ");
|
|
262
|
-
manual.interval = (
|
|
275
|
+
manual.interval = (_f = manual.interval) != null ? _f : 1;
|
|
263
276
|
if (manual.interval <= 0) {
|
|
264
277
|
throw new Error("Cannot create RRule: interval must be greater than 0");
|
|
265
278
|
}
|
|
@@ -270,8 +283,8 @@ var _RRuleTemporal = class _RRuleTemporal {
|
|
|
270
283
|
manual.until = _RRuleTemporal.normalizeToPolyfill(manual.until);
|
|
271
284
|
}
|
|
272
285
|
this.opts = this.sanitizeOpts(manual);
|
|
273
|
-
this.maxIterations = (
|
|
274
|
-
this.includeDtstart = (
|
|
286
|
+
this.maxIterations = (_g = manual.maxIterations) != null ? _g : 1e4;
|
|
287
|
+
this.includeDtstart = (_h = manual.includeDtstart) != null ? _h : false;
|
|
275
288
|
}
|
|
276
289
|
sanitizeNumericArray(arr, min, max, allowZero = false, sort = false) {
|
|
277
290
|
if (!arr) return void 0;
|
package/dist/index.cjs
CHANGED
|
@@ -102,7 +102,7 @@ function parseByMonthArray(val) {
|
|
|
102
102
|
return Number.isFinite(n) ? n : t;
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
function parseRRuleString(input, targetTimezone, dtstart) {
|
|
105
|
+
function parseRRuleString(input, targetTimezone, dtstart, strict = false) {
|
|
106
106
|
var _a, _b, _c, _d, _e;
|
|
107
107
|
const unfoldedInput = unfoldLine(input).trim();
|
|
108
108
|
let parsedDtstart;
|
|
@@ -194,7 +194,20 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
194
194
|
break;
|
|
195
195
|
}
|
|
196
196
|
if (!untilHasTime) {
|
|
197
|
-
|
|
197
|
+
if (strict) {
|
|
198
|
+
throw new Error("UNTIL rule part MUST have the same value type as DTSTART");
|
|
199
|
+
}
|
|
200
|
+
const localEndOfDay = parseIcsDateTime(val, tzid || "UTC", "DATE").with({
|
|
201
|
+
hour: 23,
|
|
202
|
+
minute: 59,
|
|
203
|
+
second: 59,
|
|
204
|
+
millisecond: 0,
|
|
205
|
+
microsecond: 0,
|
|
206
|
+
nanosecond: 0
|
|
207
|
+
});
|
|
208
|
+
const requiresUtc2 = dtstartHasTzid || dtstartIsUtc;
|
|
209
|
+
opts.until = requiresUtc2 ? localEndOfDay.withTimeZone("UTC") : localEndOfDay;
|
|
210
|
+
break;
|
|
198
211
|
}
|
|
199
212
|
const requiresUtc = dtstartHasTzid || dtstartIsUtc;
|
|
200
213
|
if (requiresUtc && !val.endsWith("Z")) {
|
|
@@ -252,19 +265,19 @@ var _RRuleTemporal = class _RRuleTemporal {
|
|
|
252
265
|
return import_polyfill.Temporal.ZonedDateTime.from(zdt.toString());
|
|
253
266
|
}
|
|
254
267
|
constructor(params) {
|
|
255
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
268
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
256
269
|
let manual;
|
|
257
270
|
if (isIcsOpts(params)) {
|
|
258
|
-
const parsed = parseRRuleString(params.rruleString, params.tzid, params.dtstart);
|
|
271
|
+
const parsed = parseRRuleString(params.rruleString, params.tzid, params.dtstart, (_a = params.strict) != null ? _a : false);
|
|
259
272
|
if (!parsed.dtstart) {
|
|
260
273
|
throw new Error("dtstart is required - provide it either in rruleString or as a separate parameter");
|
|
261
274
|
}
|
|
262
|
-
this.tzid = (
|
|
275
|
+
this.tzid = (_c = (_b = parsed.tzid) != null ? _b : params.tzid) != null ? _c : "UTC";
|
|
263
276
|
this.originalDtstart = _RRuleTemporal.normalizeToPolyfill(parsed.dtstart);
|
|
264
277
|
manual = __spreadProps(__spreadValues({}, parsed), {
|
|
265
278
|
// Allow explicit COUNT/UNTIL overrides when omitted from the RRULE string
|
|
266
|
-
count: (
|
|
267
|
-
until: (
|
|
279
|
+
count: (_d = params.count) != null ? _d : parsed.count,
|
|
280
|
+
until: (_e = params.until) != null ? _e : parsed.until,
|
|
268
281
|
strict: params.strict,
|
|
269
282
|
maxIterations: params.maxIterations,
|
|
270
283
|
includeDtstart: params.includeDtstart,
|
|
@@ -280,7 +293,7 @@ var _RRuleTemporal = class _RRuleTemporal {
|
|
|
280
293
|
this.originalDtstart = _RRuleTemporal.normalizeToPolyfill(manual.dtstart);
|
|
281
294
|
}
|
|
282
295
|
if (!manual.freq) throw new Error("RRULE must include FREQ");
|
|
283
|
-
manual.interval = (
|
|
296
|
+
manual.interval = (_f = manual.interval) != null ? _f : 1;
|
|
284
297
|
if (manual.interval <= 0) {
|
|
285
298
|
throw new Error("Cannot create RRule: interval must be greater than 0");
|
|
286
299
|
}
|
|
@@ -291,8 +304,8 @@ var _RRuleTemporal = class _RRuleTemporal {
|
|
|
291
304
|
manual.until = _RRuleTemporal.normalizeToPolyfill(manual.until);
|
|
292
305
|
}
|
|
293
306
|
this.opts = this.sanitizeOpts(manual);
|
|
294
|
-
this.maxIterations = (
|
|
295
|
-
this.includeDtstart = (
|
|
307
|
+
this.maxIterations = (_g = manual.maxIterations) != null ? _g : 1e4;
|
|
308
|
+
this.includeDtstart = (_h = manual.includeDtstart) != null ? _h : false;
|
|
296
309
|
}
|
|
297
310
|
sanitizeNumericArray(arr, min, max, allowZero = false, sort = false) {
|
|
298
311
|
if (!arr) return void 0;
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/totext.cjs
CHANGED
|
@@ -104,7 +104,7 @@ function parseByMonthArray(val) {
|
|
|
104
104
|
return Number.isFinite(n) ? n : t;
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
function parseRRuleString(input, targetTimezone, dtstart) {
|
|
107
|
+
function parseRRuleString(input, targetTimezone, dtstart, strict = false) {
|
|
108
108
|
var _a, _b, _c, _d, _e;
|
|
109
109
|
const unfoldedInput = unfoldLine(input).trim();
|
|
110
110
|
let parsedDtstart;
|
|
@@ -196,7 +196,20 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
196
196
|
break;
|
|
197
197
|
}
|
|
198
198
|
if (!untilHasTime) {
|
|
199
|
-
|
|
199
|
+
if (strict) {
|
|
200
|
+
throw new Error("UNTIL rule part MUST have the same value type as DTSTART");
|
|
201
|
+
}
|
|
202
|
+
const localEndOfDay = parseIcsDateTime(val, tzid || "UTC", "DATE").with({
|
|
203
|
+
hour: 23,
|
|
204
|
+
minute: 59,
|
|
205
|
+
second: 59,
|
|
206
|
+
millisecond: 0,
|
|
207
|
+
microsecond: 0,
|
|
208
|
+
nanosecond: 0
|
|
209
|
+
});
|
|
210
|
+
const requiresUtc2 = dtstartHasTzid || dtstartIsUtc;
|
|
211
|
+
opts.until = requiresUtc2 ? localEndOfDay.withTimeZone("UTC") : localEndOfDay;
|
|
212
|
+
break;
|
|
200
213
|
}
|
|
201
214
|
const requiresUtc = dtstartHasTzid || dtstartIsUtc;
|
|
202
215
|
if (requiresUtc && !val.endsWith("Z")) {
|
|
@@ -254,19 +267,19 @@ var _RRuleTemporal = class _RRuleTemporal {
|
|
|
254
267
|
return import_polyfill.Temporal.ZonedDateTime.from(zdt.toString());
|
|
255
268
|
}
|
|
256
269
|
constructor(params) {
|
|
257
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
270
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
258
271
|
let manual;
|
|
259
272
|
if (isIcsOpts(params)) {
|
|
260
|
-
const parsed = parseRRuleString(params.rruleString, params.tzid, params.dtstart);
|
|
273
|
+
const parsed = parseRRuleString(params.rruleString, params.tzid, params.dtstart, (_a = params.strict) != null ? _a : false);
|
|
261
274
|
if (!parsed.dtstart) {
|
|
262
275
|
throw new Error("dtstart is required - provide it either in rruleString or as a separate parameter");
|
|
263
276
|
}
|
|
264
|
-
this.tzid = (
|
|
277
|
+
this.tzid = (_c = (_b = parsed.tzid) != null ? _b : params.tzid) != null ? _c : "UTC";
|
|
265
278
|
this.originalDtstart = _RRuleTemporal.normalizeToPolyfill(parsed.dtstart);
|
|
266
279
|
manual = __spreadProps(__spreadValues({}, parsed), {
|
|
267
280
|
// Allow explicit COUNT/UNTIL overrides when omitted from the RRULE string
|
|
268
|
-
count: (
|
|
269
|
-
until: (
|
|
281
|
+
count: (_d = params.count) != null ? _d : parsed.count,
|
|
282
|
+
until: (_e = params.until) != null ? _e : parsed.until,
|
|
270
283
|
strict: params.strict,
|
|
271
284
|
maxIterations: params.maxIterations,
|
|
272
285
|
includeDtstart: params.includeDtstart,
|
|
@@ -282,7 +295,7 @@ var _RRuleTemporal = class _RRuleTemporal {
|
|
|
282
295
|
this.originalDtstart = _RRuleTemporal.normalizeToPolyfill(manual.dtstart);
|
|
283
296
|
}
|
|
284
297
|
if (!manual.freq) throw new Error("RRULE must include FREQ");
|
|
285
|
-
manual.interval = (
|
|
298
|
+
manual.interval = (_f = manual.interval) != null ? _f : 1;
|
|
286
299
|
if (manual.interval <= 0) {
|
|
287
300
|
throw new Error("Cannot create RRule: interval must be greater than 0");
|
|
288
301
|
}
|
|
@@ -293,8 +306,8 @@ var _RRuleTemporal = class _RRuleTemporal {
|
|
|
293
306
|
manual.until = _RRuleTemporal.normalizeToPolyfill(manual.until);
|
|
294
307
|
}
|
|
295
308
|
this.opts = this.sanitizeOpts(manual);
|
|
296
|
-
this.maxIterations = (
|
|
297
|
-
this.includeDtstart = (
|
|
309
|
+
this.maxIterations = (_g = manual.maxIterations) != null ? _g : 1e4;
|
|
310
|
+
this.includeDtstart = (_h = manual.includeDtstart) != null ? _h : false;
|
|
298
311
|
}
|
|
299
312
|
sanitizeNumericArray(arr, min, max, allowZero = false, sort = false) {
|
|
300
313
|
if (!arr) return void 0;
|
|
@@ -2569,7 +2582,8 @@ var en = {
|
|
|
2569
2582
|
date: "date",
|
|
2570
2583
|
dates: "dates",
|
|
2571
2584
|
and: "and",
|
|
2572
|
-
last: "last"
|
|
2585
|
+
last: "last",
|
|
2586
|
+
starting_from: "starting from"
|
|
2573
2587
|
},
|
|
2574
2588
|
ordinal: (n) => {
|
|
2575
2589
|
const abs = Math.abs(n);
|
|
@@ -2627,7 +2641,8 @@ var de = {
|
|
|
2627
2641
|
date: "Datum",
|
|
2628
2642
|
dates: "Daten",
|
|
2629
2643
|
and: "und",
|
|
2630
|
-
last: "letzter"
|
|
2644
|
+
last: "letzter",
|
|
2645
|
+
starting_from: "beginnend am"
|
|
2631
2646
|
},
|
|
2632
2647
|
ordinal: (n) => {
|
|
2633
2648
|
if (n < 0) return "letzten";
|
|
@@ -2684,7 +2699,8 @@ var es = {
|
|
|
2684
2699
|
date: "fecha",
|
|
2685
2700
|
dates: "fechas",
|
|
2686
2701
|
and: "y",
|
|
2687
|
-
last: "\xFAltimo"
|
|
2702
|
+
last: "\xFAltimo",
|
|
2703
|
+
starting_from: "a partir de"
|
|
2688
2704
|
},
|
|
2689
2705
|
ordinal: (n) => n < 0 ? "\xFAltimo" : `${Math.abs(n)}\xBA`
|
|
2690
2706
|
};
|
|
@@ -2738,7 +2754,8 @@ var hi = {
|
|
|
2738
2754
|
date: "\u0924\u093E\u0930\u0940\u0916",
|
|
2739
2755
|
dates: "\u0924\u093E\u0930\u0940\u0916\u0947\u0902",
|
|
2740
2756
|
and: "\u0914\u0930",
|
|
2741
|
-
last: "\u0906\u0916\u093F\u0930\u0940"
|
|
2757
|
+
last: "\u0906\u0916\u093F\u0930\u0940",
|
|
2758
|
+
starting_from: "\u0938\u0947 \u0936\u0941\u0930\u0942"
|
|
2742
2759
|
},
|
|
2743
2760
|
ordinal: (n) => n < 0 ? "\u0906\u0916\u093F\u0930\u0940" : `${Math.abs(n)}\u0935\u093E\u0902`
|
|
2744
2761
|
};
|
|
@@ -2779,7 +2796,8 @@ var yue = {
|
|
|
2779
2796
|
date: "\u65E5\u671F",
|
|
2780
2797
|
dates: "\u65E5\u671F",
|
|
2781
2798
|
and: "\u548C",
|
|
2782
|
-
last: "\u6700\u5F8C"
|
|
2799
|
+
last: "\u6700\u5F8C",
|
|
2800
|
+
starting_from: "\u7531"
|
|
2783
2801
|
},
|
|
2784
2802
|
ordinal: (n) => n < 0 ? "\u6700\u5F8C" : `\u7B2C${Math.abs(n)}`
|
|
2785
2803
|
};
|
|
@@ -2833,7 +2851,8 @@ var ar = {
|
|
|
2833
2851
|
date: "\u062A\u0627\u0631\u064A\u062E",
|
|
2834
2852
|
dates: "\u062A\u0648\u0627\u0631\u064A\u062E",
|
|
2835
2853
|
and: "\u0648",
|
|
2836
|
-
last: "\u0627\u0644\u0623\u062E\u064A\u0631"
|
|
2854
|
+
last: "\u0627\u0644\u0623\u062E\u064A\u0631",
|
|
2855
|
+
starting_from: "\u0627\u0628\u062A\u062F\u0627\u0621\u064B \u0645\u0646"
|
|
2837
2856
|
},
|
|
2838
2857
|
ordinal: (n) => {
|
|
2839
2858
|
if (n < 0) return "\u0627\u0644\u0623\u062E\u064A\u0631";
|
|
@@ -2906,7 +2925,8 @@ var he = {
|
|
|
2906
2925
|
date: "\u05EA\u05D0\u05E8\u05D9\u05DA",
|
|
2907
2926
|
dates: "\u05EA\u05D0\u05E8\u05D9\u05DB\u05D9\u05DD",
|
|
2908
2927
|
and: "\u05D5",
|
|
2909
|
-
last: "\u05D0\u05D7\u05E8\u05D5\u05DF"
|
|
2928
|
+
last: "\u05D0\u05D7\u05E8\u05D5\u05DF",
|
|
2929
|
+
starting_from: "\u05D4\u05D7\u05DC \u05DE"
|
|
2910
2930
|
},
|
|
2911
2931
|
ordinal: (n) => {
|
|
2912
2932
|
if (n < 0) return "\u05D0\u05D7\u05E8\u05D5\u05DF";
|
|
@@ -2966,25 +2986,26 @@ var zh = {
|
|
|
2966
2986
|
date: "\u65E5\u671F",
|
|
2967
2987
|
dates: "\u65E5\u671F",
|
|
2968
2988
|
and: "\u548C",
|
|
2969
|
-
last: "\u6700\u540E"
|
|
2989
|
+
last: "\u6700\u540E",
|
|
2990
|
+
starting_from: "\u4ECE"
|
|
2970
2991
|
},
|
|
2971
2992
|
ordinal: (n) => n < 0 ? "\u6700\u540E" : `\u7B2C${Math.abs(n)}`
|
|
2972
2993
|
};
|
|
2973
2994
|
var fr = {
|
|
2974
|
-
weekdayNames: ["
|
|
2995
|
+
weekdayNames: ["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"],
|
|
2975
2996
|
monthNames: [
|
|
2976
|
-
"
|
|
2977
|
-
"
|
|
2978
|
-
"
|
|
2979
|
-
"
|
|
2980
|
-
"
|
|
2981
|
-
"
|
|
2982
|
-
"
|
|
2983
|
-
"
|
|
2984
|
-
"
|
|
2985
|
-
"
|
|
2986
|
-
"
|
|
2987
|
-
"
|
|
2997
|
+
"janvier",
|
|
2998
|
+
"f\xE9vrier",
|
|
2999
|
+
"mars",
|
|
3000
|
+
"avril",
|
|
3001
|
+
"mai",
|
|
3002
|
+
"juin",
|
|
3003
|
+
"juillet",
|
|
3004
|
+
"ao\xFBt",
|
|
3005
|
+
"septembre",
|
|
3006
|
+
"octobre",
|
|
3007
|
+
"novembre",
|
|
3008
|
+
"d\xE9cembre"
|
|
2988
3009
|
],
|
|
2989
3010
|
units: {
|
|
2990
3011
|
year: { singular: "ann\xE9e", plural: "ans" },
|
|
@@ -3007,7 +3028,7 @@ var fr = {
|
|
|
3007
3028
|
at: "\xE0",
|
|
3008
3029
|
at_minute: "\xE0 la minute",
|
|
3009
3030
|
at_second: "\xE0 la seconde",
|
|
3010
|
-
until: "jusqu'
|
|
3031
|
+
until: "jusqu'au",
|
|
3011
3032
|
for: "pendant",
|
|
3012
3033
|
time: "fois",
|
|
3013
3034
|
times: "fois",
|
|
@@ -3020,7 +3041,8 @@ var fr = {
|
|
|
3020
3041
|
date: "date",
|
|
3021
3042
|
dates: "dates",
|
|
3022
3043
|
and: "et",
|
|
3023
|
-
last: "dernier"
|
|
3044
|
+
last: "dernier",
|
|
3045
|
+
starting_from: "\xE0 partir du"
|
|
3024
3046
|
},
|
|
3025
3047
|
ordinal: (n) => {
|
|
3026
3048
|
const abs = Math.abs(n);
|
|
@@ -3095,11 +3117,20 @@ function tzAbbreviation(zdt) {
|
|
|
3095
3117
|
const tzPart = parts.find((p) => p.type === "timeZoneName");
|
|
3096
3118
|
return (tzPart == null ? void 0 : tzPart.value) || zdt.timeZoneId;
|
|
3097
3119
|
}
|
|
3098
|
-
function
|
|
3120
|
+
function formatLocalizedDate(zdt, locale) {
|
|
3121
|
+
try {
|
|
3122
|
+
return zdt.toLocaleString(locale, { dateStyle: "long" });
|
|
3123
|
+
} catch (e) {
|
|
3124
|
+
return zdt.toLocaleString("en", { dateStyle: "long" });
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
function toText(input, locale, options = {}) {
|
|
3099
3128
|
const rule = typeof input === "string" ? new RRuleTemporal({ rruleString: input }) : input;
|
|
3100
3129
|
const opts = rule.options();
|
|
3101
|
-
const
|
|
3130
|
+
const resolvedLocale = locale != null ? locale : Intl.DateTimeFormat().resolvedOptions().locale;
|
|
3131
|
+
const lang = resolvedLocale.split("-")[0];
|
|
3102
3132
|
const data = LOCALES[lang] || en;
|
|
3133
|
+
const dateLocale = LOCALES[lang] ? resolvedLocale : "en";
|
|
3103
3134
|
const {
|
|
3104
3135
|
freq,
|
|
3105
3136
|
interval = 1,
|
|
@@ -3201,9 +3232,11 @@ function toText(input, locale) {
|
|
|
3201
3232
|
if (!textByHour && !textByMinute && textBySecond) {
|
|
3202
3233
|
parts.push(data.words.at_second, list(textBySecond, void 0, data.words.and));
|
|
3203
3234
|
}
|
|
3235
|
+
if (options.includeDtstart) {
|
|
3236
|
+
parts.push(data.words.starting_from, formatLocalizedDate(opts.dtstart, dateLocale));
|
|
3237
|
+
}
|
|
3204
3238
|
if (until) {
|
|
3205
|
-
|
|
3206
|
-
parts.push(data.words.until, `${monthName} ${until.day}, ${until.year}`);
|
|
3239
|
+
parts.push(data.words.until, formatLocalizedDate(until, dateLocale));
|
|
3207
3240
|
} else if (count !== void 0) {
|
|
3208
3241
|
parts.push(data.words.for, count.toString(), count === 1 ? data.words.time : data.words.times);
|
|
3209
3242
|
}
|
package/dist/totext.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { RRuleTemporal } from './index.cjs';
|
|
2
2
|
import '@js-temporal/polyfill';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface ToTextOptions {
|
|
5
|
+
includeDtstart?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function toText(input: RRuleTemporal | string, locale?: string, options?: ToTextOptions): string;
|
|
5
8
|
|
|
6
|
-
export { toText };
|
|
9
|
+
export { type ToTextOptions, toText };
|
package/dist/totext.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { RRuleTemporal } from './index.js';
|
|
2
2
|
import '@js-temporal/polyfill';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface ToTextOptions {
|
|
5
|
+
includeDtstart?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function toText(input: RRuleTemporal | string, locale?: string, options?: ToTextOptions): string;
|
|
5
8
|
|
|
6
|
-
export { toText };
|
|
9
|
+
export { type ToTextOptions, toText };
|
package/dist/totext.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RRuleTemporal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6K5NTVS6.js";
|
|
4
4
|
|
|
5
5
|
// src/totext.ts
|
|
6
6
|
var en = {
|
|
@@ -53,7 +53,8 @@ var en = {
|
|
|
53
53
|
date: "date",
|
|
54
54
|
dates: "dates",
|
|
55
55
|
and: "and",
|
|
56
|
-
last: "last"
|
|
56
|
+
last: "last",
|
|
57
|
+
starting_from: "starting from"
|
|
57
58
|
},
|
|
58
59
|
ordinal: (n) => {
|
|
59
60
|
const abs = Math.abs(n);
|
|
@@ -111,7 +112,8 @@ var de = {
|
|
|
111
112
|
date: "Datum",
|
|
112
113
|
dates: "Daten",
|
|
113
114
|
and: "und",
|
|
114
|
-
last: "letzter"
|
|
115
|
+
last: "letzter",
|
|
116
|
+
starting_from: "beginnend am"
|
|
115
117
|
},
|
|
116
118
|
ordinal: (n) => {
|
|
117
119
|
if (n < 0) return "letzten";
|
|
@@ -168,7 +170,8 @@ var es = {
|
|
|
168
170
|
date: "fecha",
|
|
169
171
|
dates: "fechas",
|
|
170
172
|
and: "y",
|
|
171
|
-
last: "\xFAltimo"
|
|
173
|
+
last: "\xFAltimo",
|
|
174
|
+
starting_from: "a partir de"
|
|
172
175
|
},
|
|
173
176
|
ordinal: (n) => n < 0 ? "\xFAltimo" : `${Math.abs(n)}\xBA`
|
|
174
177
|
};
|
|
@@ -222,7 +225,8 @@ var hi = {
|
|
|
222
225
|
date: "\u0924\u093E\u0930\u0940\u0916",
|
|
223
226
|
dates: "\u0924\u093E\u0930\u0940\u0916\u0947\u0902",
|
|
224
227
|
and: "\u0914\u0930",
|
|
225
|
-
last: "\u0906\u0916\u093F\u0930\u0940"
|
|
228
|
+
last: "\u0906\u0916\u093F\u0930\u0940",
|
|
229
|
+
starting_from: "\u0938\u0947 \u0936\u0941\u0930\u0942"
|
|
226
230
|
},
|
|
227
231
|
ordinal: (n) => n < 0 ? "\u0906\u0916\u093F\u0930\u0940" : `${Math.abs(n)}\u0935\u093E\u0902`
|
|
228
232
|
};
|
|
@@ -263,7 +267,8 @@ var yue = {
|
|
|
263
267
|
date: "\u65E5\u671F",
|
|
264
268
|
dates: "\u65E5\u671F",
|
|
265
269
|
and: "\u548C",
|
|
266
|
-
last: "\u6700\u5F8C"
|
|
270
|
+
last: "\u6700\u5F8C",
|
|
271
|
+
starting_from: "\u7531"
|
|
267
272
|
},
|
|
268
273
|
ordinal: (n) => n < 0 ? "\u6700\u5F8C" : `\u7B2C${Math.abs(n)}`
|
|
269
274
|
};
|
|
@@ -317,7 +322,8 @@ var ar = {
|
|
|
317
322
|
date: "\u062A\u0627\u0631\u064A\u062E",
|
|
318
323
|
dates: "\u062A\u0648\u0627\u0631\u064A\u062E",
|
|
319
324
|
and: "\u0648",
|
|
320
|
-
last: "\u0627\u0644\u0623\u062E\u064A\u0631"
|
|
325
|
+
last: "\u0627\u0644\u0623\u062E\u064A\u0631",
|
|
326
|
+
starting_from: "\u0627\u0628\u062A\u062F\u0627\u0621\u064B \u0645\u0646"
|
|
321
327
|
},
|
|
322
328
|
ordinal: (n) => {
|
|
323
329
|
if (n < 0) return "\u0627\u0644\u0623\u062E\u064A\u0631";
|
|
@@ -390,7 +396,8 @@ var he = {
|
|
|
390
396
|
date: "\u05EA\u05D0\u05E8\u05D9\u05DA",
|
|
391
397
|
dates: "\u05EA\u05D0\u05E8\u05D9\u05DB\u05D9\u05DD",
|
|
392
398
|
and: "\u05D5",
|
|
393
|
-
last: "\u05D0\u05D7\u05E8\u05D5\u05DF"
|
|
399
|
+
last: "\u05D0\u05D7\u05E8\u05D5\u05DF",
|
|
400
|
+
starting_from: "\u05D4\u05D7\u05DC \u05DE"
|
|
394
401
|
},
|
|
395
402
|
ordinal: (n) => {
|
|
396
403
|
if (n < 0) return "\u05D0\u05D7\u05E8\u05D5\u05DF";
|
|
@@ -450,25 +457,26 @@ var zh = {
|
|
|
450
457
|
date: "\u65E5\u671F",
|
|
451
458
|
dates: "\u65E5\u671F",
|
|
452
459
|
and: "\u548C",
|
|
453
|
-
last: "\u6700\u540E"
|
|
460
|
+
last: "\u6700\u540E",
|
|
461
|
+
starting_from: "\u4ECE"
|
|
454
462
|
},
|
|
455
463
|
ordinal: (n) => n < 0 ? "\u6700\u540E" : `\u7B2C${Math.abs(n)}`
|
|
456
464
|
};
|
|
457
465
|
var fr = {
|
|
458
|
-
weekdayNames: ["
|
|
466
|
+
weekdayNames: ["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"],
|
|
459
467
|
monthNames: [
|
|
460
|
-
"
|
|
461
|
-
"
|
|
462
|
-
"
|
|
463
|
-
"
|
|
464
|
-
"
|
|
465
|
-
"
|
|
466
|
-
"
|
|
467
|
-
"
|
|
468
|
-
"
|
|
469
|
-
"
|
|
470
|
-
"
|
|
471
|
-
"
|
|
468
|
+
"janvier",
|
|
469
|
+
"f\xE9vrier",
|
|
470
|
+
"mars",
|
|
471
|
+
"avril",
|
|
472
|
+
"mai",
|
|
473
|
+
"juin",
|
|
474
|
+
"juillet",
|
|
475
|
+
"ao\xFBt",
|
|
476
|
+
"septembre",
|
|
477
|
+
"octobre",
|
|
478
|
+
"novembre",
|
|
479
|
+
"d\xE9cembre"
|
|
472
480
|
],
|
|
473
481
|
units: {
|
|
474
482
|
year: { singular: "ann\xE9e", plural: "ans" },
|
|
@@ -491,7 +499,7 @@ var fr = {
|
|
|
491
499
|
at: "\xE0",
|
|
492
500
|
at_minute: "\xE0 la minute",
|
|
493
501
|
at_second: "\xE0 la seconde",
|
|
494
|
-
until: "jusqu'
|
|
502
|
+
until: "jusqu'au",
|
|
495
503
|
for: "pendant",
|
|
496
504
|
time: "fois",
|
|
497
505
|
times: "fois",
|
|
@@ -504,7 +512,8 @@ var fr = {
|
|
|
504
512
|
date: "date",
|
|
505
513
|
dates: "dates",
|
|
506
514
|
and: "et",
|
|
507
|
-
last: "dernier"
|
|
515
|
+
last: "dernier",
|
|
516
|
+
starting_from: "\xE0 partir du"
|
|
508
517
|
},
|
|
509
518
|
ordinal: (n) => {
|
|
510
519
|
const abs = Math.abs(n);
|
|
@@ -579,11 +588,20 @@ function tzAbbreviation(zdt) {
|
|
|
579
588
|
const tzPart = parts.find((p) => p.type === "timeZoneName");
|
|
580
589
|
return (tzPart == null ? void 0 : tzPart.value) || zdt.timeZoneId;
|
|
581
590
|
}
|
|
582
|
-
function
|
|
591
|
+
function formatLocalizedDate(zdt, locale) {
|
|
592
|
+
try {
|
|
593
|
+
return zdt.toLocaleString(locale, { dateStyle: "long" });
|
|
594
|
+
} catch (e) {
|
|
595
|
+
return zdt.toLocaleString("en", { dateStyle: "long" });
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
function toText(input, locale, options = {}) {
|
|
583
599
|
const rule = typeof input === "string" ? new RRuleTemporal({ rruleString: input }) : input;
|
|
584
600
|
const opts = rule.options();
|
|
585
|
-
const
|
|
601
|
+
const resolvedLocale = locale != null ? locale : Intl.DateTimeFormat().resolvedOptions().locale;
|
|
602
|
+
const lang = resolvedLocale.split("-")[0];
|
|
586
603
|
const data = LOCALES[lang] || en;
|
|
604
|
+
const dateLocale = LOCALES[lang] ? resolvedLocale : "en";
|
|
587
605
|
const {
|
|
588
606
|
freq,
|
|
589
607
|
interval = 1,
|
|
@@ -685,9 +703,11 @@ function toText(input, locale) {
|
|
|
685
703
|
if (!textByHour && !textByMinute && textBySecond) {
|
|
686
704
|
parts.push(data.words.at_second, list(textBySecond, void 0, data.words.and));
|
|
687
705
|
}
|
|
706
|
+
if (options.includeDtstart) {
|
|
707
|
+
parts.push(data.words.starting_from, formatLocalizedDate(opts.dtstart, dateLocale));
|
|
708
|
+
}
|
|
688
709
|
if (until) {
|
|
689
|
-
|
|
690
|
-
parts.push(data.words.until, `${monthName} ${until.day}, ${until.year}`);
|
|
710
|
+
parts.push(data.words.until, formatLocalizedDate(until, dateLocale));
|
|
691
711
|
} else if (count !== void 0) {
|
|
692
712
|
parts.push(data.words.for, count.toString(), count === 1 ? data.words.time : data.words.times);
|
|
693
713
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrule-temporal",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
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",
|