rrule-temporal 1.6.0 → 2.0.1
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 +60 -34
- package/dist/index.cjs +5 -2761
- package/dist/index.d.cts +41 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +1 -2757
- package/dist/src-B0RsDEOV.cjs +7577 -0
- package/dist/src-DEpYefSo.js +7554 -0
- package/dist/totext.cjs +19 -21
- package/dist/totext.js +13 -15
- package/package.json +2 -2
package/dist/totext.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
let _js_temporal_polyfill = require("@js-temporal/polyfill");
|
|
2
|
+
const require_src = require("./src-B0RsDEOV.cjs");
|
|
4
3
|
//#region src/totext.ts
|
|
5
4
|
const en = {
|
|
6
5
|
weekdayNames: [
|
|
@@ -813,9 +812,9 @@ const env = typeof process !== "undefined" && process.env ? process.env.TOTEXT_L
|
|
|
813
812
|
const active = env ? env.split(",").map((s) => s.trim()).filter(Boolean) : Object.keys(ALL_LOCALES);
|
|
814
813
|
const LOCALES = {};
|
|
815
814
|
for (const l of active) if (ALL_LOCALES[l]) LOCALES[l] = ALL_LOCALES[l];
|
|
816
|
-
const workweekWeekdays =
|
|
817
|
-
const byDayTokenRegex = new RegExp(`^([+-]?\\d+)?(${
|
|
818
|
-
const weekdayIndexByToken = Object.fromEntries(
|
|
815
|
+
const workweekWeekdays = require_src.allowedWeekdays.slice(0, 5);
|
|
816
|
+
const byDayTokenRegex = new RegExp(`^([+-]?\\d+)?(${require_src.allowedWeekdays.join("|")})$`);
|
|
817
|
+
const weekdayIndexByToken = Object.fromEntries(require_src.allowedWeekdays.map((weekday, idx) => [weekday, idx]));
|
|
819
818
|
function defaultOrdinal(n) {
|
|
820
819
|
const abs = Math.abs(n);
|
|
821
820
|
const suffix = abs % 10 === 1 && abs % 100 !== 11 ? "st" : abs % 10 === 2 && abs % 100 !== 12 ? "nd" : abs % 10 === 3 && abs % 100 !== 13 ? "rd" : "th";
|
|
@@ -840,28 +839,22 @@ function formatByDayToken(tok, locale) {
|
|
|
840
839
|
if (ord === -1) return `${locale.words.last} ${name}`;
|
|
841
840
|
return `${ordinal(ord, locale)} ${name}`;
|
|
842
841
|
}
|
|
843
|
-
function formatTime(
|
|
842
|
+
function formatTime(_zdt, locale, hour, minute, second) {
|
|
844
843
|
const options = {
|
|
845
844
|
hour: "numeric",
|
|
846
|
-
timeZone:
|
|
845
|
+
timeZone: "UTC"
|
|
847
846
|
};
|
|
848
847
|
if (second) options.second = "2-digit";
|
|
849
848
|
if (second || minute) options.minute = "2-digit";
|
|
850
|
-
const
|
|
851
|
-
hour,
|
|
852
|
-
minute,
|
|
853
|
-
second
|
|
854
|
-
});
|
|
855
|
-
let result;
|
|
849
|
+
const sample = new Date(Date.UTC(2e3, 0, 1, hour, minute, second));
|
|
856
850
|
try {
|
|
857
|
-
|
|
851
|
+
return new Intl.DateTimeFormat(locale, options).format(sample);
|
|
858
852
|
} catch {
|
|
859
|
-
|
|
853
|
+
return new Intl.DateTimeFormat("en", options).format(sample);
|
|
860
854
|
}
|
|
861
|
-
return result;
|
|
862
855
|
}
|
|
863
856
|
function weekdayTokenFromZdt(zdt) {
|
|
864
|
-
return
|
|
857
|
+
return require_src.allowedWeekdays[zdt.dayOfWeek - 1];
|
|
865
858
|
}
|
|
866
859
|
function tzAbbreviation(zdt, locale) {
|
|
867
860
|
const options = {
|
|
@@ -878,14 +871,19 @@ function tzAbbreviation(zdt, locale) {
|
|
|
878
871
|
return formatter.formatToParts(new Date(zdt.epochMilliseconds)).find((p) => p.type === "timeZoneName")?.value || zdt.timeZoneId;
|
|
879
872
|
}
|
|
880
873
|
function formatLocalizedDate(zdt, locale) {
|
|
874
|
+
const options = {
|
|
875
|
+
dateStyle: "long",
|
|
876
|
+
timeZone: zdt.timeZoneId
|
|
877
|
+
};
|
|
878
|
+
const sample = new Date(zdt.epochMilliseconds);
|
|
881
879
|
try {
|
|
882
|
-
return
|
|
880
|
+
return new Intl.DateTimeFormat(locale, options).format(sample);
|
|
883
881
|
} catch {
|
|
884
|
-
return
|
|
882
|
+
return new Intl.DateTimeFormat("en", options).format(sample);
|
|
885
883
|
}
|
|
886
884
|
}
|
|
887
885
|
function toText(input, locale, options = {}) {
|
|
888
|
-
const opts = (typeof input === "string" ? new
|
|
886
|
+
const opts = (typeof input === "string" ? new require_src.RRuleTemporal({ rruleString: input }) : input).options();
|
|
889
887
|
const resolvedLocale = locale ?? Intl.DateTimeFormat().resolvedOptions().locale;
|
|
890
888
|
const lang = resolvedLocale.split("-")[0];
|
|
891
889
|
const data = LOCALES[lang] || en;
|
|
@@ -912,7 +910,7 @@ function toText(input, locale, options = {}) {
|
|
|
912
910
|
const base = data.units[baseKey];
|
|
913
911
|
const daysNormalized = textByDay?.map((d) => d.toUpperCase());
|
|
914
912
|
const isWeekdays = daysNormalized && daysNormalized.length === workweekWeekdays.length && workweekWeekdays.every((d) => daysNormalized.includes(d));
|
|
915
|
-
const isEveryday = daysNormalized && daysNormalized.length ===
|
|
913
|
+
const isEveryday = daysNormalized && daysNormalized.length === require_src.allowedWeekdays.length && require_src.allowedWeekdays.every((d) => daysNormalized.includes(d));
|
|
916
914
|
if (freq === "WEEKLY" && interval === 1 && isWeekdays) parts.push(data.words.weekday);
|
|
917
915
|
else if (freq === "WEEKLY" && interval === 1 && isEveryday) parts.push(data.units.day.singular);
|
|
918
916
|
else if (interval !== 1) parts.push(interval.toString(), base.plural);
|
package/dist/totext.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
1
|
+
import { r as allowedWeekdays, t as RRuleTemporal } from "./src-DEpYefSo.js";
|
|
3
2
|
//#region src/totext.ts
|
|
4
3
|
const en = {
|
|
5
4
|
weekdayNames: [
|
|
@@ -839,25 +838,19 @@ function formatByDayToken(tok, locale) {
|
|
|
839
838
|
if (ord === -1) return `${locale.words.last} ${name}`;
|
|
840
839
|
return `${ordinal(ord, locale)} ${name}`;
|
|
841
840
|
}
|
|
842
|
-
function formatTime(
|
|
841
|
+
function formatTime(_zdt, locale, hour, minute, second) {
|
|
843
842
|
const options = {
|
|
844
843
|
hour: "numeric",
|
|
845
|
-
timeZone:
|
|
844
|
+
timeZone: "UTC"
|
|
846
845
|
};
|
|
847
846
|
if (second) options.second = "2-digit";
|
|
848
847
|
if (second || minute) options.minute = "2-digit";
|
|
849
|
-
const
|
|
850
|
-
hour,
|
|
851
|
-
minute,
|
|
852
|
-
second
|
|
853
|
-
});
|
|
854
|
-
let result;
|
|
848
|
+
const sample = new Date(Date.UTC(2e3, 0, 1, hour, minute, second));
|
|
855
849
|
try {
|
|
856
|
-
|
|
850
|
+
return new Intl.DateTimeFormat(locale, options).format(sample);
|
|
857
851
|
} catch {
|
|
858
|
-
|
|
852
|
+
return new Intl.DateTimeFormat("en", options).format(sample);
|
|
859
853
|
}
|
|
860
|
-
return result;
|
|
861
854
|
}
|
|
862
855
|
function weekdayTokenFromZdt(zdt) {
|
|
863
856
|
return allowedWeekdays[zdt.dayOfWeek - 1];
|
|
@@ -877,10 +870,15 @@ function tzAbbreviation(zdt, locale) {
|
|
|
877
870
|
return formatter.formatToParts(new Date(zdt.epochMilliseconds)).find((p) => p.type === "timeZoneName")?.value || zdt.timeZoneId;
|
|
878
871
|
}
|
|
879
872
|
function formatLocalizedDate(zdt, locale) {
|
|
873
|
+
const options = {
|
|
874
|
+
dateStyle: "long",
|
|
875
|
+
timeZone: zdt.timeZoneId
|
|
876
|
+
};
|
|
877
|
+
const sample = new Date(zdt.epochMilliseconds);
|
|
880
878
|
try {
|
|
881
|
-
return
|
|
879
|
+
return new Intl.DateTimeFormat(locale, options).format(sample);
|
|
882
880
|
} catch {
|
|
883
|
-
return
|
|
881
|
+
return new Intl.DateTimeFormat("en", options).format(sample);
|
|
884
882
|
}
|
|
885
883
|
}
|
|
886
884
|
function toText(input, locale, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrule-temporal",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
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",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"dist"
|
|
49
49
|
],
|
|
50
50
|
"devDependencies": {
|
|
51
|
+
"@js-temporal/polyfill": "^0.5.1",
|
|
51
52
|
"@types/node": "^25.5.0",
|
|
52
53
|
"@vitest/coverage-v8": "^4.1.0",
|
|
53
54
|
"prettier": "^3.8.1",
|
|
@@ -57,7 +58,6 @@
|
|
|
57
58
|
"vitest": "^4.1.0"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
|
-
"@js-temporal/polyfill": "^0.5.1",
|
|
61
61
|
"temporal-spec": "^1.0.0"
|
|
62
62
|
},
|
|
63
63
|
"packageManager": "pnpm@10.6.0+sha1.c53a73dd9336949b37f63d82c45beb5b161924b6"
|