@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/import.mjs 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 [
package/dist/main.js CHANGED
@@ -1825,33 +1825,37 @@ function $9cc5d3577ec40243$var$toGregorian(date) {
1825
1825
  // Original licensing can be found in the NOTICE file in the root directory of this source tree.
1826
1826
 
1827
1827
 
1828
- const $3c060181fc7249ae$var$PERSIAN_EPOCH = 1948321; // 622/03/19 Julian C.E.
1829
- function $3c060181fc7249ae$var$isLeapYear(year) {
1830
- let y0 = year > 0 ? year - 474 : year - 473;
1831
- let y1 = (0, $a5090d6430502238$export$842a2cf37af977e1)(y0, 2820) + 474;
1832
- return (0, $a5090d6430502238$export$842a2cf37af977e1)((y1 + 38) * 31, 128) < 31;
1833
- }
1834
- function $3c060181fc7249ae$var$persianToJulianDay(year, month, day) {
1835
- let y0 = year > 0 ? year - 474 : year - 473;
1836
- let y1 = (0, $a5090d6430502238$export$842a2cf37af977e1)(y0, 2820) + 474;
1837
- let offset = month <= 7 ? 31 * (month - 1) : 30 * (month - 1) + 6;
1838
- return $3c060181fc7249ae$var$PERSIAN_EPOCH - 1 + 1029983 * Math.floor(y0 / 2820) + 365 * (y1 - 1) + Math.floor((31 * y1 - 5) / 128) + offset + day;
1839
- }
1828
+ const $3c060181fc7249ae$var$PERSIAN_EPOCH = 1948320;
1829
+ // Number of days from the start of the year to the start of each month.
1830
+ const $3c060181fc7249ae$var$MONTH_START = [
1831
+ 0,
1832
+ 31,
1833
+ 62,
1834
+ 93,
1835
+ 124,
1836
+ 155,
1837
+ 186,
1838
+ 216,
1839
+ 246,
1840
+ 276,
1841
+ 306,
1842
+ 336 // Esfand
1843
+ ];
1840
1844
  class $3c060181fc7249ae$export$37fccdbfd14c5939 {
1841
1845
  fromJulianDay(jd) {
1842
- let d0 = jd - $3c060181fc7249ae$var$persianToJulianDay(475, 1, 1);
1843
- let n2820 = Math.floor(d0 / 1029983);
1844
- let d1 = (0, $a5090d6430502238$export$842a2cf37af977e1)(d0, 1029983);
1845
- let y2820 = d1 === 1029982 ? 2820 : Math.floor((128 * d1 + 46878) / 46751);
1846
- let year = 474 + 2820 * n2820 + y2820;
1847
- if (year <= 0) year--;
1848
- let yDay = jd - $3c060181fc7249ae$var$persianToJulianDay(year, 1, 1) + 1;
1849
- let month = yDay <= 186 ? Math.ceil(yDay / 31) : Math.ceil((yDay - 6) / 31);
1850
- let day = jd - $3c060181fc7249ae$var$persianToJulianDay(year, month, 1) + 1;
1851
- return new (0, $625ad1e1f4c43bc1$export$99faa760c7908e4f)(this, year, month, day);
1846
+ let daysSinceEpoch = jd - $3c060181fc7249ae$var$PERSIAN_EPOCH;
1847
+ let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);
1848
+ let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);
1849
+ let dayOfYear = daysSinceEpoch - farvardin1;
1850
+ let month = dayOfYear < 216 ? Math.floor(dayOfYear / 31) : Math.floor((dayOfYear - 6) / 30);
1851
+ let day = dayOfYear - $3c060181fc7249ae$var$MONTH_START[month] + 1;
1852
+ return new (0, $625ad1e1f4c43bc1$export$99faa760c7908e4f)(this, year, month + 1, day);
1852
1853
  }
1853
1854
  toJulianDay(date) {
1854
- return $3c060181fc7249ae$var$persianToJulianDay(date.year, date.month, date.day);
1855
+ let jd = $3c060181fc7249ae$var$PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);
1856
+ jd += $3c060181fc7249ae$var$MONTH_START[date.month - 1];
1857
+ jd += date.day;
1858
+ return jd;
1855
1859
  }
1856
1860
  getMonthsInYear() {
1857
1861
  return 12;
@@ -1859,7 +1863,8 @@ class $3c060181fc7249ae$export$37fccdbfd14c5939 {
1859
1863
  getDaysInMonth(date) {
1860
1864
  if (date.month <= 6) return 31;
1861
1865
  if (date.month <= 11) return 30;
1862
- return $3c060181fc7249ae$var$isLeapYear(date.year) ? 30 : 29;
1866
+ let isLeapYear = (0, $a5090d6430502238$export$842a2cf37af977e1)(25 * date.year + 11, 33) < 8;
1867
+ return isLeapYear ? 30 : 29;
1863
1868
  }
1864
1869
  getEras() {
1865
1870
  return [