@internationalized/date 3.0.0-rc.1 → 3.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/main.js +63 -33
- package/dist/main.js.map +1 -1
- package/dist/module.js +63 -33
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +4 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/DateFormatter.ts +6 -0
- package/src/calendars/EthiopicCalendar.ts +35 -29
- package/src/calendars/HebrewCalendar.ts +1 -0
- package/src/calendars/IndianCalendar.ts +3 -1
- package/src/calendars/IslamicCalendar.ts +2 -1
- package/src/calendars/JapaneseCalendar.ts +9 -8
- package/src/calendars/PersianCalendar.ts +3 -1
- package/src/calendars/TaiwanCalendar.ts +4 -0
- package/src/conversion.ts +2 -0
package/dist/main.js
CHANGED
|
@@ -78,6 +78,7 @@ $parcel$export(module.exports, "DateFormatter", () => $8f23a04ae90a588b$export$a
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
|
|
81
|
+
|
|
81
82
|
function $a5090d6430502238$export$842a2cf37af977e1(amount, numerator) {
|
|
82
83
|
return amount - numerator * Math.floor(amount / numerator);
|
|
83
84
|
}
|
|
@@ -715,6 +716,7 @@ function $4ae0260a69729f1d$export$b4a036af3fc0b032(date, calendar) {
|
|
|
715
716
|
copy.year = calendarDate.year;
|
|
716
717
|
copy.month = calendarDate.month;
|
|
717
718
|
copy.day = calendarDate.day;
|
|
719
|
+
$5c0571aa5b6fb5da$export$c4e2ecac49351ef2(copy);
|
|
718
720
|
return copy;
|
|
719
721
|
}
|
|
720
722
|
function $4ae0260a69729f1d$export$84c95a83c799e074(date, timeZone, disambiguation) {
|
|
@@ -1494,11 +1496,11 @@ class $b0ac0602ef646b2c$export$b746ab2b60cdffbf extends $af14c9812fdceb33$export
|
|
|
1494
1496
|
date.month = Math.min(endMonth, date.month);
|
|
1495
1497
|
if (date.month === endMonth) date.day = Math.min(endDay, date.day);
|
|
1496
1498
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1499
|
+
}
|
|
1500
|
+
if (date.year === 1 && idx >= 0) {
|
|
1501
|
+
let [, startMonth, startDay] = $b0ac0602ef646b2c$var$ERA_START_DATES[idx];
|
|
1502
|
+
date.month = Math.max(startMonth, date.month);
|
|
1503
|
+
if (date.month === startMonth) date.day = Math.max(startDay, date.day);
|
|
1502
1504
|
}
|
|
1503
1505
|
}
|
|
1504
1506
|
getEras() {
|
|
@@ -1507,9 +1509,10 @@ class $b0ac0602ef646b2c$export$b746ab2b60cdffbf extends $af14c9812fdceb33$export
|
|
|
1507
1509
|
getYearsInEra(date) {
|
|
1508
1510
|
// Get the number of years in the era, taking into account the date's month and day fields.
|
|
1509
1511
|
let era = $b0ac0602ef646b2c$var$ERA_NAMES.indexOf(date.era);
|
|
1510
|
-
let next = $b0ac0602ef646b2c$var$ERA_START_DATES[era + 1];
|
|
1511
|
-
if (next == null) return 9999;
|
|
1512
1512
|
let cur = $b0ac0602ef646b2c$var$ERA_START_DATES[era];
|
|
1513
|
+
let next = $b0ac0602ef646b2c$var$ERA_START_DATES[era + 1];
|
|
1514
|
+
if (next == null) // 9999 gregorian is the maximum year allowed.
|
|
1515
|
+
return 9999 - cur[0] + 1;
|
|
1513
1516
|
let years = next[0] - cur[0];
|
|
1514
1517
|
if (date.month < next[1] || date.month === next[1] && date.day < next[2]) years++;
|
|
1515
1518
|
return years;
|
|
@@ -1615,6 +1618,9 @@ class $9cc5d3577ec40243$export$65e01080afcb0799 extends $af14c9812fdceb33$export
|
|
|
1615
1618
|
getDaysInMonth(date) {
|
|
1616
1619
|
return super.getDaysInMonth($9cc5d3577ec40243$var$toGregorian(date));
|
|
1617
1620
|
}
|
|
1621
|
+
getYearsInEra(date) {
|
|
1622
|
+
return date.era === 'before_minguo' ? 9999 : 9999 - $9cc5d3577ec40243$var$TAIWAN_ERA_START;
|
|
1623
|
+
}
|
|
1618
1624
|
constructor(...args){
|
|
1619
1625
|
super(...args);
|
|
1620
1626
|
this.identifier // Republic of China
|
|
@@ -1671,7 +1677,9 @@ class $3c060181fc7249ae$export$37fccdbfd14c5939 {
|
|
|
1671
1677
|
];
|
|
1672
1678
|
}
|
|
1673
1679
|
getYearsInEra() {
|
|
1674
|
-
|
|
1680
|
+
// 9378-10-10 persian is 9999-12-31 gregorian.
|
|
1681
|
+
// Round down to 9377 to set the maximum full year.
|
|
1682
|
+
return 9377;
|
|
1675
1683
|
}
|
|
1676
1684
|
constructor(){
|
|
1677
1685
|
this.identifier = 'persian';
|
|
@@ -1747,7 +1755,9 @@ class $5f1dfa5c67609fe6$export$39f31c639fa15726 extends $af14c9812fdceb33$export
|
|
|
1747
1755
|
return 30;
|
|
1748
1756
|
}
|
|
1749
1757
|
getYearsInEra() {
|
|
1750
|
-
|
|
1758
|
+
// 9999-12-31 gregorian is 9920-10-10 indian.
|
|
1759
|
+
// Round down to 9919 for the last full year.
|
|
1760
|
+
return 9919;
|
|
1751
1761
|
}
|
|
1752
1762
|
getEras() {
|
|
1753
1763
|
return [
|
|
@@ -1800,7 +1810,8 @@ class $ecb2c4cc8c9aae25$export$2066795aadd37bfc {
|
|
|
1800
1810
|
return $ecb2c4cc8c9aae25$var$isLeapYear(date.year) ? 355 : 354;
|
|
1801
1811
|
}
|
|
1802
1812
|
getYearsInEra() {
|
|
1803
|
-
|
|
1813
|
+
// 9999 gregorian
|
|
1814
|
+
return 9665;
|
|
1804
1815
|
}
|
|
1805
1816
|
getEras() {
|
|
1806
1817
|
return [
|
|
@@ -2010,6 +2021,7 @@ class $0f5324ee3bdd9396$export$ca405048b8fb5af {
|
|
|
2010
2021
|
return $0f5324ee3bdd9396$var$getDaysInYear(date.year);
|
|
2011
2022
|
}
|
|
2012
2023
|
getYearsInEra() {
|
|
2024
|
+
// 6239 gregorian
|
|
2013
2025
|
return 9999;
|
|
2014
2026
|
}
|
|
2015
2027
|
getEras() {
|
|
@@ -2044,11 +2056,15 @@ function $4db04d1051af0f2f$var$ceToJulianDay(epoch, year, month, day) {
|
|
|
2044
2056
|
+ day - 1 // number of days for present month (1 based)
|
|
2045
2057
|
;
|
|
2046
2058
|
}
|
|
2047
|
-
function $4db04d1051af0f2f$var$julianDayToCE(
|
|
2059
|
+
function $4db04d1051af0f2f$var$julianDayToCE(epoch, jd) {
|
|
2048
2060
|
let year = Math.floor(4 * (jd - epoch) / 1461);
|
|
2049
2061
|
let month = 1 + Math.floor((jd - $4db04d1051af0f2f$var$ceToJulianDay(epoch, year, 1, 1)) / 30);
|
|
2050
2062
|
let day = jd + 1 - $4db04d1051af0f2f$var$ceToJulianDay(epoch, year, month, 1);
|
|
2051
|
-
return
|
|
2063
|
+
return [
|
|
2064
|
+
year,
|
|
2065
|
+
month,
|
|
2066
|
+
day
|
|
2067
|
+
];
|
|
2052
2068
|
}
|
|
2053
2069
|
function $4db04d1051af0f2f$var$getLeapDay(year) {
|
|
2054
2070
|
return Math.floor(year % 4 / 3);
|
|
@@ -2066,13 +2082,13 @@ function $4db04d1051af0f2f$var$getDaysInMonth(year, month) {
|
|
|
2066
2082
|
}
|
|
2067
2083
|
class $4db04d1051af0f2f$export$26ba6eab5e20cd7d {
|
|
2068
2084
|
fromJulianDay(jd) {
|
|
2069
|
-
let
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2085
|
+
let [year, month, day] = $4db04d1051af0f2f$var$julianDayToCE($4db04d1051af0f2f$var$ETHIOPIC_EPOCH, jd);
|
|
2086
|
+
let era = 'AM';
|
|
2087
|
+
if (year <= 0) {
|
|
2088
|
+
era = 'AA';
|
|
2089
|
+
year += $4db04d1051af0f2f$var$AMETE_MIHRET_DELTA;
|
|
2074
2090
|
}
|
|
2075
|
-
return
|
|
2091
|
+
return new $625ad1e1f4c43bc1$export$99faa760c7908e4f(this, era, year, month, day);
|
|
2076
2092
|
}
|
|
2077
2093
|
toJulianDay(date) {
|
|
2078
2094
|
let year = date.year;
|
|
@@ -2080,9 +2096,7 @@ class $4db04d1051af0f2f$export$26ba6eab5e20cd7d {
|
|
|
2080
2096
|
return $4db04d1051af0f2f$var$ceToJulianDay($4db04d1051af0f2f$var$ETHIOPIC_EPOCH, year, date.month, date.day);
|
|
2081
2097
|
}
|
|
2082
2098
|
getDaysInMonth(date) {
|
|
2083
|
-
|
|
2084
|
-
if (date.era === 'AA') year -= $4db04d1051af0f2f$var$AMETE_MIHRET_DELTA;
|
|
2085
|
-
return $4db04d1051af0f2f$var$getDaysInMonth(year, date.month);
|
|
2099
|
+
return $4db04d1051af0f2f$var$getDaysInMonth(date.year, date.month);
|
|
2086
2100
|
}
|
|
2087
2101
|
getMonthsInYear() {
|
|
2088
2102
|
return 13;
|
|
@@ -2090,8 +2104,11 @@ class $4db04d1051af0f2f$export$26ba6eab5e20cd7d {
|
|
|
2090
2104
|
getDaysInYear(date) {
|
|
2091
2105
|
return 365 + $4db04d1051af0f2f$var$getLeapDay(date.year);
|
|
2092
2106
|
}
|
|
2093
|
-
getYearsInEra() {
|
|
2094
|
-
|
|
2107
|
+
getYearsInEra(date) {
|
|
2108
|
+
// 9999-12-31 gregorian is 9992-20-02 ethiopic.
|
|
2109
|
+
// Round down to 9991 for the last full year.
|
|
2110
|
+
// AA 9999-01-01 ethiopic is 4506-09-30 gregorian.
|
|
2111
|
+
return date.era === 'AA' ? 9999 : 9991;
|
|
2095
2112
|
}
|
|
2096
2113
|
getEras() {
|
|
2097
2114
|
return [
|
|
@@ -2105,16 +2122,19 @@ class $4db04d1051af0f2f$export$26ba6eab5e20cd7d {
|
|
|
2105
2122
|
}
|
|
2106
2123
|
class $4db04d1051af0f2f$export$d72e0c37005a4914 extends $4db04d1051af0f2f$export$26ba6eab5e20cd7d {
|
|
2107
2124
|
fromJulianDay(jd) {
|
|
2108
|
-
let
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
return date;
|
|
2125
|
+
let [year, month, day] = $4db04d1051af0f2f$var$julianDayToCE($4db04d1051af0f2f$var$ETHIOPIC_EPOCH, jd);
|
|
2126
|
+
year += $4db04d1051af0f2f$var$AMETE_MIHRET_DELTA;
|
|
2127
|
+
return new $625ad1e1f4c43bc1$export$99faa760c7908e4f(this, 'AA', year, month, day);
|
|
2112
2128
|
}
|
|
2113
2129
|
getEras() {
|
|
2114
2130
|
return [
|
|
2115
2131
|
'AA'
|
|
2116
2132
|
];
|
|
2117
2133
|
}
|
|
2134
|
+
getYearsInEra() {
|
|
2135
|
+
// 9999-13-04 ethioaa is the maximum date, which is equivalent to 4506-09-29 gregorian.
|
|
2136
|
+
return 9999;
|
|
2137
|
+
}
|
|
2118
2138
|
constructor(...args){
|
|
2119
2139
|
super(...args);
|
|
2120
2140
|
this.identifier // also known as 'ethiopic-amete-alem' in ICU
|
|
@@ -2123,12 +2143,13 @@ class $4db04d1051af0f2f$export$d72e0c37005a4914 extends $4db04d1051af0f2f$export
|
|
|
2123
2143
|
}
|
|
2124
2144
|
class $4db04d1051af0f2f$export$fe6243cbe1a4b7c1 extends $4db04d1051af0f2f$export$26ba6eab5e20cd7d {
|
|
2125
2145
|
fromJulianDay(jd) {
|
|
2126
|
-
let
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2146
|
+
let [year, month, day] = $4db04d1051af0f2f$var$julianDayToCE($4db04d1051af0f2f$var$COPTIC_EPOCH, jd);
|
|
2147
|
+
let era = 'CE';
|
|
2148
|
+
if (year <= 0) {
|
|
2149
|
+
era = 'BCE';
|
|
2150
|
+
year = 1 - year;
|
|
2151
|
+
}
|
|
2152
|
+
return new $625ad1e1f4c43bc1$export$99faa760c7908e4f(this, era, year, month, day);
|
|
2132
2153
|
}
|
|
2133
2154
|
toJulianDay(date) {
|
|
2134
2155
|
let year = date.year;
|
|
@@ -2155,6 +2176,12 @@ class $4db04d1051af0f2f$export$fe6243cbe1a4b7c1 extends $4db04d1051af0f2f$export
|
|
|
2155
2176
|
'CE'
|
|
2156
2177
|
];
|
|
2157
2178
|
}
|
|
2179
|
+
getYearsInEra(date) {
|
|
2180
|
+
// 9999-12-30 gregorian is 9716-02-20 coptic.
|
|
2181
|
+
// Round down to 9715 for the last full year.
|
|
2182
|
+
// BCE 9999-01-01 coptic is BC 9716-06-15 gregorian.
|
|
2183
|
+
return date.era === 'BCE' ? 9999 : 9715;
|
|
2184
|
+
}
|
|
2158
2185
|
constructor(...args){
|
|
2159
2186
|
super(...args);
|
|
2160
2187
|
this.identifier = 'coptic';
|
|
@@ -2268,6 +2295,9 @@ class $8f23a04ae90a588b$export$ad991b66133851cf {
|
|
|
2268
2295
|
resolvedOptions.hourCycle = this.resolvedHourCycle;
|
|
2269
2296
|
resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';
|
|
2270
2297
|
}
|
|
2298
|
+
// Safari uses a different name for the Ethiopic (Amete Alem) calendar.
|
|
2299
|
+
// https://bugs.webkit.org/show_bug.cgi?id=241564
|
|
2300
|
+
if (resolvedOptions.calendar === 'ethiopic-amete-alem') resolvedOptions.calendar = 'ethioaa';
|
|
2271
2301
|
return resolvedOptions;
|
|
2272
2302
|
}
|
|
2273
2303
|
constructor(locale, options = {
|