rrule-temporal 1.4.0 → 1.4.2
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 +13 -0
- package/dist/{chunk-76UOKZYT.js → chunk-EHMOE4GK.js} +25 -3
- package/dist/index.cjs +25 -3
- package/dist/index.js +1 -1
- package/dist/totext.cjs +50 -16
- package/dist/totext.js +26 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# RRule Temporal
|
|
2
2
|
|
|
3
|
+
> This library is sponsored by [PostalForm 💌](https://postalform.com/?utm_source=github&utm_medium=readme&utm_campaign=rrule-temporal) — upload a PDF and we print + mail it via USPS (no printer or stamps needed). The only mailing platform for AI Agents via MCP, and the easiest one for humans!
|
|
4
|
+
|
|
3
5
|
The first and only fully compliant Recurrence rule ([RFC-5545](https://www.rfc-editor.org/rfc/rfc5545.html)) processing JS/TS library built on the Temporal API, now with support for [RFC-7529](https://www.rfc-editor.org/rfc/rfc7529.html) (RSCALE / SKIP) for non-Gregorian calendars.
|
|
4
6
|
The library accepts the familiar `RRULE` format and returns
|
|
5
7
|
`Temporal.ZonedDateTime` instances for easy time‑zone aware scheduling.
|
|
@@ -55,6 +57,11 @@ This is useful when:
|
|
|
55
57
|
- Storing recurrence patterns separately from start dates in databases
|
|
56
58
|
- Building rules programmatically from user input
|
|
57
59
|
|
|
60
|
+
Note on `UNTIL` (RFC 5545): if `DTSTART` is a DATE-TIME with a `TZID` or UTC (`Z`),
|
|
61
|
+
`UNTIL` must be a DATE-TIME in UTC (trailing `Z`). If `DTSTART` is `VALUE=DATE`,
|
|
62
|
+
`UNTIL` must be a DATE (no time). Floating DATE-TIME rules (no `TZID`, no `Z`)
|
|
63
|
+
allow a floating `UNTIL`.
|
|
64
|
+
|
|
58
65
|
## Creating a rule with options
|
|
59
66
|
|
|
60
67
|
Instead of a full ICS string you can supply the recurrence parameters directly:
|
|
@@ -377,3 +384,9 @@ const appOccurrences = rawOccurrences.map((zdt) =>
|
|
|
377
384
|
```
|
|
378
385
|
|
|
379
386
|
Both approaches preserve the original calendar, time-zone and nanosecond accuracy.
|
|
387
|
+
|
|
388
|
+
## Sponsor
|
|
389
|
+
|
|
390
|
+
If this library saves you time, sponsorship helps keep it maintained.
|
|
391
|
+
|
|
392
|
+
Primary sponsor: [PostalForm](https://postalform.com/?utm_source=github&utm_medium=readme&utm_campaign=rrule-temporal)
|
|
@@ -86,6 +86,9 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
86
86
|
const unfoldedInput = unfoldLine(input).trim();
|
|
87
87
|
let parsedDtstart;
|
|
88
88
|
let tzid = targetTimezone;
|
|
89
|
+
let dtstartValueType = "DATE-TIME";
|
|
90
|
+
let dtstartHasTzid = false;
|
|
91
|
+
let dtstartIsUtc = false;
|
|
89
92
|
let rruleLine;
|
|
90
93
|
let exDate = [];
|
|
91
94
|
let rDate = [];
|
|
@@ -98,8 +101,12 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
98
101
|
const dtMatch = dtLine.match(/DTSTART(?:;VALUE=([^;]+))?(?:;TZID=([^:]+))?:(.+)/i);
|
|
99
102
|
if (!dtMatch) throw new Error("Invalid DTSTART in ICS snippet");
|
|
100
103
|
const [, valueType, dtTzid, dtValue] = dtMatch;
|
|
104
|
+
const normalizedValueType = (valueType || ((dtValue == null ? void 0 : dtValue.includes("T")) ? "DATE-TIME" : "DATE")).toUpperCase();
|
|
105
|
+
dtstartValueType = normalizedValueType === "DATE" ? "DATE" : "DATE-TIME";
|
|
106
|
+
dtstartHasTzid = Boolean(dtTzid);
|
|
107
|
+
dtstartIsUtc = Boolean(dtValue == null ? void 0 : dtValue.endsWith("Z"));
|
|
101
108
|
const effectiveTzid = (_b = (_a = dtTzid != null ? dtTzid : targetTimezone) != null ? _a : tzid) != null ? _b : "UTC";
|
|
102
|
-
parsedDtstart = parseIcsDateTime(dtValue, effectiveTzid,
|
|
109
|
+
parsedDtstart = parseIcsDateTime(dtValue, effectiveTzid, dtstartValueType);
|
|
103
110
|
tzid = (_e = (_d = (_c = dtTzid != null ? dtTzid : parsedDtstart.timeZoneId) != null ? _c : targetTimezone) != null ? _d : tzid) != null ? _e : "UTC";
|
|
104
111
|
rruleLine = rrLine;
|
|
105
112
|
exDate = parseDateLines(exLines, "EXDATE", tzid != null ? tzid : "UTC");
|
|
@@ -109,6 +116,9 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
109
116
|
rruleLine = unfoldedInput;
|
|
110
117
|
if (parsedDtstart) {
|
|
111
118
|
tzid = parsedDtstart.timeZoneId;
|
|
119
|
+
dtstartValueType = "DATE-TIME";
|
|
120
|
+
dtstartHasTzid = true;
|
|
121
|
+
dtstartIsUtc = parsedDtstart.timeZoneId === "UTC";
|
|
112
122
|
}
|
|
113
123
|
}
|
|
114
124
|
const parts = rruleLine ? rruleLine.replace(/^RRULE:/i, "").split(";") : [];
|
|
@@ -154,10 +164,22 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
154
164
|
opts.count = parseInt(val, 10);
|
|
155
165
|
break;
|
|
156
166
|
case "UNTIL": {
|
|
157
|
-
|
|
158
|
-
if (
|
|
167
|
+
const untilHasTime = val.includes("T");
|
|
168
|
+
if (dtstartValueType === "DATE") {
|
|
169
|
+
if (untilHasTime) {
|
|
170
|
+
throw new Error("UNTIL rule part MUST have the same value type as DTSTART");
|
|
171
|
+
}
|
|
172
|
+
opts.until = parseIcsDateTime(val, tzid || "UTC", "DATE");
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
if (!untilHasTime) {
|
|
176
|
+
throw new Error("UNTIL rule part MUST have the same value type as DTSTART");
|
|
177
|
+
}
|
|
178
|
+
const requiresUtc = dtstartHasTzid || dtstartIsUtc;
|
|
179
|
+
if (requiresUtc && !val.endsWith("Z")) {
|
|
159
180
|
throw new Error("UNTIL rule part MUST always be specified as a date with UTC time");
|
|
160
181
|
}
|
|
182
|
+
opts.until = parseIcsDateTime(val, tzid || "UTC", "DATE-TIME");
|
|
161
183
|
break;
|
|
162
184
|
}
|
|
163
185
|
case "BYHOUR":
|
package/dist/index.cjs
CHANGED
|
@@ -107,6 +107,9 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
107
107
|
const unfoldedInput = unfoldLine(input).trim();
|
|
108
108
|
let parsedDtstart;
|
|
109
109
|
let tzid = targetTimezone;
|
|
110
|
+
let dtstartValueType = "DATE-TIME";
|
|
111
|
+
let dtstartHasTzid = false;
|
|
112
|
+
let dtstartIsUtc = false;
|
|
110
113
|
let rruleLine;
|
|
111
114
|
let exDate = [];
|
|
112
115
|
let rDate = [];
|
|
@@ -119,8 +122,12 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
119
122
|
const dtMatch = dtLine.match(/DTSTART(?:;VALUE=([^;]+))?(?:;TZID=([^:]+))?:(.+)/i);
|
|
120
123
|
if (!dtMatch) throw new Error("Invalid DTSTART in ICS snippet");
|
|
121
124
|
const [, valueType, dtTzid, dtValue] = dtMatch;
|
|
125
|
+
const normalizedValueType = (valueType || ((dtValue == null ? void 0 : dtValue.includes("T")) ? "DATE-TIME" : "DATE")).toUpperCase();
|
|
126
|
+
dtstartValueType = normalizedValueType === "DATE" ? "DATE" : "DATE-TIME";
|
|
127
|
+
dtstartHasTzid = Boolean(dtTzid);
|
|
128
|
+
dtstartIsUtc = Boolean(dtValue == null ? void 0 : dtValue.endsWith("Z"));
|
|
122
129
|
const effectiveTzid = (_b = (_a = dtTzid != null ? dtTzid : targetTimezone) != null ? _a : tzid) != null ? _b : "UTC";
|
|
123
|
-
parsedDtstart = parseIcsDateTime(dtValue, effectiveTzid,
|
|
130
|
+
parsedDtstart = parseIcsDateTime(dtValue, effectiveTzid, dtstartValueType);
|
|
124
131
|
tzid = (_e = (_d = (_c = dtTzid != null ? dtTzid : parsedDtstart.timeZoneId) != null ? _c : targetTimezone) != null ? _d : tzid) != null ? _e : "UTC";
|
|
125
132
|
rruleLine = rrLine;
|
|
126
133
|
exDate = parseDateLines(exLines, "EXDATE", tzid != null ? tzid : "UTC");
|
|
@@ -130,6 +137,9 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
130
137
|
rruleLine = unfoldedInput;
|
|
131
138
|
if (parsedDtstart) {
|
|
132
139
|
tzid = parsedDtstart.timeZoneId;
|
|
140
|
+
dtstartValueType = "DATE-TIME";
|
|
141
|
+
dtstartHasTzid = true;
|
|
142
|
+
dtstartIsUtc = parsedDtstart.timeZoneId === "UTC";
|
|
133
143
|
}
|
|
134
144
|
}
|
|
135
145
|
const parts = rruleLine ? rruleLine.replace(/^RRULE:/i, "").split(";") : [];
|
|
@@ -175,10 +185,22 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
175
185
|
opts.count = parseInt(val, 10);
|
|
176
186
|
break;
|
|
177
187
|
case "UNTIL": {
|
|
178
|
-
|
|
179
|
-
if (
|
|
188
|
+
const untilHasTime = val.includes("T");
|
|
189
|
+
if (dtstartValueType === "DATE") {
|
|
190
|
+
if (untilHasTime) {
|
|
191
|
+
throw new Error("UNTIL rule part MUST have the same value type as DTSTART");
|
|
192
|
+
}
|
|
193
|
+
opts.until = parseIcsDateTime(val, tzid || "UTC", "DATE");
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
if (!untilHasTime) {
|
|
197
|
+
throw new Error("UNTIL rule part MUST have the same value type as DTSTART");
|
|
198
|
+
}
|
|
199
|
+
const requiresUtc = dtstartHasTzid || dtstartIsUtc;
|
|
200
|
+
if (requiresUtc && !val.endsWith("Z")) {
|
|
180
201
|
throw new Error("UNTIL rule part MUST always be specified as a date with UTC time");
|
|
181
202
|
}
|
|
203
|
+
opts.until = parseIcsDateTime(val, tzid || "UTC", "DATE-TIME");
|
|
182
204
|
break;
|
|
183
205
|
}
|
|
184
206
|
case "BYHOUR":
|
package/dist/index.js
CHANGED
package/dist/totext.cjs
CHANGED
|
@@ -109,6 +109,9 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
109
109
|
const unfoldedInput = unfoldLine(input).trim();
|
|
110
110
|
let parsedDtstart;
|
|
111
111
|
let tzid = targetTimezone;
|
|
112
|
+
let dtstartValueType = "DATE-TIME";
|
|
113
|
+
let dtstartHasTzid = false;
|
|
114
|
+
let dtstartIsUtc = false;
|
|
112
115
|
let rruleLine;
|
|
113
116
|
let exDate = [];
|
|
114
117
|
let rDate = [];
|
|
@@ -121,8 +124,12 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
121
124
|
const dtMatch = dtLine.match(/DTSTART(?:;VALUE=([^;]+))?(?:;TZID=([^:]+))?:(.+)/i);
|
|
122
125
|
if (!dtMatch) throw new Error("Invalid DTSTART in ICS snippet");
|
|
123
126
|
const [, valueType, dtTzid, dtValue] = dtMatch;
|
|
127
|
+
const normalizedValueType = (valueType || ((dtValue == null ? void 0 : dtValue.includes("T")) ? "DATE-TIME" : "DATE")).toUpperCase();
|
|
128
|
+
dtstartValueType = normalizedValueType === "DATE" ? "DATE" : "DATE-TIME";
|
|
129
|
+
dtstartHasTzid = Boolean(dtTzid);
|
|
130
|
+
dtstartIsUtc = Boolean(dtValue == null ? void 0 : dtValue.endsWith("Z"));
|
|
124
131
|
const effectiveTzid = (_b = (_a = dtTzid != null ? dtTzid : targetTimezone) != null ? _a : tzid) != null ? _b : "UTC";
|
|
125
|
-
parsedDtstart = parseIcsDateTime(dtValue, effectiveTzid,
|
|
132
|
+
parsedDtstart = parseIcsDateTime(dtValue, effectiveTzid, dtstartValueType);
|
|
126
133
|
tzid = (_e = (_d = (_c = dtTzid != null ? dtTzid : parsedDtstart.timeZoneId) != null ? _c : targetTimezone) != null ? _d : tzid) != null ? _e : "UTC";
|
|
127
134
|
rruleLine = rrLine;
|
|
128
135
|
exDate = parseDateLines(exLines, "EXDATE", tzid != null ? tzid : "UTC");
|
|
@@ -132,6 +139,9 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
132
139
|
rruleLine = unfoldedInput;
|
|
133
140
|
if (parsedDtstart) {
|
|
134
141
|
tzid = parsedDtstart.timeZoneId;
|
|
142
|
+
dtstartValueType = "DATE-TIME";
|
|
143
|
+
dtstartHasTzid = true;
|
|
144
|
+
dtstartIsUtc = parsedDtstart.timeZoneId === "UTC";
|
|
135
145
|
}
|
|
136
146
|
}
|
|
137
147
|
const parts = rruleLine ? rruleLine.replace(/^RRULE:/i, "").split(";") : [];
|
|
@@ -177,10 +187,22 @@ function parseRRuleString(input, targetTimezone, dtstart) {
|
|
|
177
187
|
opts.count = parseInt(val, 10);
|
|
178
188
|
break;
|
|
179
189
|
case "UNTIL": {
|
|
180
|
-
|
|
181
|
-
if (
|
|
190
|
+
const untilHasTime = val.includes("T");
|
|
191
|
+
if (dtstartValueType === "DATE") {
|
|
192
|
+
if (untilHasTime) {
|
|
193
|
+
throw new Error("UNTIL rule part MUST have the same value type as DTSTART");
|
|
194
|
+
}
|
|
195
|
+
opts.until = parseIcsDateTime(val, tzid || "UTC", "DATE");
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
if (!untilHasTime) {
|
|
199
|
+
throw new Error("UNTIL rule part MUST have the same value type as DTSTART");
|
|
200
|
+
}
|
|
201
|
+
const requiresUtc = dtstartHasTzid || dtstartIsUtc;
|
|
202
|
+
if (requiresUtc && !val.endsWith("Z")) {
|
|
182
203
|
throw new Error("UNTIL rule part MUST always be specified as a date with UTC time");
|
|
183
204
|
}
|
|
205
|
+
opts.until = parseIcsDateTime(val, tzid || "UTC", "DATE-TIME");
|
|
184
206
|
break;
|
|
185
207
|
}
|
|
186
208
|
case "BYHOUR":
|
|
@@ -3014,6 +3036,10 @@ function formatTime(hour, minute = 0, second = 0) {
|
|
|
3014
3036
|
}
|
|
3015
3037
|
return `${hr12} ${ampm}`;
|
|
3016
3038
|
}
|
|
3039
|
+
function weekdayTokenFromZdt(zdt) {
|
|
3040
|
+
const tokens = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"];
|
|
3041
|
+
return tokens[zdt.dayOfWeek - 1];
|
|
3042
|
+
}
|
|
3017
3043
|
function tzAbbreviation(zdt) {
|
|
3018
3044
|
const parts = new Intl.DateTimeFormat("en-US", {
|
|
3019
3045
|
timeZone: zdt.timeZoneId,
|
|
@@ -3046,6 +3072,14 @@ function toText(input, locale) {
|
|
|
3046
3072
|
rDate,
|
|
3047
3073
|
exDate
|
|
3048
3074
|
} = opts;
|
|
3075
|
+
const dayOrLarger = freq === "YEARLY" || freq === "MONTHLY" || freq === "WEEKLY" || freq === "DAILY";
|
|
3076
|
+
const hasExplicitTime = Boolean(byHour || byMinute || bySecond);
|
|
3077
|
+
const dtstartHasTime = opts.dtstart.hour !== 0 || opts.dtstart.minute !== 0 || opts.dtstart.second !== 0;
|
|
3078
|
+
const shouldDefaultTime = dayOrLarger && (hasExplicitTime || dtstartHasTime);
|
|
3079
|
+
const textByDay = byDay != null ? byDay : freq === "WEEKLY" ? [weekdayTokenFromZdt(opts.dtstart)] : void 0;
|
|
3080
|
+
const textByHour = byHour != null ? byHour : shouldDefaultTime ? [opts.dtstart.hour] : void 0;
|
|
3081
|
+
const textByMinute = textByHour ? byMinute != null ? byMinute : [opts.dtstart.minute] : byMinute;
|
|
3082
|
+
const textBySecond = textByHour ? bySecond != null ? bySecond : [opts.dtstart.second] : bySecond;
|
|
3049
3083
|
const parts = [data.words.every];
|
|
3050
3084
|
const baseKey = {
|
|
3051
3085
|
YEARLY: "year",
|
|
@@ -3057,7 +3091,7 @@ function toText(input, locale) {
|
|
|
3057
3091
|
SECONDLY: "second"
|
|
3058
3092
|
}[freq];
|
|
3059
3093
|
const base = data.units[baseKey];
|
|
3060
|
-
const daysNormalized =
|
|
3094
|
+
const daysNormalized = textByDay == null ? void 0 : textByDay.map((d) => d.toUpperCase());
|
|
3061
3095
|
const isWeekdays = daysNormalized && daysNormalized.length === 5 && ["MO", "TU", "WE", "TH", "FR"].every((d) => daysNormalized.includes(d));
|
|
3062
3096
|
const isEveryday = daysNormalized && daysNormalized.length === 7 && ["MO", "TU", "WE", "TH", "FR", "SA", "SU"].every((d) => daysNormalized.includes(d));
|
|
3063
3097
|
if (freq === "WEEKLY" && interval === 1 && isWeekdays) {
|
|
@@ -3071,15 +3105,15 @@ function toText(input, locale) {
|
|
|
3071
3105
|
parts.push(base.singular);
|
|
3072
3106
|
}
|
|
3073
3107
|
}
|
|
3074
|
-
if (freq === "WEEKLY" &&
|
|
3108
|
+
if (freq === "WEEKLY" && textByDay && !isWeekdays && !isEveryday) {
|
|
3075
3109
|
parts.push(
|
|
3076
3110
|
data.words.on,
|
|
3077
|
-
list(
|
|
3111
|
+
list(textByDay, (t) => formatByDayToken(t, data), data.words.and)
|
|
3078
3112
|
);
|
|
3079
|
-
} else if (
|
|
3113
|
+
} else if (textByDay && freq !== "WEEKLY") {
|
|
3080
3114
|
parts.push(
|
|
3081
3115
|
data.words.on,
|
|
3082
|
-
list(
|
|
3116
|
+
list(textByDay, (t) => formatByDayToken(t, data), data.words.and)
|
|
3083
3117
|
);
|
|
3084
3118
|
}
|
|
3085
3119
|
if (byMonth) {
|
|
@@ -3108,18 +3142,18 @@ function toText(input, locale) {
|
|
|
3108
3142
|
list(byWeekNo, (n) => n.toString(), data.words.and)
|
|
3109
3143
|
);
|
|
3110
3144
|
}
|
|
3111
|
-
if (
|
|
3112
|
-
const minutes =
|
|
3113
|
-
const seconds =
|
|
3114
|
-
const times =
|
|
3145
|
+
if (textByHour) {
|
|
3146
|
+
const minutes = textByMinute != null ? textByMinute : [0];
|
|
3147
|
+
const seconds = textBySecond != null ? textBySecond : [0];
|
|
3148
|
+
const times = textByHour.flatMap((h) => minutes.flatMap((m) => seconds.map((s) => formatTime(h, m, s))));
|
|
3115
3149
|
parts.push(data.words.at, list(times, void 0, data.words.and));
|
|
3116
3150
|
parts.push(tzAbbreviation(opts.dtstart));
|
|
3117
3151
|
}
|
|
3118
|
-
if (!
|
|
3119
|
-
parts.push(data.words.at_minute, list(
|
|
3152
|
+
if (!textByHour && textByMinute) {
|
|
3153
|
+
parts.push(data.words.at_minute, list(textByMinute, void 0, data.words.and));
|
|
3120
3154
|
}
|
|
3121
|
-
if (!
|
|
3122
|
-
parts.push(data.words.at_second, list(
|
|
3155
|
+
if (!textByHour && !textByMinute && textBySecond) {
|
|
3156
|
+
parts.push(data.words.at_second, list(textBySecond, void 0, data.words.and));
|
|
3123
3157
|
}
|
|
3124
3158
|
if (until) {
|
|
3125
3159
|
const monthName = data.monthNames[until.month - 1];
|
package/dist/totext.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RRuleTemporal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EHMOE4GK.js";
|
|
4
4
|
|
|
5
5
|
// src/totext.ts
|
|
6
6
|
var en = {
|
|
@@ -566,6 +566,10 @@ function formatTime(hour, minute = 0, second = 0) {
|
|
|
566
566
|
}
|
|
567
567
|
return `${hr12} ${ampm}`;
|
|
568
568
|
}
|
|
569
|
+
function weekdayTokenFromZdt(zdt) {
|
|
570
|
+
const tokens = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"];
|
|
571
|
+
return tokens[zdt.dayOfWeek - 1];
|
|
572
|
+
}
|
|
569
573
|
function tzAbbreviation(zdt) {
|
|
570
574
|
const parts = new Intl.DateTimeFormat("en-US", {
|
|
571
575
|
timeZone: zdt.timeZoneId,
|
|
@@ -598,6 +602,14 @@ function toText(input, locale) {
|
|
|
598
602
|
rDate,
|
|
599
603
|
exDate
|
|
600
604
|
} = opts;
|
|
605
|
+
const dayOrLarger = freq === "YEARLY" || freq === "MONTHLY" || freq === "WEEKLY" || freq === "DAILY";
|
|
606
|
+
const hasExplicitTime = Boolean(byHour || byMinute || bySecond);
|
|
607
|
+
const dtstartHasTime = opts.dtstart.hour !== 0 || opts.dtstart.minute !== 0 || opts.dtstart.second !== 0;
|
|
608
|
+
const shouldDefaultTime = dayOrLarger && (hasExplicitTime || dtstartHasTime);
|
|
609
|
+
const textByDay = byDay != null ? byDay : freq === "WEEKLY" ? [weekdayTokenFromZdt(opts.dtstart)] : void 0;
|
|
610
|
+
const textByHour = byHour != null ? byHour : shouldDefaultTime ? [opts.dtstart.hour] : void 0;
|
|
611
|
+
const textByMinute = textByHour ? byMinute != null ? byMinute : [opts.dtstart.minute] : byMinute;
|
|
612
|
+
const textBySecond = textByHour ? bySecond != null ? bySecond : [opts.dtstart.second] : bySecond;
|
|
601
613
|
const parts = [data.words.every];
|
|
602
614
|
const baseKey = {
|
|
603
615
|
YEARLY: "year",
|
|
@@ -609,7 +621,7 @@ function toText(input, locale) {
|
|
|
609
621
|
SECONDLY: "second"
|
|
610
622
|
}[freq];
|
|
611
623
|
const base = data.units[baseKey];
|
|
612
|
-
const daysNormalized =
|
|
624
|
+
const daysNormalized = textByDay == null ? void 0 : textByDay.map((d) => d.toUpperCase());
|
|
613
625
|
const isWeekdays = daysNormalized && daysNormalized.length === 5 && ["MO", "TU", "WE", "TH", "FR"].every((d) => daysNormalized.includes(d));
|
|
614
626
|
const isEveryday = daysNormalized && daysNormalized.length === 7 && ["MO", "TU", "WE", "TH", "FR", "SA", "SU"].every((d) => daysNormalized.includes(d));
|
|
615
627
|
if (freq === "WEEKLY" && interval === 1 && isWeekdays) {
|
|
@@ -623,15 +635,15 @@ function toText(input, locale) {
|
|
|
623
635
|
parts.push(base.singular);
|
|
624
636
|
}
|
|
625
637
|
}
|
|
626
|
-
if (freq === "WEEKLY" &&
|
|
638
|
+
if (freq === "WEEKLY" && textByDay && !isWeekdays && !isEveryday) {
|
|
627
639
|
parts.push(
|
|
628
640
|
data.words.on,
|
|
629
|
-
list(
|
|
641
|
+
list(textByDay, (t) => formatByDayToken(t, data), data.words.and)
|
|
630
642
|
);
|
|
631
|
-
} else if (
|
|
643
|
+
} else if (textByDay && freq !== "WEEKLY") {
|
|
632
644
|
parts.push(
|
|
633
645
|
data.words.on,
|
|
634
|
-
list(
|
|
646
|
+
list(textByDay, (t) => formatByDayToken(t, data), data.words.and)
|
|
635
647
|
);
|
|
636
648
|
}
|
|
637
649
|
if (byMonth) {
|
|
@@ -660,18 +672,18 @@ function toText(input, locale) {
|
|
|
660
672
|
list(byWeekNo, (n) => n.toString(), data.words.and)
|
|
661
673
|
);
|
|
662
674
|
}
|
|
663
|
-
if (
|
|
664
|
-
const minutes =
|
|
665
|
-
const seconds =
|
|
666
|
-
const times =
|
|
675
|
+
if (textByHour) {
|
|
676
|
+
const minutes = textByMinute != null ? textByMinute : [0];
|
|
677
|
+
const seconds = textBySecond != null ? textBySecond : [0];
|
|
678
|
+
const times = textByHour.flatMap((h) => minutes.flatMap((m) => seconds.map((s) => formatTime(h, m, s))));
|
|
667
679
|
parts.push(data.words.at, list(times, void 0, data.words.and));
|
|
668
680
|
parts.push(tzAbbreviation(opts.dtstart));
|
|
669
681
|
}
|
|
670
|
-
if (!
|
|
671
|
-
parts.push(data.words.at_minute, list(
|
|
682
|
+
if (!textByHour && textByMinute) {
|
|
683
|
+
parts.push(data.words.at_minute, list(textByMinute, void 0, data.words.and));
|
|
672
684
|
}
|
|
673
|
-
if (!
|
|
674
|
-
parts.push(data.words.at_second, list(
|
|
685
|
+
if (!textByHour && !textByMinute && textBySecond) {
|
|
686
|
+
parts.push(data.words.at_second, list(textBySecond, void 0, data.words.and));
|
|
675
687
|
}
|
|
676
688
|
if (until) {
|
|
677
689
|
const monthName = data.monthNames[until.month - 1];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrule-temporal",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
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",
|