@internationalized/date 3.5.3-nightly.4555 → 3.5.3-nightly.4560
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/BuddhistCalendar.main.js +54 -0
- package/dist/BuddhistCalendar.main.js.map +1 -0
- package/dist/BuddhistCalendar.mjs +49 -0
- package/dist/BuddhistCalendar.module.js +49 -0
- package/dist/BuddhistCalendar.module.js.map +1 -0
- package/dist/CalendarDate.main.js +260 -0
- package/dist/CalendarDate.main.js.map +1 -0
- package/dist/CalendarDate.mjs +252 -0
- package/dist/CalendarDate.module.js +252 -0
- package/dist/CalendarDate.module.js.map +1 -0
- package/dist/DateFormatter.main.js +145 -0
- package/dist/DateFormatter.main.js.map +1 -0
- package/dist/DateFormatter.mjs +140 -0
- package/dist/DateFormatter.module.js +140 -0
- package/dist/DateFormatter.module.js.map +1 -0
- package/dist/EthiopicCalendar.main.js +170 -0
- package/dist/EthiopicCalendar.main.js.map +1 -0
- package/dist/EthiopicCalendar.mjs +163 -0
- package/dist/EthiopicCalendar.module.js +163 -0
- package/dist/EthiopicCalendar.module.js.map +1 -0
- package/dist/GregorianCalendar.main.js +143 -0
- package/dist/GregorianCalendar.main.js.map +1 -0
- package/dist/GregorianCalendar.mjs +134 -0
- package/dist/GregorianCalendar.module.js +134 -0
- package/dist/GregorianCalendar.module.js.map +1 -0
- package/dist/HebrewCalendar.main.js +149 -0
- package/dist/HebrewCalendar.main.js.map +1 -0
- package/dist/HebrewCalendar.mjs +144 -0
- package/dist/HebrewCalendar.module.js +144 -0
- package/dist/HebrewCalendar.module.js.map +1 -0
- package/dist/IndianCalendar.main.js +107 -0
- package/dist/IndianCalendar.main.js.map +1 -0
- package/dist/IndianCalendar.mjs +102 -0
- package/dist/IndianCalendar.module.js +102 -0
- package/dist/IndianCalendar.module.js.map +1 -0
- package/dist/IslamicCalendar.main.js +164 -0
- package/dist/IslamicCalendar.main.js.map +1 -0
- package/dist/IslamicCalendar.mjs +157 -0
- package/dist/IslamicCalendar.module.js +157 -0
- package/dist/IslamicCalendar.module.js.map +1 -0
- package/dist/JapaneseCalendar.main.js +180 -0
- package/dist/JapaneseCalendar.main.js.map +1 -0
- package/dist/JapaneseCalendar.mjs +175 -0
- package/dist/JapaneseCalendar.module.js +175 -0
- package/dist/JapaneseCalendar.module.js.map +1 -0
- package/dist/PersianCalendar.main.js +81 -0
- package/dist/PersianCalendar.main.js.map +1 -0
- package/dist/PersianCalendar.mjs +76 -0
- package/dist/PersianCalendar.module.js +76 -0
- package/dist/PersianCalendar.module.js.map +1 -0
- package/dist/TaiwanCalendar.main.js +81 -0
- package/dist/TaiwanCalendar.main.js.map +1 -0
- package/dist/TaiwanCalendar.mjs +76 -0
- package/dist/TaiwanCalendar.module.js +76 -0
- package/dist/TaiwanCalendar.module.js.map +1 -0
- package/dist/conversion.main.js +236 -0
- package/dist/conversion.main.js.map +1 -0
- package/dist/conversion.mjs +218 -0
- package/dist/conversion.module.js +218 -0
- package/dist/conversion.module.js.map +1 -0
- package/dist/createCalendar.main.js +69 -0
- package/dist/createCalendar.main.js.map +1 -0
- package/dist/createCalendar.mjs +64 -0
- package/dist/createCalendar.module.js +64 -0
- package/dist/createCalendar.module.js.map +1 -0
- package/dist/import.mjs +15 -2534
- package/dist/main.js +75 -2594
- package/dist/main.js.map +1 -1
- package/dist/manipulation.main.js +362 -0
- package/dist/manipulation.main.js.map +1 -0
- package/dist/manipulation.mjs +344 -0
- package/dist/manipulation.module.js +344 -0
- package/dist/manipulation.module.js.map +1 -0
- package/dist/module.js +15 -2534
- package/dist/module.js.map +1 -1
- package/dist/queries.main.js +287 -0
- package/dist/queries.main.js.map +1 -0
- package/dist/queries.mjs +256 -0
- package/dist/queries.module.js +256 -0
- package/dist/queries.module.js.map +1 -0
- package/dist/string.main.js +171 -0
- package/dist/string.main.js.map +1 -0
- package/dist/string.mjs +156 -0
- package/dist/string.module.js +156 -0
- package/dist/string.module.js.map +1 -0
- package/dist/utils.main.js +33 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +28 -0
- package/dist/utils.module.js +28 -0
- package/dist/utils.module.js.map +1 -0
- package/dist/weekStartData.main.js +118 -0
- package/dist/weekStartData.main.js.map +1 -0
- package/dist/weekStartData.mjs +113 -0
- package/dist/weekStartData.module.js +113 -0
- package/dist/weekStartData.module.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import {CalendarDate as $35ea8db9cb2ccb90$export$99faa760c7908e4f} from "./CalendarDate.mjs";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/ // Portions of the code in this file are based on code from ICU.
|
|
14
|
+
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
15
|
+
|
|
16
|
+
const $f2f3e0e3a817edbd$var$CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)
|
|
17
|
+
const $f2f3e0e3a817edbd$var$ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)
|
|
18
|
+
const $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START = 1300;
|
|
19
|
+
const $f2f3e0e3a817edbd$var$UMALQURA_YEAR_END = 1600;
|
|
20
|
+
const $f2f3e0e3a817edbd$var$UMALQURA_START_DAYS = 460322;
|
|
21
|
+
function $f2f3e0e3a817edbd$var$islamicToJulianDay(epoch, year, month, day) {
|
|
22
|
+
return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + Math.floor((3 + 11 * year) / 30) + epoch - 1;
|
|
23
|
+
}
|
|
24
|
+
function $f2f3e0e3a817edbd$var$julianDayToIslamic(calendar, epoch, jd) {
|
|
25
|
+
let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);
|
|
26
|
+
let month = Math.min(12, Math.ceil((jd - (29 + $f2f3e0e3a817edbd$var$islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1);
|
|
27
|
+
let day = jd - $f2f3e0e3a817edbd$var$islamicToJulianDay(epoch, year, month, 1) + 1;
|
|
28
|
+
return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(calendar, year, month, day);
|
|
29
|
+
}
|
|
30
|
+
function $f2f3e0e3a817edbd$var$isLeapYear(year) {
|
|
31
|
+
return (14 + 11 * year) % 30 < 11;
|
|
32
|
+
}
|
|
33
|
+
class $f2f3e0e3a817edbd$export$2066795aadd37bfc {
|
|
34
|
+
fromJulianDay(jd) {
|
|
35
|
+
return $f2f3e0e3a817edbd$var$julianDayToIslamic(this, $f2f3e0e3a817edbd$var$CIVIL_EPOC, jd);
|
|
36
|
+
}
|
|
37
|
+
toJulianDay(date) {
|
|
38
|
+
return $f2f3e0e3a817edbd$var$islamicToJulianDay($f2f3e0e3a817edbd$var$CIVIL_EPOC, date.year, date.month, date.day);
|
|
39
|
+
}
|
|
40
|
+
getDaysInMonth(date) {
|
|
41
|
+
let length = 29 + date.month % 2;
|
|
42
|
+
if (date.month === 12 && $f2f3e0e3a817edbd$var$isLeapYear(date.year)) length++;
|
|
43
|
+
return length;
|
|
44
|
+
}
|
|
45
|
+
getMonthsInYear() {
|
|
46
|
+
return 12;
|
|
47
|
+
}
|
|
48
|
+
getDaysInYear(date) {
|
|
49
|
+
return $f2f3e0e3a817edbd$var$isLeapYear(date.year) ? 355 : 354;
|
|
50
|
+
}
|
|
51
|
+
getYearsInEra() {
|
|
52
|
+
// 9999 gregorian
|
|
53
|
+
return 9665;
|
|
54
|
+
}
|
|
55
|
+
getEras() {
|
|
56
|
+
return [
|
|
57
|
+
"AH"
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
constructor(){
|
|
61
|
+
this.identifier = "islamic-civil";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class $f2f3e0e3a817edbd$export$37f0887f2f9d22f7 extends $f2f3e0e3a817edbd$export$2066795aadd37bfc {
|
|
65
|
+
fromJulianDay(jd) {
|
|
66
|
+
return $f2f3e0e3a817edbd$var$julianDayToIslamic(this, $f2f3e0e3a817edbd$var$ASTRONOMICAL_EPOC, jd);
|
|
67
|
+
}
|
|
68
|
+
toJulianDay(date) {
|
|
69
|
+
return $f2f3e0e3a817edbd$var$islamicToJulianDay($f2f3e0e3a817edbd$var$ASTRONOMICAL_EPOC, date.year, date.month, date.day);
|
|
70
|
+
}
|
|
71
|
+
constructor(...args){
|
|
72
|
+
super(...args);
|
|
73
|
+
this.identifier = "islamic-tbla";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Generated by scripts/generate-umalqura.js
|
|
77
|
+
const $f2f3e0e3a817edbd$var$UMALQURA_DATA = "qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=";
|
|
78
|
+
let $f2f3e0e3a817edbd$var$UMALQURA_MONTHLENGTH;
|
|
79
|
+
let $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE;
|
|
80
|
+
function $f2f3e0e3a817edbd$var$umalquraYearStart(year) {
|
|
81
|
+
return $f2f3e0e3a817edbd$var$UMALQURA_START_DAYS + $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE[year - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START];
|
|
82
|
+
}
|
|
83
|
+
function $f2f3e0e3a817edbd$var$umalquraMonthLength(year, month) {
|
|
84
|
+
let idx = year - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START;
|
|
85
|
+
let mask = 0x01 << 11 - (month - 1);
|
|
86
|
+
if (($f2f3e0e3a817edbd$var$UMALQURA_MONTHLENGTH[idx] & mask) === 0) return 29;
|
|
87
|
+
else return 30;
|
|
88
|
+
}
|
|
89
|
+
function $f2f3e0e3a817edbd$var$umalquraMonthStart(year, month) {
|
|
90
|
+
let day = $f2f3e0e3a817edbd$var$umalquraYearStart(year);
|
|
91
|
+
for(let i = 1; i < month; i++)day += $f2f3e0e3a817edbd$var$umalquraMonthLength(year, i);
|
|
92
|
+
return day;
|
|
93
|
+
}
|
|
94
|
+
function $f2f3e0e3a817edbd$var$umalquraYearLength(year) {
|
|
95
|
+
return $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE[year + 1 - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START] - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE[year - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START];
|
|
96
|
+
}
|
|
97
|
+
class $f2f3e0e3a817edbd$export$5baab4758c231076 extends $f2f3e0e3a817edbd$export$2066795aadd37bfc {
|
|
98
|
+
fromJulianDay(jd) {
|
|
99
|
+
let days = jd - $f2f3e0e3a817edbd$var$CIVIL_EPOC;
|
|
100
|
+
let startDays = $f2f3e0e3a817edbd$var$umalquraYearStart($f2f3e0e3a817edbd$var$UMALQURA_YEAR_START);
|
|
101
|
+
let endDays = $f2f3e0e3a817edbd$var$umalquraYearStart($f2f3e0e3a817edbd$var$UMALQURA_YEAR_END);
|
|
102
|
+
if (days < startDays || days > endDays) return super.fromJulianDay(jd);
|
|
103
|
+
else {
|
|
104
|
+
let y = $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START - 1;
|
|
105
|
+
let m = 1;
|
|
106
|
+
let d = 1;
|
|
107
|
+
while(d > 0){
|
|
108
|
+
y++;
|
|
109
|
+
d = days - $f2f3e0e3a817edbd$var$umalquraYearStart(y) + 1;
|
|
110
|
+
let yearLength = $f2f3e0e3a817edbd$var$umalquraYearLength(y);
|
|
111
|
+
if (d === yearLength) {
|
|
112
|
+
m = 12;
|
|
113
|
+
break;
|
|
114
|
+
} else if (d < yearLength) {
|
|
115
|
+
let monthLength = $f2f3e0e3a817edbd$var$umalquraMonthLength(y, m);
|
|
116
|
+
m = 1;
|
|
117
|
+
while(d > monthLength){
|
|
118
|
+
d -= monthLength;
|
|
119
|
+
m++;
|
|
120
|
+
monthLength = $f2f3e0e3a817edbd$var$umalquraMonthLength(y, m);
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(this, y, m, days - $f2f3e0e3a817edbd$var$umalquraMonthStart(y, m) + 1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
toJulianDay(date) {
|
|
129
|
+
if (date.year < $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START || date.year > $f2f3e0e3a817edbd$var$UMALQURA_YEAR_END) return super.toJulianDay(date);
|
|
130
|
+
return $f2f3e0e3a817edbd$var$CIVIL_EPOC + $f2f3e0e3a817edbd$var$umalquraMonthStart(date.year, date.month) + (date.day - 1);
|
|
131
|
+
}
|
|
132
|
+
getDaysInMonth(date) {
|
|
133
|
+
if (date.year < $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START || date.year > $f2f3e0e3a817edbd$var$UMALQURA_YEAR_END) return super.getDaysInMonth(date);
|
|
134
|
+
return $f2f3e0e3a817edbd$var$umalquraMonthLength(date.year, date.month);
|
|
135
|
+
}
|
|
136
|
+
getDaysInYear(date) {
|
|
137
|
+
if (date.year < $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START || date.year > $f2f3e0e3a817edbd$var$UMALQURA_YEAR_END) return super.getDaysInYear(date);
|
|
138
|
+
return $f2f3e0e3a817edbd$var$umalquraYearLength(date.year);
|
|
139
|
+
}
|
|
140
|
+
constructor(){
|
|
141
|
+
super();
|
|
142
|
+
this.identifier = "islamic-umalqura";
|
|
143
|
+
if (!$f2f3e0e3a817edbd$var$UMALQURA_MONTHLENGTH) $f2f3e0e3a817edbd$var$UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob($f2f3e0e3a817edbd$var$UMALQURA_DATA), (c)=>c.charCodeAt(0)).buffer);
|
|
144
|
+
if (!$f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE) {
|
|
145
|
+
$f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE = new Uint32Array($f2f3e0e3a817edbd$var$UMALQURA_YEAR_END - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START + 1);
|
|
146
|
+
let yearStart = 0;
|
|
147
|
+
for(let year = $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START; year <= $f2f3e0e3a817edbd$var$UMALQURA_YEAR_END; year++){
|
|
148
|
+
$f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE[year - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START] = yearStart;
|
|
149
|
+
for(let i = 1; i <= 12; i++)yearStart += $f2f3e0e3a817edbd$var$umalquraMonthLength(year, i);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
export {$f2f3e0e3a817edbd$export$2066795aadd37bfc as IslamicCivilCalendar, $f2f3e0e3a817edbd$export$37f0887f2f9d22f7 as IslamicTabularCalendar, $f2f3e0e3a817edbd$export$5baab4758c231076 as IslamicUmalquraCalendar};
|
|
157
|
+
//# sourceMappingURL=IslamicCalendar.mjs.map
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import {CalendarDate as $35ea8db9cb2ccb90$export$99faa760c7908e4f} from "./CalendarDate.module.js";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/ // Portions of the code in this file are based on code from ICU.
|
|
14
|
+
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
15
|
+
|
|
16
|
+
const $f2f3e0e3a817edbd$var$CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)
|
|
17
|
+
const $f2f3e0e3a817edbd$var$ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)
|
|
18
|
+
const $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START = 1300;
|
|
19
|
+
const $f2f3e0e3a817edbd$var$UMALQURA_YEAR_END = 1600;
|
|
20
|
+
const $f2f3e0e3a817edbd$var$UMALQURA_START_DAYS = 460322;
|
|
21
|
+
function $f2f3e0e3a817edbd$var$islamicToJulianDay(epoch, year, month, day) {
|
|
22
|
+
return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + Math.floor((3 + 11 * year) / 30) + epoch - 1;
|
|
23
|
+
}
|
|
24
|
+
function $f2f3e0e3a817edbd$var$julianDayToIslamic(calendar, epoch, jd) {
|
|
25
|
+
let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);
|
|
26
|
+
let month = Math.min(12, Math.ceil((jd - (29 + $f2f3e0e3a817edbd$var$islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1);
|
|
27
|
+
let day = jd - $f2f3e0e3a817edbd$var$islamicToJulianDay(epoch, year, month, 1) + 1;
|
|
28
|
+
return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(calendar, year, month, day);
|
|
29
|
+
}
|
|
30
|
+
function $f2f3e0e3a817edbd$var$isLeapYear(year) {
|
|
31
|
+
return (14 + 11 * year) % 30 < 11;
|
|
32
|
+
}
|
|
33
|
+
class $f2f3e0e3a817edbd$export$2066795aadd37bfc {
|
|
34
|
+
fromJulianDay(jd) {
|
|
35
|
+
return $f2f3e0e3a817edbd$var$julianDayToIslamic(this, $f2f3e0e3a817edbd$var$CIVIL_EPOC, jd);
|
|
36
|
+
}
|
|
37
|
+
toJulianDay(date) {
|
|
38
|
+
return $f2f3e0e3a817edbd$var$islamicToJulianDay($f2f3e0e3a817edbd$var$CIVIL_EPOC, date.year, date.month, date.day);
|
|
39
|
+
}
|
|
40
|
+
getDaysInMonth(date) {
|
|
41
|
+
let length = 29 + date.month % 2;
|
|
42
|
+
if (date.month === 12 && $f2f3e0e3a817edbd$var$isLeapYear(date.year)) length++;
|
|
43
|
+
return length;
|
|
44
|
+
}
|
|
45
|
+
getMonthsInYear() {
|
|
46
|
+
return 12;
|
|
47
|
+
}
|
|
48
|
+
getDaysInYear(date) {
|
|
49
|
+
return $f2f3e0e3a817edbd$var$isLeapYear(date.year) ? 355 : 354;
|
|
50
|
+
}
|
|
51
|
+
getYearsInEra() {
|
|
52
|
+
// 9999 gregorian
|
|
53
|
+
return 9665;
|
|
54
|
+
}
|
|
55
|
+
getEras() {
|
|
56
|
+
return [
|
|
57
|
+
"AH"
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
constructor(){
|
|
61
|
+
this.identifier = "islamic-civil";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class $f2f3e0e3a817edbd$export$37f0887f2f9d22f7 extends $f2f3e0e3a817edbd$export$2066795aadd37bfc {
|
|
65
|
+
fromJulianDay(jd) {
|
|
66
|
+
return $f2f3e0e3a817edbd$var$julianDayToIslamic(this, $f2f3e0e3a817edbd$var$ASTRONOMICAL_EPOC, jd);
|
|
67
|
+
}
|
|
68
|
+
toJulianDay(date) {
|
|
69
|
+
return $f2f3e0e3a817edbd$var$islamicToJulianDay($f2f3e0e3a817edbd$var$ASTRONOMICAL_EPOC, date.year, date.month, date.day);
|
|
70
|
+
}
|
|
71
|
+
constructor(...args){
|
|
72
|
+
super(...args);
|
|
73
|
+
this.identifier = "islamic-tbla";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Generated by scripts/generate-umalqura.js
|
|
77
|
+
const $f2f3e0e3a817edbd$var$UMALQURA_DATA = "qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=";
|
|
78
|
+
let $f2f3e0e3a817edbd$var$UMALQURA_MONTHLENGTH;
|
|
79
|
+
let $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE;
|
|
80
|
+
function $f2f3e0e3a817edbd$var$umalquraYearStart(year) {
|
|
81
|
+
return $f2f3e0e3a817edbd$var$UMALQURA_START_DAYS + $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE[year - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START];
|
|
82
|
+
}
|
|
83
|
+
function $f2f3e0e3a817edbd$var$umalquraMonthLength(year, month) {
|
|
84
|
+
let idx = year - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START;
|
|
85
|
+
let mask = 0x01 << 11 - (month - 1);
|
|
86
|
+
if (($f2f3e0e3a817edbd$var$UMALQURA_MONTHLENGTH[idx] & mask) === 0) return 29;
|
|
87
|
+
else return 30;
|
|
88
|
+
}
|
|
89
|
+
function $f2f3e0e3a817edbd$var$umalquraMonthStart(year, month) {
|
|
90
|
+
let day = $f2f3e0e3a817edbd$var$umalquraYearStart(year);
|
|
91
|
+
for(let i = 1; i < month; i++)day += $f2f3e0e3a817edbd$var$umalquraMonthLength(year, i);
|
|
92
|
+
return day;
|
|
93
|
+
}
|
|
94
|
+
function $f2f3e0e3a817edbd$var$umalquraYearLength(year) {
|
|
95
|
+
return $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE[year + 1 - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START] - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE[year - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START];
|
|
96
|
+
}
|
|
97
|
+
class $f2f3e0e3a817edbd$export$5baab4758c231076 extends $f2f3e0e3a817edbd$export$2066795aadd37bfc {
|
|
98
|
+
fromJulianDay(jd) {
|
|
99
|
+
let days = jd - $f2f3e0e3a817edbd$var$CIVIL_EPOC;
|
|
100
|
+
let startDays = $f2f3e0e3a817edbd$var$umalquraYearStart($f2f3e0e3a817edbd$var$UMALQURA_YEAR_START);
|
|
101
|
+
let endDays = $f2f3e0e3a817edbd$var$umalquraYearStart($f2f3e0e3a817edbd$var$UMALQURA_YEAR_END);
|
|
102
|
+
if (days < startDays || days > endDays) return super.fromJulianDay(jd);
|
|
103
|
+
else {
|
|
104
|
+
let y = $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START - 1;
|
|
105
|
+
let m = 1;
|
|
106
|
+
let d = 1;
|
|
107
|
+
while(d > 0){
|
|
108
|
+
y++;
|
|
109
|
+
d = days - $f2f3e0e3a817edbd$var$umalquraYearStart(y) + 1;
|
|
110
|
+
let yearLength = $f2f3e0e3a817edbd$var$umalquraYearLength(y);
|
|
111
|
+
if (d === yearLength) {
|
|
112
|
+
m = 12;
|
|
113
|
+
break;
|
|
114
|
+
} else if (d < yearLength) {
|
|
115
|
+
let monthLength = $f2f3e0e3a817edbd$var$umalquraMonthLength(y, m);
|
|
116
|
+
m = 1;
|
|
117
|
+
while(d > monthLength){
|
|
118
|
+
d -= monthLength;
|
|
119
|
+
m++;
|
|
120
|
+
monthLength = $f2f3e0e3a817edbd$var$umalquraMonthLength(y, m);
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(this, y, m, days - $f2f3e0e3a817edbd$var$umalquraMonthStart(y, m) + 1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
toJulianDay(date) {
|
|
129
|
+
if (date.year < $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START || date.year > $f2f3e0e3a817edbd$var$UMALQURA_YEAR_END) return super.toJulianDay(date);
|
|
130
|
+
return $f2f3e0e3a817edbd$var$CIVIL_EPOC + $f2f3e0e3a817edbd$var$umalquraMonthStart(date.year, date.month) + (date.day - 1);
|
|
131
|
+
}
|
|
132
|
+
getDaysInMonth(date) {
|
|
133
|
+
if (date.year < $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START || date.year > $f2f3e0e3a817edbd$var$UMALQURA_YEAR_END) return super.getDaysInMonth(date);
|
|
134
|
+
return $f2f3e0e3a817edbd$var$umalquraMonthLength(date.year, date.month);
|
|
135
|
+
}
|
|
136
|
+
getDaysInYear(date) {
|
|
137
|
+
if (date.year < $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START || date.year > $f2f3e0e3a817edbd$var$UMALQURA_YEAR_END) return super.getDaysInYear(date);
|
|
138
|
+
return $f2f3e0e3a817edbd$var$umalquraYearLength(date.year);
|
|
139
|
+
}
|
|
140
|
+
constructor(){
|
|
141
|
+
super();
|
|
142
|
+
this.identifier = "islamic-umalqura";
|
|
143
|
+
if (!$f2f3e0e3a817edbd$var$UMALQURA_MONTHLENGTH) $f2f3e0e3a817edbd$var$UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob($f2f3e0e3a817edbd$var$UMALQURA_DATA), (c)=>c.charCodeAt(0)).buffer);
|
|
144
|
+
if (!$f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE) {
|
|
145
|
+
$f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE = new Uint32Array($f2f3e0e3a817edbd$var$UMALQURA_YEAR_END - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START + 1);
|
|
146
|
+
let yearStart = 0;
|
|
147
|
+
for(let year = $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START; year <= $f2f3e0e3a817edbd$var$UMALQURA_YEAR_END; year++){
|
|
148
|
+
$f2f3e0e3a817edbd$var$UMALQURA_YEAR_START_TABLE[year - $f2f3e0e3a817edbd$var$UMALQURA_YEAR_START] = yearStart;
|
|
149
|
+
for(let i = 1; i <= 12; i++)yearStart += $f2f3e0e3a817edbd$var$umalquraMonthLength(year, i);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
export {$f2f3e0e3a817edbd$export$2066795aadd37bfc as IslamicCivilCalendar, $f2f3e0e3a817edbd$export$37f0887f2f9d22f7 as IslamicTabularCalendar, $f2f3e0e3a817edbd$export$5baab4758c231076 as IslamicUmalquraCalendar};
|
|
157
|
+
//# sourceMappingURL=IslamicCalendar.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;AAKhG,MAAM,mCAAa,SAAS,gFAAgF;AAC5G,MAAM,0CAAoB,SAAS,4CAA4C;AAC/E,MAAM,4CAAsB;AAC5B,M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C,OAAO,0CAAoB,GAAG;gBACxD,IAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IACvB,aAAa,0CAAoB,MAAM;YAE3C;QACF;IACF;AA0DF","sources":["packages/@internationalized/date/src/calendars/IslamicCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar} from '../types';\nimport {CalendarDate} from '../CalendarDate';\n\nconst CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)\nconst ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)\nconst UMALQURA_YEAR_START = 1300;\nconst UMALQURA_YEAR_END = 1600;\nconst UMALQURA_START_DAYS = 460322;\n\nfunction islamicToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return day +\n Math.ceil(29.5 * (month - 1)) +\n (year - 1) * 354 +\n Math.floor((3 + 11 * year) / 30) +\n epoch - 1;\n}\n\nfunction julianDayToIslamic(calendar: Calendar, epoch: number, jd: number) {\n let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);\n let month = Math.min(12, Math.ceil((jd - (29 + islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1);\n let day = jd - islamicToJulianDay(epoch, year, month, 1) + 1;\n\n return new CalendarDate(calendar, year, month, day);\n}\n\nfunction isLeapYear(year: number): boolean {\n return (14 + 11 * year) % 30 < 11;\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The civil variant uses simple arithmetic rules rather than astronomical calculations to approximate\n * the traditional calendar, which is based on sighting of the crescent moon. It uses Friday, July 16 622 CE (Julian) as the epoch.\n * Each year has 12 months, with either 354 or 355 days depending on whether it is a leap year.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicCivilCalendar implements Calendar {\n identifier = 'islamic-civil';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, CIVIL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return islamicToJulianDay(CIVIL_EPOC, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let length = 29 + date.month % 2;\n if (date.month === 12 && isLeapYear(date.year)) {\n length++;\n }\n\n return length;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 355 : 354;\n }\n\n getYearsInEra(): number {\n // 9999 gregorian\n return 9665;\n }\n\n getEras() {\n return ['AH'];\n }\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The tabular variant uses simple arithmetic rules rather than astronomical calculations to approximate\n * the traditional calendar, which is based on sighting of the crescent moon. It uses Thursday, July 15 622 CE (Julian) as the epoch.\n * Each year has 12 months, with either 354 or 355 days depending on whether it is a leap year.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicTabularCalendar extends IslamicCivilCalendar {\n identifier = 'islamic-tbla';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, ASTRONOMICAL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return islamicToJulianDay(ASTRONOMICAL_EPOC, date.year, date.month, date.day);\n }\n}\n\n// Generated by scripts/generate-umalqura.js\nconst UMALQURA_DATA = 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=';\nlet UMALQURA_MONTHLENGTH: Uint16Array;\nlet UMALQURA_YEAR_START_TABLE: Uint32Array;\n\nfunction umalquraYearStart(year: number): number {\n return UMALQURA_START_DAYS + UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\nfunction umalquraMonthLength(year: number, month: number): number {\n let idx = (year - UMALQURA_YEAR_START);\n let mask = (0x01 << (11 - (month - 1)));\n if ((UMALQURA_MONTHLENGTH[idx] & mask) === 0) {\n return 29;\n } else {\n return 30;\n }\n}\n\nfunction umalquraMonthStart(year: number, month: number): number {\n let day = umalquraYearStart(year);\n for (let i = 1; i < month; i++) {\n day += umalquraMonthLength(year, i);\n }\n return day;\n}\n\nfunction umalquraYearLength(year: number): number {\n return UMALQURA_YEAR_START_TABLE[year + 1 - UMALQURA_YEAR_START] - UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The Umalqura variant is primarily used in Saudi Arabia. It is a lunar calendar, based on astronomical\n * calculations that predict the sighting of a crescent moon. Month and year lengths vary between years\n * depending on these calculations.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicUmalquraCalendar extends IslamicCivilCalendar {\n identifier = 'islamic-umalqura';\n\n constructor() {\n super();\n if (!UMALQURA_MONTHLENGTH) {\n UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob(UMALQURA_DATA), c => c.charCodeAt(0)).buffer);\n }\n\n if (!UMALQURA_YEAR_START_TABLE) {\n UMALQURA_YEAR_START_TABLE = new Uint32Array(UMALQURA_YEAR_END - UMALQURA_YEAR_START + 1);\n\n let yearStart = 0;\n for (let year = UMALQURA_YEAR_START; year <= UMALQURA_YEAR_END; year++) {\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START] = yearStart;\n for (let i = 1; i <= 12; i++) {\n yearStart += umalquraMonthLength(year, i);\n }\n }\n }\n }\n\n fromJulianDay(jd: number): CalendarDate {\n let days = jd - CIVIL_EPOC;\n let startDays = umalquraYearStart(UMALQURA_YEAR_START);\n let endDays = umalquraYearStart(UMALQURA_YEAR_END);\n if (days < startDays || days > endDays) {\n return super.fromJulianDay(jd);\n } else {\n let y = UMALQURA_YEAR_START - 1;\n let m = 1;\n let d = 1;\n while (d > 0) {\n y++;\n d = days - umalquraYearStart(y) + 1;\n let yearLength = umalquraYearLength(y);\n if (d === yearLength) {\n m = 12;\n break;\n } else if (d < yearLength) {\n let monthLength = umalquraMonthLength(y, m);\n m = 1;\n while (d > monthLength) {\n d -= monthLength;\n m++;\n monthLength = umalquraMonthLength(y, m);\n }\n break;\n }\n }\n\n return new CalendarDate(this, y, m, (days - umalquraMonthStart(y, m) + 1));\n }\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.toJulianDay(date);\n }\n\n return CIVIL_EPOC + umalquraMonthStart(date.year, date.month) + (date.day - 1);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInMonth(date);\n }\n\n return umalquraMonthLength(date.year, date.month);\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInYear(date);\n }\n\n return umalquraYearLength(date.year);\n }\n}\n"],"names":[],"version":3,"file":"IslamicCalendar.module.js.map"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
var $625ad1e1f4c43bc1$exports = require("./CalendarDate.main.js");
|
|
2
|
+
var $af14c9812fdceb33$exports = require("./GregorianCalendar.main.js");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "JapaneseCalendar", () => $b0ac0602ef646b2c$export$b746ab2b60cdffbf);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/ // Portions of the code in this file are based on code from the TC39 Temporal proposal.
|
|
21
|
+
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const $b0ac0602ef646b2c$var$ERA_START_DATES = [
|
|
25
|
+
[
|
|
26
|
+
1868,
|
|
27
|
+
9,
|
|
28
|
+
8
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
1912,
|
|
32
|
+
7,
|
|
33
|
+
30
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
1926,
|
|
37
|
+
12,
|
|
38
|
+
25
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
1989,
|
|
42
|
+
1,
|
|
43
|
+
8
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
2019,
|
|
47
|
+
5,
|
|
48
|
+
1
|
|
49
|
+
]
|
|
50
|
+
];
|
|
51
|
+
const $b0ac0602ef646b2c$var$ERA_END_DATES = [
|
|
52
|
+
[
|
|
53
|
+
1912,
|
|
54
|
+
7,
|
|
55
|
+
29
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
1926,
|
|
59
|
+
12,
|
|
60
|
+
24
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
1989,
|
|
64
|
+
1,
|
|
65
|
+
7
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
2019,
|
|
69
|
+
4,
|
|
70
|
+
30
|
|
71
|
+
]
|
|
72
|
+
];
|
|
73
|
+
const $b0ac0602ef646b2c$var$ERA_ADDENDS = [
|
|
74
|
+
1867,
|
|
75
|
+
1911,
|
|
76
|
+
1925,
|
|
77
|
+
1988,
|
|
78
|
+
2018
|
|
79
|
+
];
|
|
80
|
+
const $b0ac0602ef646b2c$var$ERA_NAMES = [
|
|
81
|
+
"meiji",
|
|
82
|
+
"taisho",
|
|
83
|
+
"showa",
|
|
84
|
+
"heisei",
|
|
85
|
+
"reiwa"
|
|
86
|
+
];
|
|
87
|
+
function $b0ac0602ef646b2c$var$findEraFromGregorianDate(date) {
|
|
88
|
+
const idx = $b0ac0602ef646b2c$var$ERA_START_DATES.findIndex(([year, month, day])=>{
|
|
89
|
+
if (date.year < year) return true;
|
|
90
|
+
if (date.year === year && date.month < month) return true;
|
|
91
|
+
if (date.year === year && date.month === month && date.day < day) return true;
|
|
92
|
+
return false;
|
|
93
|
+
});
|
|
94
|
+
if (idx === -1) return $b0ac0602ef646b2c$var$ERA_START_DATES.length - 1;
|
|
95
|
+
if (idx === 0) return 0;
|
|
96
|
+
return idx - 1;
|
|
97
|
+
}
|
|
98
|
+
function $b0ac0602ef646b2c$var$toGregorian(date) {
|
|
99
|
+
let eraAddend = $b0ac0602ef646b2c$var$ERA_ADDENDS[$b0ac0602ef646b2c$var$ERA_NAMES.indexOf(date.era)];
|
|
100
|
+
if (!eraAddend) throw new Error("Unknown era: " + date.era);
|
|
101
|
+
return new (0, $625ad1e1f4c43bc1$exports.CalendarDate)(date.year + eraAddend, date.month, date.day);
|
|
102
|
+
}
|
|
103
|
+
class $b0ac0602ef646b2c$export$b746ab2b60cdffbf extends (0, $af14c9812fdceb33$exports.GregorianCalendar) {
|
|
104
|
+
fromJulianDay(jd) {
|
|
105
|
+
let date = super.fromJulianDay(jd);
|
|
106
|
+
let era = $b0ac0602ef646b2c$var$findEraFromGregorianDate(date);
|
|
107
|
+
return new (0, $625ad1e1f4c43bc1$exports.CalendarDate)(this, $b0ac0602ef646b2c$var$ERA_NAMES[era], date.year - $b0ac0602ef646b2c$var$ERA_ADDENDS[era], date.month, date.day);
|
|
108
|
+
}
|
|
109
|
+
toJulianDay(date) {
|
|
110
|
+
return super.toJulianDay($b0ac0602ef646b2c$var$toGregorian(date));
|
|
111
|
+
}
|
|
112
|
+
balanceDate(date) {
|
|
113
|
+
let gregorianDate = $b0ac0602ef646b2c$var$toGregorian(date);
|
|
114
|
+
let era = $b0ac0602ef646b2c$var$findEraFromGregorianDate(gregorianDate);
|
|
115
|
+
if ($b0ac0602ef646b2c$var$ERA_NAMES[era] !== date.era) {
|
|
116
|
+
date.era = $b0ac0602ef646b2c$var$ERA_NAMES[era];
|
|
117
|
+
date.year = gregorianDate.year - $b0ac0602ef646b2c$var$ERA_ADDENDS[era];
|
|
118
|
+
}
|
|
119
|
+
// Constrain in case we went before the first supported era.
|
|
120
|
+
this.constrainDate(date);
|
|
121
|
+
}
|
|
122
|
+
constrainDate(date) {
|
|
123
|
+
let idx = $b0ac0602ef646b2c$var$ERA_NAMES.indexOf(date.era);
|
|
124
|
+
let end = $b0ac0602ef646b2c$var$ERA_END_DATES[idx];
|
|
125
|
+
if (end != null) {
|
|
126
|
+
let [endYear, endMonth, endDay] = end;
|
|
127
|
+
// Constrain the year to the maximum possible value in the era.
|
|
128
|
+
// Then constrain the month and day fields within that.
|
|
129
|
+
let maxYear = endYear - $b0ac0602ef646b2c$var$ERA_ADDENDS[idx];
|
|
130
|
+
date.year = Math.max(1, Math.min(maxYear, date.year));
|
|
131
|
+
if (date.year === maxYear) {
|
|
132
|
+
date.month = Math.min(endMonth, date.month);
|
|
133
|
+
if (date.month === endMonth) date.day = Math.min(endDay, date.day);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (date.year === 1 && idx >= 0) {
|
|
137
|
+
let [, startMonth, startDay] = $b0ac0602ef646b2c$var$ERA_START_DATES[idx];
|
|
138
|
+
date.month = Math.max(startMonth, date.month);
|
|
139
|
+
if (date.month === startMonth) date.day = Math.max(startDay, date.day);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
getEras() {
|
|
143
|
+
return $b0ac0602ef646b2c$var$ERA_NAMES;
|
|
144
|
+
}
|
|
145
|
+
getYearsInEra(date) {
|
|
146
|
+
// Get the number of years in the era, taking into account the date's month and day fields.
|
|
147
|
+
let era = $b0ac0602ef646b2c$var$ERA_NAMES.indexOf(date.era);
|
|
148
|
+
let cur = $b0ac0602ef646b2c$var$ERA_START_DATES[era];
|
|
149
|
+
let next = $b0ac0602ef646b2c$var$ERA_START_DATES[era + 1];
|
|
150
|
+
if (next == null) // 9999 gregorian is the maximum year allowed.
|
|
151
|
+
return 9999 - cur[0] + 1;
|
|
152
|
+
let years = next[0] - cur[0];
|
|
153
|
+
if (date.month < next[1] || date.month === next[1] && date.day < next[2]) years++;
|
|
154
|
+
return years;
|
|
155
|
+
}
|
|
156
|
+
getDaysInMonth(date) {
|
|
157
|
+
return super.getDaysInMonth($b0ac0602ef646b2c$var$toGregorian(date));
|
|
158
|
+
}
|
|
159
|
+
getMinimumMonthInYear(date) {
|
|
160
|
+
let start = $b0ac0602ef646b2c$var$getMinimums(date);
|
|
161
|
+
return start ? start[1] : 1;
|
|
162
|
+
}
|
|
163
|
+
getMinimumDayInMonth(date) {
|
|
164
|
+
let start = $b0ac0602ef646b2c$var$getMinimums(date);
|
|
165
|
+
return start && date.month === start[1] ? start[2] : 1;
|
|
166
|
+
}
|
|
167
|
+
constructor(...args){
|
|
168
|
+
super(...args);
|
|
169
|
+
this.identifier = "japanese";
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function $b0ac0602ef646b2c$var$getMinimums(date) {
|
|
173
|
+
if (date.year === 1) {
|
|
174
|
+
let idx = $b0ac0602ef646b2c$var$ERA_NAMES.indexOf(date.era);
|
|
175
|
+
return $b0ac0602ef646b2c$var$ERA_START_DATES[idx];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
//# sourceMappingURL=JapaneseCalendar.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IA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C,IAAI,KAAK,KAAK,KAAK,YACjB,KAAK,GAAG,GAAG,KAAK,GAAG,CAAC,UAAU,KAAK,GAAG;QAE1C;IACF;IAEA,UAAU;QACR,OAAO;IACT;IAEA,cAAc,IAAqB,EAAU;QAC3C,2FAA2F;QAC3F,IAAI,MAAM,gCAAU,OAAO,CAAC,KAAK,GAAG;QACpC,IAAI,MAAM,qCAAe,CAAC,IAAI;QAC9B,IAAI,OAAO,qCAAe,CAAC,MAAM,EAAE;QACnC,IAAI,QAAQ,MACV,8CAA8C;QAC9C,OAAO,OAAO,GAAG,CAAC,EAAE,GAAG;QAGzB,IAAI,QAAQ,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE;QAE5B,IAAI,KAAK,KAAK,GAAG,IAAI,CAAC,EAAE,IAAK,KAAK,KAAK,KAAK,IAAI,CAAC,EAAE,IAAI,KAAK,GAAG,GAAG,IAAI,CAAC,EAAE,EACvE;QAGF,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,sBAAsB,IAAqB,EAAU;QACnD,IAAI,QAAQ,kCAAY;QACxB,OAAO,QAAQ,KAAK,CAAC,EAAE,GAAG;IAC5B;IAEA,qBAAqB,IAAqB,EAAU;QAClD,IAAI,QAAQ,kCAAY;QACxB,OAAO,SAAS,KAAK,KAAK,KAAK,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,GAAG;IACvD;;;aAhGA,aAAa;;AAiGf;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,KAAK,IAAI,KAAK,GAAG;QACnB,IAAI,MAAM,gCAAU,OAAO,CAAC,KAAK,GAAG;QACpC,OAAO,qCAAe,CAAC,IAAI;IAC7B;AACF","sources":["packages/@internationalized/date/src/calendars/JapaneseCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst ERA_START_DATES = [[1868, 9, 8], [1912, 7, 30], [1926, 12, 25], [1989, 1, 8], [2019, 5, 1]];\nconst ERA_END_DATES = [[1912, 7, 29], [1926, 12, 24], [1989, 1, 7], [2019, 4, 30]];\nconst ERA_ADDENDS = [1867, 1911, 1925, 1988, 2018];\nconst ERA_NAMES = ['meiji', 'taisho', 'showa', 'heisei', 'reiwa'];\n\nfunction findEraFromGregorianDate(date: AnyCalendarDate) {\n const idx = ERA_START_DATES.findIndex(([year, month, day]) => {\n if (date.year < year) {\n return true;\n }\n\n if (date.year === year && date.month < month) {\n return true;\n }\n\n if (date.year === year && date.month === month && date.day < day) {\n return true;\n }\n\n return false;\n });\n\n if (idx === -1) {\n return ERA_START_DATES.length - 1;\n }\n\n if (idx === 0) {\n return 0;\n }\n\n return idx - 1;\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let eraAddend = ERA_ADDENDS[ERA_NAMES.indexOf(date.era)];\n if (!eraAddend) {\n throw new Error('Unknown era: ' + date.era);\n }\n\n return new CalendarDate(\n date.year + eraAddend,\n date.month,\n date.day\n );\n}\n\n/**\n * The Japanese calendar is based on the Gregorian calendar, but with eras for the reign of each Japanese emperor.\n * Whenever a new emperor ascends to the throne, a new era begins and the year starts again from 1.\n * Note that eras before 1868 (Gregorian) are not currently supported by this implementation.\n */\nexport class JapaneseCalendar extends GregorianCalendar {\n identifier = 'japanese';\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let era = findEraFromGregorianDate(date);\n\n return new CalendarDate(\n this,\n ERA_NAMES[era],\n date.year - ERA_ADDENDS[era],\n date.month,\n date.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>) {\n let gregorianDate = toGregorian(date);\n let era = findEraFromGregorianDate(gregorianDate);\n\n if (ERA_NAMES[era] !== date.era) {\n date.era = ERA_NAMES[era];\n date.year = gregorianDate.year - ERA_ADDENDS[era];\n }\n\n // Constrain in case we went before the first supported era.\n this.constrainDate(date);\n }\n\n constrainDate(date: Mutable<AnyCalendarDate>) {\n let idx = ERA_NAMES.indexOf(date.era);\n let end = ERA_END_DATES[idx];\n if (end != null) {\n let [endYear, endMonth, endDay] = end;\n\n // Constrain the year to the maximum possible value in the era.\n // Then constrain the month and day fields within that.\n let maxYear = endYear - ERA_ADDENDS[idx];\n date.year = Math.max(1, Math.min(maxYear, date.year));\n if (date.year === maxYear) {\n date.month = Math.min(endMonth, date.month);\n\n if (date.month === endMonth) {\n date.day = Math.min(endDay, date.day);\n }\n }\n }\n\n if (date.year === 1 && idx >= 0) {\n let [, startMonth, startDay] = ERA_START_DATES[idx];\n date.month = Math.max(startMonth, date.month);\n\n if (date.month === startMonth) {\n date.day = Math.max(startDay, date.day);\n }\n }\n }\n\n getEras() {\n return ERA_NAMES;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // Get the number of years in the era, taking into account the date's month and day fields.\n let era = ERA_NAMES.indexOf(date.era);\n let cur = ERA_START_DATES[era];\n let next = ERA_START_DATES[era + 1];\n if (next == null) {\n // 9999 gregorian is the maximum year allowed.\n return 9999 - cur[0] + 1;\n }\n\n let years = next[0] - cur[0];\n\n if (date.month < next[1] || (date.month === next[1] && date.day < next[2])) {\n years++;\n }\n\n return years;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getMinimumMonthInYear(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start ? start[1] : 1;\n }\n\n getMinimumDayInMonth(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start && date.month === start[1] ? start[2] : 1;\n }\n}\n\nfunction getMinimums(date: AnyCalendarDate) {\n if (date.year === 1) {\n let idx = ERA_NAMES.indexOf(date.era);\n return ERA_START_DATES[idx];\n }\n}\n"],"names":[],"version":3,"file":"JapaneseCalendar.main.js.map"}
|