@internationalized/date 3.5.3-nightly.4516 → 3.5.3-nightly.4523

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/module.js CHANGED
@@ -1760,33 +1760,37 @@ function $5f31bd6f0c8940b2$var$toGregorian(date) {
1760
1760
  // Original licensing can be found in the NOTICE file in the root directory of this source tree.
1761
1761
 
1762
1762
 
1763
- const $f3ed2e4472ae7e25$var$PERSIAN_EPOCH = 1948321; // 622/03/19 Julian C.E.
1764
- function $f3ed2e4472ae7e25$var$isLeapYear(year) {
1765
- let y0 = year > 0 ? year - 474 : year - 473;
1766
- let y1 = (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(y0, 2820) + 474;
1767
- return (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)((y1 + 38) * 31, 128) < 31;
1768
- }
1769
- function $f3ed2e4472ae7e25$var$persianToJulianDay(year, month, day) {
1770
- let y0 = year > 0 ? year - 474 : year - 473;
1771
- let y1 = (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(y0, 2820) + 474;
1772
- let offset = month <= 7 ? 31 * (month - 1) : 30 * (month - 1) + 6;
1773
- return $f3ed2e4472ae7e25$var$PERSIAN_EPOCH - 1 + 1029983 * Math.floor(y0 / 2820) + 365 * (y1 - 1) + Math.floor((31 * y1 - 5) / 128) + offset + day;
1774
- }
1763
+ const $f3ed2e4472ae7e25$var$PERSIAN_EPOCH = 1948320;
1764
+ // Number of days from the start of the year to the start of each month.
1765
+ const $f3ed2e4472ae7e25$var$MONTH_START = [
1766
+ 0,
1767
+ 31,
1768
+ 62,
1769
+ 93,
1770
+ 124,
1771
+ 155,
1772
+ 186,
1773
+ 216,
1774
+ 246,
1775
+ 276,
1776
+ 306,
1777
+ 336 // Esfand
1778
+ ];
1775
1779
  class $f3ed2e4472ae7e25$export$37fccdbfd14c5939 {
1776
1780
  fromJulianDay(jd) {
1777
- let d0 = jd - $f3ed2e4472ae7e25$var$persianToJulianDay(475, 1, 1);
1778
- let n2820 = Math.floor(d0 / 1029983);
1779
- let d1 = (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(d0, 1029983);
1780
- let y2820 = d1 === 1029982 ? 2820 : Math.floor((128 * d1 + 46878) / 46751);
1781
- let year = 474 + 2820 * n2820 + y2820;
1782
- if (year <= 0) year--;
1783
- let yDay = jd - $f3ed2e4472ae7e25$var$persianToJulianDay(year, 1, 1) + 1;
1784
- let month = yDay <= 186 ? Math.ceil(yDay / 31) : Math.ceil((yDay - 6) / 31);
1785
- let day = jd - $f3ed2e4472ae7e25$var$persianToJulianDay(year, month, 1) + 1;
1786
- return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(this, year, month, day);
1781
+ let daysSinceEpoch = jd - $f3ed2e4472ae7e25$var$PERSIAN_EPOCH;
1782
+ let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);
1783
+ let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);
1784
+ let dayOfYear = daysSinceEpoch - farvardin1;
1785
+ let month = dayOfYear < 216 ? Math.floor(dayOfYear / 31) : Math.floor((dayOfYear - 6) / 30);
1786
+ let day = dayOfYear - $f3ed2e4472ae7e25$var$MONTH_START[month] + 1;
1787
+ return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(this, year, month + 1, day);
1787
1788
  }
1788
1789
  toJulianDay(date) {
1789
- return $f3ed2e4472ae7e25$var$persianToJulianDay(date.year, date.month, date.day);
1790
+ let jd = $f3ed2e4472ae7e25$var$PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);
1791
+ jd += $f3ed2e4472ae7e25$var$MONTH_START[date.month - 1];
1792
+ jd += date.day;
1793
+ return jd;
1790
1794
  }
1791
1795
  getMonthsInYear() {
1792
1796
  return 12;
@@ -1794,7 +1798,8 @@ class $f3ed2e4472ae7e25$export$37fccdbfd14c5939 {
1794
1798
  getDaysInMonth(date) {
1795
1799
  if (date.month <= 6) return 31;
1796
1800
  if (date.month <= 11) return 30;
1797
- return $f3ed2e4472ae7e25$var$isLeapYear(date.year) ? 30 : 29;
1801
+ let isLeapYear = (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(25 * date.year + 11, 33) < 8;
1802
+ return isLeapYear ? 30 : 29;
1798
1803
  }
1799
1804
  getEras() {
1800
1805
  return [