rrule-temporal 1.5.3 → 2.0.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/totext.cjs CHANGED
@@ -1,6 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_index = require("./index.cjs");
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 = require_index.allowedWeekdays.slice(0, 5);
817
- const byDayTokenRegex = new RegExp(`^([+-]?\\d+)?(${require_index.allowedWeekdays.join("|")})$`);
818
- const weekdayIndexByToken = Object.fromEntries(require_index.allowedWeekdays.map((weekday, idx) => [weekday, idx]));
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(zdt, locale, hour, minute, second) {
842
+ function formatTime(_zdt, locale, hour, minute, second) {
844
843
  const options = {
845
844
  hour: "numeric",
846
- timeZone: zdt.timeZoneId
845
+ timeZone: "UTC"
847
846
  };
848
847
  if (second) options.second = "2-digit";
849
848
  if (second || minute) options.minute = "2-digit";
850
- const ruleTime = _js_temporal_polyfill.Temporal.PlainTime.from({
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
- result = ruleTime.toLocaleString(locale, options);
851
+ return new Intl.DateTimeFormat(locale, options).format(sample);
858
852
  } catch {
859
- result = ruleTime.toLocaleString("en", options);
853
+ return new Intl.DateTimeFormat("en", options).format(sample);
860
854
  }
861
- return result;
862
855
  }
863
856
  function weekdayTokenFromZdt(zdt) {
864
- return require_index.allowedWeekdays[zdt.dayOfWeek - 1];
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 zdt.toLocaleString(locale, { dateStyle: "long" });
880
+ return new Intl.DateTimeFormat(locale, options).format(sample);
883
881
  } catch {
884
- return zdt.toLocaleString("en", { dateStyle: "long" });
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 require_index.RRuleTemporal({ rruleString: input }) : input).options();
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 === require_index.allowedWeekdays.length && require_index.allowedWeekdays.every((d) => daysNormalized.includes(d));
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 { RRuleTemporal, allowedWeekdays } from "./index.js";
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(zdt, locale, hour, minute, second) {
841
+ function formatTime(_zdt, locale, hour, minute, second) {
843
842
  const options = {
844
843
  hour: "numeric",
845
- timeZone: zdt.timeZoneId
844
+ timeZone: "UTC"
846
845
  };
847
846
  if (second) options.second = "2-digit";
848
847
  if (second || minute) options.minute = "2-digit";
849
- const ruleTime = Temporal.PlainTime.from({
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
- result = ruleTime.toLocaleString(locale, options);
850
+ return new Intl.DateTimeFormat(locale, options).format(sample);
857
851
  } catch {
858
- result = ruleTime.toLocaleString("en", options);
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 zdt.toLocaleString(locale, { dateStyle: "long" });
879
+ return new Intl.DateTimeFormat(locale, options).format(sample);
882
880
  } catch {
883
- return zdt.toLocaleString("en", { dateStyle: "long" });
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": "1.5.3",
3
+ "version": "2.0.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",
@@ -20,6 +20,7 @@
20
20
  "scripts": {
21
21
  "build": "tsdown",
22
22
  "test": "vitest run",
23
+ "test:types": "npm run build && tsc -p tests/type-compat/tsconfig.json --noEmit",
23
24
  "coverage": "vitest run --coverage",
24
25
  "format": "prettier --write 'src/**/*.ts'",
25
26
  "prepare": "npm run build"
@@ -46,15 +47,21 @@
46
47
  "files": [
47
48
  "dist"
48
49
  ],
50
+ "engines": {
51
+ "node": ">=20"
52
+ },
49
53
  "devDependencies": {
54
+ "@js-temporal/polyfill": "^0.5.1",
50
55
  "@types/node": "^25.5.0",
51
56
  "@vitest/coverage-v8": "^4.1.0",
52
57
  "prettier": "^3.8.1",
58
+ "temporal-polyfill": "^1.0.1",
53
59
  "tsdown": "^0.21.4",
54
60
  "typescript": "^5.9.3",
55
61
  "vitest": "^4.1.0"
56
62
  },
57
63
  "dependencies": {
58
- "@js-temporal/polyfill": "^0.5.1"
59
- }
64
+ "temporal-spec": "^1.0.0"
65
+ },
66
+ "packageManager": "pnpm@10.6.0+sha1.c53a73dd9336949b37f63d82c45beb5b161924b6"
60
67
  }