rrule-temporal 1.2.7 → 1.3.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/dist/{chunk-SWKVAJTZ.js → chunk-R242V3P5.js} +130 -1
- package/dist/index.cjs +130 -1
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -1
- package/dist/totext.cjs +130 -1
- package/dist/totext.js +1 -1
- package/package.json +1 -1
|
@@ -17,6 +17,18 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
20
32
|
|
|
21
33
|
// src/index.ts
|
|
22
34
|
import { Temporal } from "@js-temporal/polyfill";
|
|
@@ -188,7 +200,7 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
188
200
|
}
|
|
189
201
|
return opts;
|
|
190
202
|
}
|
|
191
|
-
var
|
|
203
|
+
var _RRuleTemporal = class _RRuleTemporal {
|
|
192
204
|
constructor(params) {
|
|
193
205
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
194
206
|
let manual;
|
|
@@ -678,6 +690,99 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
678
690
|
options() {
|
|
679
691
|
return this.opts;
|
|
680
692
|
}
|
|
693
|
+
cloneOptions() {
|
|
694
|
+
const _a = this.opts, {
|
|
695
|
+
byHour,
|
|
696
|
+
byMinute,
|
|
697
|
+
bySecond,
|
|
698
|
+
byDay,
|
|
699
|
+
byMonth,
|
|
700
|
+
byMonthDay,
|
|
701
|
+
byYearDay,
|
|
702
|
+
byWeekNo,
|
|
703
|
+
bySetPos,
|
|
704
|
+
rDate,
|
|
705
|
+
exDate
|
|
706
|
+
} = _a, rest = __objRest(_a, [
|
|
707
|
+
"byHour",
|
|
708
|
+
"byMinute",
|
|
709
|
+
"bySecond",
|
|
710
|
+
"byDay",
|
|
711
|
+
"byMonth",
|
|
712
|
+
"byMonthDay",
|
|
713
|
+
"byYearDay",
|
|
714
|
+
"byWeekNo",
|
|
715
|
+
"bySetPos",
|
|
716
|
+
"rDate",
|
|
717
|
+
"exDate"
|
|
718
|
+
]);
|
|
719
|
+
return __spreadProps(__spreadValues({}, rest), {
|
|
720
|
+
byHour: byHour ? [...byHour] : void 0,
|
|
721
|
+
byMinute: byMinute ? [...byMinute] : void 0,
|
|
722
|
+
bySecond: bySecond ? [...bySecond] : void 0,
|
|
723
|
+
byDay: byDay ? [...byDay] : void 0,
|
|
724
|
+
byMonth: byMonth ? [...byMonth] : void 0,
|
|
725
|
+
byMonthDay: byMonthDay ? [...byMonthDay] : void 0,
|
|
726
|
+
byYearDay: byYearDay ? [...byYearDay] : void 0,
|
|
727
|
+
byWeekNo: byWeekNo ? [...byWeekNo] : void 0,
|
|
728
|
+
bySetPos: bySetPos ? [...bySetPos] : void 0,
|
|
729
|
+
rDate: rDate ? [...rDate] : void 0,
|
|
730
|
+
exDate: exDate ? [...exDate] : void 0
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
cloneUpdateOptions(updates) {
|
|
734
|
+
const cloned = {};
|
|
735
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byHour")) {
|
|
736
|
+
cloned.byHour = Array.isArray(updates.byHour) ? [...updates.byHour] : updates.byHour;
|
|
737
|
+
}
|
|
738
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byMinute")) {
|
|
739
|
+
cloned.byMinute = Array.isArray(updates.byMinute) ? [...updates.byMinute] : updates.byMinute;
|
|
740
|
+
}
|
|
741
|
+
if (Object.prototype.hasOwnProperty.call(updates, "bySecond")) {
|
|
742
|
+
cloned.bySecond = Array.isArray(updates.bySecond) ? [...updates.bySecond] : updates.bySecond;
|
|
743
|
+
}
|
|
744
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byDay")) {
|
|
745
|
+
cloned.byDay = Array.isArray(updates.byDay) ? [...updates.byDay] : updates.byDay;
|
|
746
|
+
}
|
|
747
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byMonth")) {
|
|
748
|
+
cloned.byMonth = Array.isArray(updates.byMonth) ? [...updates.byMonth] : updates.byMonth;
|
|
749
|
+
}
|
|
750
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byMonthDay")) {
|
|
751
|
+
cloned.byMonthDay = Array.isArray(updates.byMonthDay) ? [...updates.byMonthDay] : updates.byMonthDay;
|
|
752
|
+
}
|
|
753
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byYearDay")) {
|
|
754
|
+
cloned.byYearDay = Array.isArray(updates.byYearDay) ? [...updates.byYearDay] : updates.byYearDay;
|
|
755
|
+
}
|
|
756
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byWeekNo")) {
|
|
757
|
+
cloned.byWeekNo = Array.isArray(updates.byWeekNo) ? [...updates.byWeekNo] : updates.byWeekNo;
|
|
758
|
+
}
|
|
759
|
+
if (Object.prototype.hasOwnProperty.call(updates, "bySetPos")) {
|
|
760
|
+
cloned.bySetPos = Array.isArray(updates.bySetPos) ? [...updates.bySetPos] : updates.bySetPos;
|
|
761
|
+
}
|
|
762
|
+
if (Object.prototype.hasOwnProperty.call(updates, "rDate")) {
|
|
763
|
+
cloned.rDate = Array.isArray(updates.rDate) ? [...updates.rDate] : updates.rDate;
|
|
764
|
+
}
|
|
765
|
+
if (Object.prototype.hasOwnProperty.call(updates, "exDate")) {
|
|
766
|
+
cloned.exDate = Array.isArray(updates.exDate) ? [...updates.exDate] : updates.exDate;
|
|
767
|
+
}
|
|
768
|
+
return cloned;
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Create a new {@link RRuleTemporal} instance with modified options while keeping the current one unchanged.
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
* ```ts
|
|
775
|
+
* const updated = rule.with({byMonthDay: [3]});
|
|
776
|
+
* ```
|
|
777
|
+
*/
|
|
778
|
+
with(updates) {
|
|
779
|
+
var _a, _b;
|
|
780
|
+
const merged = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, this.cloneOptions()), updates), this.cloneUpdateOptions(updates)), {
|
|
781
|
+
tzid: (_a = updates.tzid) != null ? _a : this.opts.tzid,
|
|
782
|
+
dtstart: (_b = updates.dtstart) != null ? _b : this.opts.dtstart
|
|
783
|
+
});
|
|
784
|
+
return new _RRuleTemporal(merged);
|
|
785
|
+
}
|
|
681
786
|
addDtstartIfNeeded(dates, iterator) {
|
|
682
787
|
if (this.includeDtstart && !this.matchesAll(this.originalDtstart)) {
|
|
683
788
|
if (iterator && this.isExcluded(this.originalDtstart)) {
|
|
@@ -1850,6 +1955,27 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
1850
1955
|
const r = ((_a = this.opts.rscale) == null ? void 0 : _a.toUpperCase()) || "";
|
|
1851
1956
|
return map[r] || null;
|
|
1852
1957
|
}
|
|
1958
|
+
assertRscaleCalendarSupported(calId) {
|
|
1959
|
+
if (calId === "gregory" || calId === "iso8601") return;
|
|
1960
|
+
const cached = _RRuleTemporal.rscaleCalendarSupport[calId];
|
|
1961
|
+
if (cached === true) return;
|
|
1962
|
+
if (cached === false) {
|
|
1963
|
+
throw new Error(`RSCALE=${this.opts.rscale} is not supported by the current Temporal/Intl implementation`);
|
|
1964
|
+
}
|
|
1965
|
+
let supported = true;
|
|
1966
|
+
try {
|
|
1967
|
+
const probe = Temporal.ZonedDateTime.from("2000-01-01T00:00:00+00:00[UTC]").withCalendar(calId);
|
|
1968
|
+
void probe.year;
|
|
1969
|
+
void probe.monthCode;
|
|
1970
|
+
void probe.day;
|
|
1971
|
+
} catch (e) {
|
|
1972
|
+
supported = false;
|
|
1973
|
+
}
|
|
1974
|
+
_RRuleTemporal.rscaleCalendarSupport[calId] = supported;
|
|
1975
|
+
if (!supported) {
|
|
1976
|
+
throw new Error(`RSCALE=${this.opts.rscale} is not supported by the current Temporal/Intl implementation`);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1853
1979
|
pad2(n) {
|
|
1854
1980
|
return String(n).padStart(2, "0");
|
|
1855
1981
|
}
|
|
@@ -2021,6 +2147,7 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
2021
2147
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
2022
2148
|
const calId = this.getRscaleCalendarId();
|
|
2023
2149
|
if (!calId) return this._allFallback(iterator);
|
|
2150
|
+
this.assertRscaleCalendarSupported(calId);
|
|
2024
2151
|
const dates = [];
|
|
2025
2152
|
let iterationCount = 0;
|
|
2026
2153
|
const start = this.originalDtstart;
|
|
@@ -2249,6 +2376,8 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
2249
2376
|
return this._allFallback(iterator);
|
|
2250
2377
|
}
|
|
2251
2378
|
};
|
|
2379
|
+
_RRuleTemporal.rscaleCalendarSupport = {};
|
|
2380
|
+
var RRuleTemporal = _RRuleTemporal;
|
|
2252
2381
|
|
|
2253
2382
|
export {
|
|
2254
2383
|
RRuleTemporal
|
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,18 @@ var __spreadValues = (a, b) => {
|
|
|
20
20
|
return a;
|
|
21
21
|
};
|
|
22
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
23
35
|
var __export = (target, all) => {
|
|
24
36
|
for (var name in all)
|
|
25
37
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -209,7 +221,7 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
209
221
|
}
|
|
210
222
|
return opts;
|
|
211
223
|
}
|
|
212
|
-
var
|
|
224
|
+
var _RRuleTemporal = class _RRuleTemporal {
|
|
213
225
|
constructor(params) {
|
|
214
226
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
215
227
|
let manual;
|
|
@@ -699,6 +711,99 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
699
711
|
options() {
|
|
700
712
|
return this.opts;
|
|
701
713
|
}
|
|
714
|
+
cloneOptions() {
|
|
715
|
+
const _a = this.opts, {
|
|
716
|
+
byHour,
|
|
717
|
+
byMinute,
|
|
718
|
+
bySecond,
|
|
719
|
+
byDay,
|
|
720
|
+
byMonth,
|
|
721
|
+
byMonthDay,
|
|
722
|
+
byYearDay,
|
|
723
|
+
byWeekNo,
|
|
724
|
+
bySetPos,
|
|
725
|
+
rDate,
|
|
726
|
+
exDate
|
|
727
|
+
} = _a, rest = __objRest(_a, [
|
|
728
|
+
"byHour",
|
|
729
|
+
"byMinute",
|
|
730
|
+
"bySecond",
|
|
731
|
+
"byDay",
|
|
732
|
+
"byMonth",
|
|
733
|
+
"byMonthDay",
|
|
734
|
+
"byYearDay",
|
|
735
|
+
"byWeekNo",
|
|
736
|
+
"bySetPos",
|
|
737
|
+
"rDate",
|
|
738
|
+
"exDate"
|
|
739
|
+
]);
|
|
740
|
+
return __spreadProps(__spreadValues({}, rest), {
|
|
741
|
+
byHour: byHour ? [...byHour] : void 0,
|
|
742
|
+
byMinute: byMinute ? [...byMinute] : void 0,
|
|
743
|
+
bySecond: bySecond ? [...bySecond] : void 0,
|
|
744
|
+
byDay: byDay ? [...byDay] : void 0,
|
|
745
|
+
byMonth: byMonth ? [...byMonth] : void 0,
|
|
746
|
+
byMonthDay: byMonthDay ? [...byMonthDay] : void 0,
|
|
747
|
+
byYearDay: byYearDay ? [...byYearDay] : void 0,
|
|
748
|
+
byWeekNo: byWeekNo ? [...byWeekNo] : void 0,
|
|
749
|
+
bySetPos: bySetPos ? [...bySetPos] : void 0,
|
|
750
|
+
rDate: rDate ? [...rDate] : void 0,
|
|
751
|
+
exDate: exDate ? [...exDate] : void 0
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
cloneUpdateOptions(updates) {
|
|
755
|
+
const cloned = {};
|
|
756
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byHour")) {
|
|
757
|
+
cloned.byHour = Array.isArray(updates.byHour) ? [...updates.byHour] : updates.byHour;
|
|
758
|
+
}
|
|
759
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byMinute")) {
|
|
760
|
+
cloned.byMinute = Array.isArray(updates.byMinute) ? [...updates.byMinute] : updates.byMinute;
|
|
761
|
+
}
|
|
762
|
+
if (Object.prototype.hasOwnProperty.call(updates, "bySecond")) {
|
|
763
|
+
cloned.bySecond = Array.isArray(updates.bySecond) ? [...updates.bySecond] : updates.bySecond;
|
|
764
|
+
}
|
|
765
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byDay")) {
|
|
766
|
+
cloned.byDay = Array.isArray(updates.byDay) ? [...updates.byDay] : updates.byDay;
|
|
767
|
+
}
|
|
768
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byMonth")) {
|
|
769
|
+
cloned.byMonth = Array.isArray(updates.byMonth) ? [...updates.byMonth] : updates.byMonth;
|
|
770
|
+
}
|
|
771
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byMonthDay")) {
|
|
772
|
+
cloned.byMonthDay = Array.isArray(updates.byMonthDay) ? [...updates.byMonthDay] : updates.byMonthDay;
|
|
773
|
+
}
|
|
774
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byYearDay")) {
|
|
775
|
+
cloned.byYearDay = Array.isArray(updates.byYearDay) ? [...updates.byYearDay] : updates.byYearDay;
|
|
776
|
+
}
|
|
777
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byWeekNo")) {
|
|
778
|
+
cloned.byWeekNo = Array.isArray(updates.byWeekNo) ? [...updates.byWeekNo] : updates.byWeekNo;
|
|
779
|
+
}
|
|
780
|
+
if (Object.prototype.hasOwnProperty.call(updates, "bySetPos")) {
|
|
781
|
+
cloned.bySetPos = Array.isArray(updates.bySetPos) ? [...updates.bySetPos] : updates.bySetPos;
|
|
782
|
+
}
|
|
783
|
+
if (Object.prototype.hasOwnProperty.call(updates, "rDate")) {
|
|
784
|
+
cloned.rDate = Array.isArray(updates.rDate) ? [...updates.rDate] : updates.rDate;
|
|
785
|
+
}
|
|
786
|
+
if (Object.prototype.hasOwnProperty.call(updates, "exDate")) {
|
|
787
|
+
cloned.exDate = Array.isArray(updates.exDate) ? [...updates.exDate] : updates.exDate;
|
|
788
|
+
}
|
|
789
|
+
return cloned;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Create a new {@link RRuleTemporal} instance with modified options while keeping the current one unchanged.
|
|
793
|
+
*
|
|
794
|
+
* @example
|
|
795
|
+
* ```ts
|
|
796
|
+
* const updated = rule.with({byMonthDay: [3]});
|
|
797
|
+
* ```
|
|
798
|
+
*/
|
|
799
|
+
with(updates) {
|
|
800
|
+
var _a, _b;
|
|
801
|
+
const merged = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, this.cloneOptions()), updates), this.cloneUpdateOptions(updates)), {
|
|
802
|
+
tzid: (_a = updates.tzid) != null ? _a : this.opts.tzid,
|
|
803
|
+
dtstart: (_b = updates.dtstart) != null ? _b : this.opts.dtstart
|
|
804
|
+
});
|
|
805
|
+
return new _RRuleTemporal(merged);
|
|
806
|
+
}
|
|
702
807
|
addDtstartIfNeeded(dates, iterator) {
|
|
703
808
|
if (this.includeDtstart && !this.matchesAll(this.originalDtstart)) {
|
|
704
809
|
if (iterator && this.isExcluded(this.originalDtstart)) {
|
|
@@ -1871,6 +1976,27 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
1871
1976
|
const r = ((_a = this.opts.rscale) == null ? void 0 : _a.toUpperCase()) || "";
|
|
1872
1977
|
return map[r] || null;
|
|
1873
1978
|
}
|
|
1979
|
+
assertRscaleCalendarSupported(calId) {
|
|
1980
|
+
if (calId === "gregory" || calId === "iso8601") return;
|
|
1981
|
+
const cached = _RRuleTemporal.rscaleCalendarSupport[calId];
|
|
1982
|
+
if (cached === true) return;
|
|
1983
|
+
if (cached === false) {
|
|
1984
|
+
throw new Error(`RSCALE=${this.opts.rscale} is not supported by the current Temporal/Intl implementation`);
|
|
1985
|
+
}
|
|
1986
|
+
let supported = true;
|
|
1987
|
+
try {
|
|
1988
|
+
const probe = import_polyfill.Temporal.ZonedDateTime.from("2000-01-01T00:00:00+00:00[UTC]").withCalendar(calId);
|
|
1989
|
+
void probe.year;
|
|
1990
|
+
void probe.monthCode;
|
|
1991
|
+
void probe.day;
|
|
1992
|
+
} catch (e) {
|
|
1993
|
+
supported = false;
|
|
1994
|
+
}
|
|
1995
|
+
_RRuleTemporal.rscaleCalendarSupport[calId] = supported;
|
|
1996
|
+
if (!supported) {
|
|
1997
|
+
throw new Error(`RSCALE=${this.opts.rscale} is not supported by the current Temporal/Intl implementation`);
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
1874
2000
|
pad2(n) {
|
|
1875
2001
|
return String(n).padStart(2, "0");
|
|
1876
2002
|
}
|
|
@@ -2042,6 +2168,7 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
2042
2168
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
2043
2169
|
const calId = this.getRscaleCalendarId();
|
|
2044
2170
|
if (!calId) return this._allFallback(iterator);
|
|
2171
|
+
this.assertRscaleCalendarSupported(calId);
|
|
2045
2172
|
const dates = [];
|
|
2046
2173
|
let iterationCount = 0;
|
|
2047
2174
|
const start = this.originalDtstart;
|
|
@@ -2270,6 +2397,8 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
2270
2397
|
return this._allFallback(iterator);
|
|
2271
2398
|
}
|
|
2272
2399
|
};
|
|
2400
|
+
_RRuleTemporal.rscaleCalendarSupport = {};
|
|
2401
|
+
var RRuleTemporal = _RRuleTemporal;
|
|
2273
2402
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2274
2403
|
0 && (module.exports = {
|
|
2275
2404
|
RRuleTemporal
|
package/dist/index.d.cts
CHANGED
|
@@ -73,6 +73,7 @@ declare class RRuleTemporal {
|
|
|
73
73
|
private readonly opts;
|
|
74
74
|
private readonly maxIterations;
|
|
75
75
|
private readonly includeDtstart;
|
|
76
|
+
private static readonly rscaleCalendarSupport;
|
|
76
77
|
constructor(params: RRuleOptions);
|
|
77
78
|
private sanitizeNumericArray;
|
|
78
79
|
private sanitizeByDay;
|
|
@@ -98,6 +99,17 @@ declare class RRuleTemporal {
|
|
|
98
99
|
private getIsoWeekInfo;
|
|
99
100
|
private matchesByWeekNo;
|
|
100
101
|
options(): ManualOpts;
|
|
102
|
+
private cloneOptions;
|
|
103
|
+
private cloneUpdateOptions;
|
|
104
|
+
/**
|
|
105
|
+
* Create a new {@link RRuleTemporal} instance with modified options while keeping the current one unchanged.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const updated = rule.with({byMonthDay: [3]});
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
with(updates: Partial<ManualOpts>): RRuleTemporal;
|
|
101
113
|
private addDtstartIfNeeded;
|
|
102
114
|
private processOccurrences;
|
|
103
115
|
/**
|
|
@@ -211,6 +223,7 @@ declare class RRuleTemporal {
|
|
|
211
223
|
*/
|
|
212
224
|
private generateOccurrencesForWeekInYear;
|
|
213
225
|
private getRscaleCalendarId;
|
|
226
|
+
private assertRscaleCalendarSupported;
|
|
214
227
|
private pad2;
|
|
215
228
|
private monthMatchesToken;
|
|
216
229
|
private monthsOfYear;
|
package/dist/index.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ declare class RRuleTemporal {
|
|
|
73
73
|
private readonly opts;
|
|
74
74
|
private readonly maxIterations;
|
|
75
75
|
private readonly includeDtstart;
|
|
76
|
+
private static readonly rscaleCalendarSupport;
|
|
76
77
|
constructor(params: RRuleOptions);
|
|
77
78
|
private sanitizeNumericArray;
|
|
78
79
|
private sanitizeByDay;
|
|
@@ -98,6 +99,17 @@ declare class RRuleTemporal {
|
|
|
98
99
|
private getIsoWeekInfo;
|
|
99
100
|
private matchesByWeekNo;
|
|
100
101
|
options(): ManualOpts;
|
|
102
|
+
private cloneOptions;
|
|
103
|
+
private cloneUpdateOptions;
|
|
104
|
+
/**
|
|
105
|
+
* Create a new {@link RRuleTemporal} instance with modified options while keeping the current one unchanged.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const updated = rule.with({byMonthDay: [3]});
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
with(updates: Partial<ManualOpts>): RRuleTemporal;
|
|
101
113
|
private addDtstartIfNeeded;
|
|
102
114
|
private processOccurrences;
|
|
103
115
|
/**
|
|
@@ -211,6 +223,7 @@ declare class RRuleTemporal {
|
|
|
211
223
|
*/
|
|
212
224
|
private generateOccurrencesForWeekInYear;
|
|
213
225
|
private getRscaleCalendarId;
|
|
226
|
+
private assertRscaleCalendarSupported;
|
|
214
227
|
private pad2;
|
|
215
228
|
private monthMatchesToken;
|
|
216
229
|
private monthsOfYear;
|
package/dist/index.js
CHANGED
package/dist/totext.cjs
CHANGED
|
@@ -20,6 +20,18 @@ var __spreadValues = (a, b) => {
|
|
|
20
20
|
return a;
|
|
21
21
|
};
|
|
22
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
23
35
|
var __export = (target, all) => {
|
|
24
36
|
for (var name in all)
|
|
25
37
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -211,7 +223,7 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
211
223
|
}
|
|
212
224
|
return opts;
|
|
213
225
|
}
|
|
214
|
-
var
|
|
226
|
+
var _RRuleTemporal = class _RRuleTemporal {
|
|
215
227
|
constructor(params) {
|
|
216
228
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
217
229
|
let manual;
|
|
@@ -701,6 +713,99 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
701
713
|
options() {
|
|
702
714
|
return this.opts;
|
|
703
715
|
}
|
|
716
|
+
cloneOptions() {
|
|
717
|
+
const _a = this.opts, {
|
|
718
|
+
byHour,
|
|
719
|
+
byMinute,
|
|
720
|
+
bySecond,
|
|
721
|
+
byDay,
|
|
722
|
+
byMonth,
|
|
723
|
+
byMonthDay,
|
|
724
|
+
byYearDay,
|
|
725
|
+
byWeekNo,
|
|
726
|
+
bySetPos,
|
|
727
|
+
rDate,
|
|
728
|
+
exDate
|
|
729
|
+
} = _a, rest = __objRest(_a, [
|
|
730
|
+
"byHour",
|
|
731
|
+
"byMinute",
|
|
732
|
+
"bySecond",
|
|
733
|
+
"byDay",
|
|
734
|
+
"byMonth",
|
|
735
|
+
"byMonthDay",
|
|
736
|
+
"byYearDay",
|
|
737
|
+
"byWeekNo",
|
|
738
|
+
"bySetPos",
|
|
739
|
+
"rDate",
|
|
740
|
+
"exDate"
|
|
741
|
+
]);
|
|
742
|
+
return __spreadProps(__spreadValues({}, rest), {
|
|
743
|
+
byHour: byHour ? [...byHour] : void 0,
|
|
744
|
+
byMinute: byMinute ? [...byMinute] : void 0,
|
|
745
|
+
bySecond: bySecond ? [...bySecond] : void 0,
|
|
746
|
+
byDay: byDay ? [...byDay] : void 0,
|
|
747
|
+
byMonth: byMonth ? [...byMonth] : void 0,
|
|
748
|
+
byMonthDay: byMonthDay ? [...byMonthDay] : void 0,
|
|
749
|
+
byYearDay: byYearDay ? [...byYearDay] : void 0,
|
|
750
|
+
byWeekNo: byWeekNo ? [...byWeekNo] : void 0,
|
|
751
|
+
bySetPos: bySetPos ? [...bySetPos] : void 0,
|
|
752
|
+
rDate: rDate ? [...rDate] : void 0,
|
|
753
|
+
exDate: exDate ? [...exDate] : void 0
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
cloneUpdateOptions(updates) {
|
|
757
|
+
const cloned = {};
|
|
758
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byHour")) {
|
|
759
|
+
cloned.byHour = Array.isArray(updates.byHour) ? [...updates.byHour] : updates.byHour;
|
|
760
|
+
}
|
|
761
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byMinute")) {
|
|
762
|
+
cloned.byMinute = Array.isArray(updates.byMinute) ? [...updates.byMinute] : updates.byMinute;
|
|
763
|
+
}
|
|
764
|
+
if (Object.prototype.hasOwnProperty.call(updates, "bySecond")) {
|
|
765
|
+
cloned.bySecond = Array.isArray(updates.bySecond) ? [...updates.bySecond] : updates.bySecond;
|
|
766
|
+
}
|
|
767
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byDay")) {
|
|
768
|
+
cloned.byDay = Array.isArray(updates.byDay) ? [...updates.byDay] : updates.byDay;
|
|
769
|
+
}
|
|
770
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byMonth")) {
|
|
771
|
+
cloned.byMonth = Array.isArray(updates.byMonth) ? [...updates.byMonth] : updates.byMonth;
|
|
772
|
+
}
|
|
773
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byMonthDay")) {
|
|
774
|
+
cloned.byMonthDay = Array.isArray(updates.byMonthDay) ? [...updates.byMonthDay] : updates.byMonthDay;
|
|
775
|
+
}
|
|
776
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byYearDay")) {
|
|
777
|
+
cloned.byYearDay = Array.isArray(updates.byYearDay) ? [...updates.byYearDay] : updates.byYearDay;
|
|
778
|
+
}
|
|
779
|
+
if (Object.prototype.hasOwnProperty.call(updates, "byWeekNo")) {
|
|
780
|
+
cloned.byWeekNo = Array.isArray(updates.byWeekNo) ? [...updates.byWeekNo] : updates.byWeekNo;
|
|
781
|
+
}
|
|
782
|
+
if (Object.prototype.hasOwnProperty.call(updates, "bySetPos")) {
|
|
783
|
+
cloned.bySetPos = Array.isArray(updates.bySetPos) ? [...updates.bySetPos] : updates.bySetPos;
|
|
784
|
+
}
|
|
785
|
+
if (Object.prototype.hasOwnProperty.call(updates, "rDate")) {
|
|
786
|
+
cloned.rDate = Array.isArray(updates.rDate) ? [...updates.rDate] : updates.rDate;
|
|
787
|
+
}
|
|
788
|
+
if (Object.prototype.hasOwnProperty.call(updates, "exDate")) {
|
|
789
|
+
cloned.exDate = Array.isArray(updates.exDate) ? [...updates.exDate] : updates.exDate;
|
|
790
|
+
}
|
|
791
|
+
return cloned;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Create a new {@link RRuleTemporal} instance with modified options while keeping the current one unchanged.
|
|
795
|
+
*
|
|
796
|
+
* @example
|
|
797
|
+
* ```ts
|
|
798
|
+
* const updated = rule.with({byMonthDay: [3]});
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
with(updates) {
|
|
802
|
+
var _a, _b;
|
|
803
|
+
const merged = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, this.cloneOptions()), updates), this.cloneUpdateOptions(updates)), {
|
|
804
|
+
tzid: (_a = updates.tzid) != null ? _a : this.opts.tzid,
|
|
805
|
+
dtstart: (_b = updates.dtstart) != null ? _b : this.opts.dtstart
|
|
806
|
+
});
|
|
807
|
+
return new _RRuleTemporal(merged);
|
|
808
|
+
}
|
|
704
809
|
addDtstartIfNeeded(dates, iterator) {
|
|
705
810
|
if (this.includeDtstart && !this.matchesAll(this.originalDtstart)) {
|
|
706
811
|
if (iterator && this.isExcluded(this.originalDtstart)) {
|
|
@@ -1873,6 +1978,27 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
1873
1978
|
const r = ((_a = this.opts.rscale) == null ? void 0 : _a.toUpperCase()) || "";
|
|
1874
1979
|
return map[r] || null;
|
|
1875
1980
|
}
|
|
1981
|
+
assertRscaleCalendarSupported(calId) {
|
|
1982
|
+
if (calId === "gregory" || calId === "iso8601") return;
|
|
1983
|
+
const cached = _RRuleTemporal.rscaleCalendarSupport[calId];
|
|
1984
|
+
if (cached === true) return;
|
|
1985
|
+
if (cached === false) {
|
|
1986
|
+
throw new Error(`RSCALE=${this.opts.rscale} is not supported by the current Temporal/Intl implementation`);
|
|
1987
|
+
}
|
|
1988
|
+
let supported = true;
|
|
1989
|
+
try {
|
|
1990
|
+
const probe = import_polyfill.Temporal.ZonedDateTime.from("2000-01-01T00:00:00+00:00[UTC]").withCalendar(calId);
|
|
1991
|
+
void probe.year;
|
|
1992
|
+
void probe.monthCode;
|
|
1993
|
+
void probe.day;
|
|
1994
|
+
} catch (e) {
|
|
1995
|
+
supported = false;
|
|
1996
|
+
}
|
|
1997
|
+
_RRuleTemporal.rscaleCalendarSupport[calId] = supported;
|
|
1998
|
+
if (!supported) {
|
|
1999
|
+
throw new Error(`RSCALE=${this.opts.rscale} is not supported by the current Temporal/Intl implementation`);
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
1876
2002
|
pad2(n) {
|
|
1877
2003
|
return String(n).padStart(2, "0");
|
|
1878
2004
|
}
|
|
@@ -2044,6 +2170,7 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
2044
2170
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
2045
2171
|
const calId = this.getRscaleCalendarId();
|
|
2046
2172
|
if (!calId) return this._allFallback(iterator);
|
|
2173
|
+
this.assertRscaleCalendarSupported(calId);
|
|
2047
2174
|
const dates = [];
|
|
2048
2175
|
let iterationCount = 0;
|
|
2049
2176
|
const start = this.originalDtstart;
|
|
@@ -2272,6 +2399,8 @@ var RRuleTemporal = class _RRuleTemporal {
|
|
|
2272
2399
|
return this._allFallback(iterator);
|
|
2273
2400
|
}
|
|
2274
2401
|
};
|
|
2402
|
+
_RRuleTemporal.rscaleCalendarSupport = {};
|
|
2403
|
+
var RRuleTemporal = _RRuleTemporal;
|
|
2275
2404
|
|
|
2276
2405
|
// src/totext.ts
|
|
2277
2406
|
var en = {
|
package/dist/totext.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrule-temporal",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.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",
|