temporal-polyfill-lite 0.3.3 → 0.3.4

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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.3.4 (2026-04-14)
9
+
10
+ ### Fixed
11
+
12
+ - Fix discrepancy of date time format between timestamp and Temporal objects in `Intl.DateTimeFormat` ([#27](https://github.com/fabon-f/temporal-polyfill-lite/pull/27))
13
+
8
14
  ## 0.3.3 (2026-03-21)
9
15
 
10
16
  ### Added
package/README.md CHANGED
@@ -48,4 +48,8 @@ This polyfill doesn't internally rely on `bigint`, thus you can support older br
48
48
 
49
49
  ## Spec compliance
50
50
 
51
- It supports the latest spec with few intentional deviations (see `/expectedFailures` directory for details).
51
+ It supports the latest spec with few intentional deviations (see `tests/expectedFailures` directory for details).
52
+
53
+ ## Docs
54
+
55
+ - `docs/restrictions.md`: caveats and restrictions of this polyfill
@@ -1,2 +1,2 @@
1
- import { i as a, r as s, t as r } from "./src-m77GJsdB.js";
1
+ import { i as a, r as s, t as r } from "./src-BRD2b69b.js";
2
2
  export { s as Intl, r as Temporal, a as toTemporalInstant };
@@ -4,5 +4,5 @@ function install(s) {
4
4
  function setSystemTimeZoneIdCacheTtl(t) {
5
5
  s(t);
6
6
  }
7
- import { a as t, i as a, n as s, r as e, t as l } from "./src-m77GJsdB.js";
7
+ import { a as t, i as a, n as s, r as e, t as l } from "./src-BRD2b69b.js";
8
8
  export { install, setSystemTimeZoneIdCacheTtl };
@@ -1823,8 +1823,8 @@ function nudgeToCalendarUnit(e, t, o, n, r, a, i, c, s, l) {
1823
1823
  return roundNumberToIncrement(m.he + ((e, t, o) => signTimeDuration(e) ? ve(e, t) ? ve(addTimeDuration(e, e), t) * o / 5 + .5 : 1 : 0)(u, T, e) * c * e, c, l) === m.De && (d = !0, D = m.Ie, h = m.ge), {
1824
1824
  Oe: {
1825
1825
  Fe: combineDateAndTimeDuration(D, createTimeDurationFromSeconds(0)),
1826
- Se: h,
1827
- ye: d
1826
+ ye: h,
1827
+ Se: d
1828
1828
  },
1829
1829
  we: m.he + divideTimeDurationToFloatingPoint(u, 1e9) / divideTimeDurationToFloatingPoint(T, 1e9) * c * e
1830
1830
  };
@@ -1837,18 +1837,18 @@ function roundRelativeDuration(e, t, o, n, r, a, i, c, s, l) {
1837
1837
  let I, O = !1, F = 0;
1838
1838
  return vt(f) !== -e ? (O = !0, F = e, p = roundTimeDurationToIncrement(f, a * D, c), I = addTimeDurationToEpochNanoseconds(u, p)) : I = addTimeDurationToEpochNanoseconds(u, p), {
1839
1839
  Fe: combineDateAndTimeDuration(adjustDateDurationRecord(t.A, t.A.K + F), p),
1840
- Se: I,
1841
- ye: O
1840
+ ye: I,
1841
+ Se: O
1842
1842
  };
1843
1843
  })(d, e, n, r, a, c, s, l) : (function(e, t, o, n, r, a) {
1844
1844
  const i = add24HourDaysToTimeDuration(e.p, e.A.K), c = r === H ? roundTimeDurationByDays(i, n, a) : roundTimeDurationToIncrement(i, nanosecondsForTimeUnit(r) * n, a), s = c[0], [l, d] = isDateUnit(o) ? [s, addTimeDuration(c, timeDurationFromComponents(24 * -s, 0, 0, 0, 0, 0))] : [0, c];
1845
1845
  return {
1846
1846
  Fe: combineDateAndTimeDuration(adjustDateDurationRecord(e.A, l), d),
1847
- Se: addTimeDurationToEpochNanoseconds(t, addTimeDuration(c, negateTimeDuration(i))),
1848
- ye: sign(s - i[0]) === vt(i)
1847
+ ye: addTimeDurationToEpochNanoseconds(t, addTimeDuration(c, negateTimeDuration(i))),
1848
+ Se: sign(s - i[0]) === vt(i)
1849
1849
  };
1850
1850
  })(e, o, i, c, s, l);
1851
- return m.ye && s !== x ? ((e, t, o, n, r, a, i, c) => {
1851
+ return m.Se && s !== x ? ((e, t, o, n, r, a, i, c) => {
1852
1852
  if (c === i) return t;
1853
1853
  const s = i;
1854
1854
  let l;
@@ -1859,7 +1859,7 @@ function roundRelativeDuration(e, t, o, n, r, a, i, c, s, l) {
1859
1859
  t = combineDateAndTimeDuration(l, createTimeDurationFromSeconds(0));
1860
1860
  }
1861
1861
  return t;
1862
- })(d, m.Fe, m.Se, n, r, a, i, largerOfTwoTemporalUnits(s, H)) : m.Fe;
1862
+ })(d, m.Fe, m.ye, n, r, a, i, largerOfTwoTemporalUnits(s, H)) : m.Fe;
1863
1863
  }
1864
1864
  function totalRelativeDuration(e, t, o, n, r, a, i) {
1865
1865
  return isCalendarUnit(i) || r && i === H ? nudgeToCalendarUnit(internalDurationSign(e) || 1, e, t, o, n, r, a, 1, i, M).we : totalTimeDuration(add24HourDaysToTimeDuration(e.p, e.A.K), i);
@@ -2191,14 +2191,34 @@ function createDateTimeFormat(e, t = createNullPrototypeObject({}), o, n, r = Ob
2191
2191
  for (const n of t) o[n] = e[n];
2192
2192
  return o;
2193
2193
  })(Object(t), Rt);
2194
- a.hour12 = mapUnlessUndefined(a.hour12, toBoolean), a.hourCycle = mapUnlessUndefined(a.hourCycle, toString), a.formatMatcher = mapUnlessUndefined(a.formatMatcher, toString), void 0 !== n && (void 0 !== a.timeZone && throwTypeError("disallowed field: timeZone"), a.timeZone = n, hasAnyOptions(a, [
2194
+ a.hour12 = mapUnlessUndefined(a.hour12, toBoolean);
2195
+ for (const e of [
2196
+ "hourCycle",
2197
+ "formatMatcher",
2198
+ "era",
2199
+ "year",
2200
+ "month",
2201
+ "day",
2202
+ "weekday"
2203
+ ]) mapUnlessUndefined(a[e], toString);
2204
+ void 0 !== n && (void 0 !== a.timeZone && throwTypeError("disallowed field: timeZone"), a.timeZone = n, hasAnyOptions(a, [
2195
2205
  ...Zt,
2196
2206
  ...$t,
2197
2207
  "timeZoneName"
2198
2208
  ]) || (a.timeZoneName = "short"));
2199
2209
  const i = new Pt(e, a), c = i.resolvedOptions(), d = createNullPrototypeObject(c);
2200
2210
  for (const e of Object.keys(d)) void 0 === a[e] && (d[e] = void 0);
2201
- return d.hour12 = a.hour12, d.hourCycle = a.hourCycle, d.formatMatcher = a.formatMatcher, d.timeZone = c.timeZone, d.calendar = c.calendar, (o === s && d.timeStyle || o === l && d.dateStyle) && throwTypeError(Te), Nt.set(r, createNullPrototypeObject({
2211
+ for (const e of [
2212
+ "hour12",
2213
+ "hourCycle",
2214
+ "formatMatcher",
2215
+ "era",
2216
+ "year",
2217
+ "month",
2218
+ "day",
2219
+ "weekday"
2220
+ ]) d[e] = a[e];
2221
+ return d.timeZone = c.timeZone, d.calendar = c.calendar, (o === s && d.timeStyle || o === l && d.dateStyle) && throwTypeError(Te), Nt.set(r, createNullPrototypeObject({
2202
2222
  Pe: i,
2203
2223
  Re: d,
2204
2224
  Ne: i.resolvedOptions().locale
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as a, r as s, t as r } from "./src-CfkGat92.js";
1
+ import { i as a, r as s, t as r } from "./src-D8HHiqs0.js";
2
2
  export { s as Intl, r as Temporal, a as toTemporalInstant };
package/dist/shim.js CHANGED
@@ -4,5 +4,5 @@ function install(s) {
4
4
  function setSystemTimeZoneIdCacheTtl(t) {
5
5
  s(t);
6
6
  }
7
- import { a as t, i as a, n as s, r as e, t as l } from "./src-CfkGat92.js";
7
+ import { a as t, i as a, n as s, r as e, t as l } from "./src-D8HHiqs0.js";
8
8
  export { install, setSystemTimeZoneIdCacheTtl };
@@ -1245,18 +1245,18 @@ function computeNudgeWindow(e, t, o, n, r, a, i, l, c) {
1245
1245
  return {
1246
1246
  Te: s,
1247
1247
  De: d,
1248
- pe: u,
1249
- he: r ? getEpochNanosecondsFor(r, D, g) : getUtcEpochNanoseconds(D),
1248
+ he: u,
1249
+ pe: r ? getEpochNanosecondsFor(r, D, g) : getUtcEpochNanoseconds(D),
1250
1250
  ge: m,
1251
1251
  fe: T
1252
1252
  };
1253
1253
  }
1254
1254
  function nudgeToCalendarUnit(e, t, o, n, r, a, i, l, c, s) {
1255
1255
  let d = !1, m = computeNudgeWindow(e, t, o, r, a, 0, l, c, !1);
1256
- compareEpochNanoseconds(m.pe, n) * compareEpochNanoseconds(m.he, n) > 0 && (m = computeNudgeWindow(e, t, o, r, a, 0, l, c, !0), d = !0);
1257
- const T = differenceEpochNanoseconds(m.pe, n), u = differenceEpochNanoseconds(m.pe, m.he);
1258
- let D = m.ge, p = m.pe;
1259
- return roundNumberToIncrement(m.Te + ((e, t, o) => signTimeDuration(e) ? ye(e, t) ? ye(addTimeDuration(e, e), t) * o / 5 + .5 : 1 : 0)(T, u, e) * l * e, l, s) === m.De && (d = !0, D = m.fe, p = m.he), {
1256
+ compareEpochNanoseconds(m.he, n) * compareEpochNanoseconds(m.pe, n) > 0 && (m = computeNudgeWindow(e, t, o, r, a, 0, l, c, !0), d = !0);
1257
+ const T = differenceEpochNanoseconds(m.he, n), u = differenceEpochNanoseconds(m.he, m.pe);
1258
+ let D = m.ge, p = m.he;
1259
+ return roundNumberToIncrement(m.Te + ((e, t, o) => signTimeDuration(e) ? ye(e, t) ? ye(addTimeDuration(e, e), t) * o / 5 + .5 : 1 : 0)(T, u, e) * l * e, l, s) === m.De && (d = !0, D = m.fe, p = m.pe), {
1260
1260
  Ie: {
1261
1261
  Oe: combineDateAndTimeDuration(D, createTimeDurationFromSeconds(0)),
1262
1262
  Se: p,
@@ -1416,12 +1416,12 @@ function getTemporalFractionalSecondDigitsOption(e) {
1416
1416
  }
1417
1417
  function toSecondsStringPrecisionRecord(e, t) {
1418
1418
  return e ? {
1419
- ve: e === q ? D : 3 * (e - 6),
1420
- ye: e,
1419
+ ye: e === q ? D : 3 * (e - 6),
1420
+ ve: e,
1421
1421
  Ee: 1
1422
1422
  } : {
1423
- ve: t,
1424
- ye: divFloor((t ?? 9) - 1, 3) + 7,
1423
+ ye: t,
1424
+ ve: divFloor((t ?? 9) - 1, 3) + 7,
1425
1425
  Ee: 10 ** ((9 - (t ?? 9)) % 3)
1426
1426
  };
1427
1427
  }
@@ -1627,14 +1627,34 @@ function createDateTimeFormat(e, t = createNullPrototypeObject({}), o, n, r = Ob
1627
1627
  for (const n of t) o[n] = e[n];
1628
1628
  return o;
1629
1629
  })(Object(t), wt);
1630
- a.hour12 = mapUnlessUndefined(a.hour12, toBoolean), a.hourCycle = mapUnlessUndefined(a.hourCycle, toString), a.formatMatcher = mapUnlessUndefined(a.formatMatcher, toString), void 0 !== n && (void 0 !== a.timeZone && throwTypeError("disallowed field: timeZone"), a.timeZone = n, hasAnyOptions(a, [
1630
+ a.hour12 = mapUnlessUndefined(a.hour12, toBoolean);
1631
+ for (const e of [
1632
+ "hourCycle",
1633
+ "formatMatcher",
1634
+ "era",
1635
+ "year",
1636
+ "month",
1637
+ "day",
1638
+ "weekday"
1639
+ ]) mapUnlessUndefined(a[e], toString);
1640
+ void 0 !== n && (void 0 !== a.timeZone && throwTypeError("disallowed field: timeZone"), a.timeZone = n, hasAnyOptions(a, [
1631
1641
  ...yt,
1632
1642
  ...Et,
1633
1643
  "timeZoneName"
1634
1644
  ]) || (a.timeZoneName = "short"));
1635
1645
  const i = new Ft(e, a), l = i.resolvedOptions(), d = createNullPrototypeObject(l);
1636
1646
  for (const e of Object.keys(d)) void 0 === a[e] && (d[e] = void 0);
1637
- return d.hour12 = a.hour12, d.hourCycle = a.hourCycle, d.formatMatcher = a.formatMatcher, d.timeZone = l.timeZone, d.calendar = l.calendar, (o === c && d.timeStyle || o === s && d.dateStyle) && throwTypeError(ue), vt.set(r, createNullPrototypeObject({
1647
+ for (const e of [
1648
+ "hour12",
1649
+ "hourCycle",
1650
+ "formatMatcher",
1651
+ "era",
1652
+ "year",
1653
+ "month",
1654
+ "day",
1655
+ "weekday"
1656
+ ]) d[e] = a[e];
1657
+ return d.timeZone = l.timeZone, d.calendar = l.calendar, (o === c && d.timeStyle || o === s && d.dateStyle) && throwTypeError(ue), vt.set(r, createNullPrototypeObject({
1638
1658
  Re: i,
1639
1659
  Ze: d,
1640
1660
  Ne: i.resolvedOptions().locale
@@ -1911,7 +1931,7 @@ var Pe = class {
1911
1931
  ], W))(o);
1912
1932
  validateTemporalUnitValue(l, s), l === B && throwRangeError(invalidField("smallestUnit"));
1913
1933
  const d = toSecondsStringPrecisionRecord(l, r);
1914
- return temporalZonedDateTimeToString(t, d.ve, n, c, a, d.Ee, d.ye, i);
1934
+ return temporalZonedDateTimeToString(t, d.ye, n, c, a, d.Ee, d.ve, i);
1915
1935
  }
1916
1936
  toLocaleString(e = void 0, t = void 0) {
1917
1937
  const o = getInternalSlotOrThrowForZonedDateTime(this), n = createDateTimeFormat(e, t, d, o.Z), r = getInternalSlotOrThrowForDateTimeFormat(n);
@@ -2107,7 +2127,7 @@ var Ne = class {
2107
2127
  const t = getInternalSlotOrThrowForPlainDateTime(this), o = getOptionsObject(e), n = getTemporalShowCalendarNameOption(o), r = getTemporalFractionalSecondDigitsOption(o), a = getRoundingModeOption(o, P), i = getTemporalUnitValuedOption(o, "smallestUnit", void 0);
2108
2128
  validateTemporalUnitValue(i, s), i === B && throwRangeError(invalidField("smallestUnit"));
2109
2129
  const l = toSecondsStringPrecisionRecord(i, r);
2110
- return isoDateTimeToString(validateIsoDateTime(roundIsoDateTime(t._, l.Ee, l.ye, a)), t.U, l.ve, n);
2130
+ return isoDateTimeToString(validateIsoDateTime(roundIsoDateTime(t._, l.Ee, l.ve, a)), t.U, l.ye, n);
2111
2131
  }
2112
2132
  toLocaleString(e = void 0, t = void 0) {
2113
2133
  return getInternalSlotOrThrowForPlainDateTime(this), formatDateTime(createDateTimeFormat(e, t, d), this);
@@ -2203,7 +2223,7 @@ var Ue = class {
2203
2223
  const t = getInternalSlotOrThrowForPlainTime(this), o = getOptionsObject(e), n = getTemporalFractionalSecondDigitsOption(o), r = getRoundingModeOption(o, P), a = getTemporalUnitValuedOption(o, "smallestUnit", void 0);
2204
2224
  validateTemporalUnitValue(a, s), a === B && throwRangeError(invalidField("smallestUnit"));
2205
2225
  const i = toSecondsStringPrecisionRecord(a, n);
2206
- return timeRecordToString(roundTime(t, i.Ee, i.ye, r), i.ve);
2226
+ return timeRecordToString(roundTime(t, i.Ee, i.ve, r), i.ye);
2207
2227
  }
2208
2228
  toLocaleString(e = void 0, t = void 0) {
2209
2229
  return getInternalSlotOrThrowForPlainTime(this), formatDateTime(createDateTimeFormat(e, t, s), this);
@@ -2685,9 +2705,9 @@ var It = class {
2685
2705
  const t = getInternalSlotOrThrowForDuration(this), o = getOptionsObject(e), n = getTemporalFractionalSecondDigitsOption(o), r = getRoundingModeOption(o, P), a = getTemporalUnitValuedOption(o, "smallestUnit", void 0);
2686
2706
  validateTemporalUnitValue(a, s), a !== B && a !== q || throwRangeError(disallowedUnit(a));
2687
2707
  const i = toSecondsStringPrecisionRecord(a, n);
2688
- if (i.ye === G && 1 === i.Ee) return temporalDurationToString(t, i.ve);
2708
+ if (i.ve === G && 1 === i.Ee) return temporalDurationToString(t, i.ye);
2689
2709
  const l = toInternalDurationRecord(t);
2690
- return temporalDurationToString(temporalDurationFromInternal(combineDateAndTimeDuration(l.W, roundTimeDuration(l.p, i.Ee, i.ye, r)), largerOfTwoTemporalUnits(defaultTemporalLargestUnit(t), J)), i.ve);
2710
+ return temporalDurationToString(temporalDurationFromInternal(combineDateAndTimeDuration(l.W, roundTimeDuration(l.p, i.Ee, i.ve, r)), largerOfTwoTemporalUnits(defaultTemporalLargestUnit(t), J)), i.ye);
2691
2711
  }
2692
2712
  toJSON() {
2693
2713
  return temporalDurationToString(getInternalSlotOrThrowForDuration(this));
@@ -2826,7 +2846,7 @@ var Nt = class {
2826
2846
  const t = getInternalSlotOrThrowForInstant(this), o = getOptionsObject(e), n = getTemporalFractionalSecondDigitsOption(o), r = getRoundingModeOption(o, P), a = getTemporalUnitValuedOption(o, "smallestUnit", void 0), i = o.timeZone;
2827
2847
  validateTemporalUnitValue(a, s), a === B && throwRangeError(invalidField("smallestUnit"));
2828
2848
  const l = mapUnlessUndefined(i, toTemporalTimeZoneIdentifier), c = toSecondsStringPrecisionRecord(a, n);
2829
- return temporalInstantToString(roundTemporalInstant(t.Y, c.Ee, c.ye, r), l, c.ve);
2849
+ return temporalInstantToString(roundTemporalInstant(t.Y, c.Ee, c.ve, r), l, c.ye);
2830
2850
  }
2831
2851
  toLocaleString(e = void 0, t = void 0) {
2832
2852
  return getInternalSlotOrThrowForInstant(this), formatDateTime(createDateTimeFormat(e, t, d), this);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "temporal-polyfill-lite",
4
- "version": "0.3.3",
4
+ "version": "0.3.4",
5
5
  "description": "Lightweight Temporal polyfill",
6
6
  "keywords": [
7
7
  "Temporal"