@internationalized/date 3.11.0 → 3.12.1
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/index.cjs +113 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +45 -0
- package/dist/index.mjs.map +1 -0
- package/dist/{CalendarDate.main.js → private/CalendarDate.cjs} +102 -120
- package/dist/private/CalendarDate.cjs.map +1 -0
- package/dist/{CalendarDate.mjs → private/CalendarDate.js} +65 -65
- package/dist/private/CalendarDate.js.map +1 -0
- package/dist/{CalendarDate.module.js → private/CalendarDate.mjs} +99 -117
- package/dist/private/CalendarDate.mjs.map +1 -0
- package/dist/{DateFormatter.main.js → private/DateFormatter.cjs} +27 -27
- package/dist/private/DateFormatter.cjs.map +1 -0
- package/dist/{DateFormatter.module.js → private/DateFormatter.js} +23 -23
- package/dist/{DateFormatter.module.js.map → private/DateFormatter.js.map} +1 -1
- package/dist/{DateFormatter.mjs → private/DateFormatter.mjs} +27 -27
- package/dist/private/DateFormatter.mjs.map +1 -0
- package/dist/{BuddhistCalendar.main.js → private/calendars/BuddhistCalendar.cjs} +13 -13
- package/dist/{BuddhistCalendar.main.js.map → private/calendars/BuddhistCalendar.cjs.map} +1 -1
- package/dist/{BuddhistCalendar.module.js → private/calendars/BuddhistCalendar.js} +13 -13
- package/dist/{BuddhistCalendar.module.js.map → private/calendars/BuddhistCalendar.js.map} +1 -1
- package/dist/{BuddhistCalendar.mjs → private/calendars/BuddhistCalendar.mjs} +13 -13
- package/dist/private/calendars/BuddhistCalendar.mjs.map +1 -0
- package/dist/{EthiopicCalendar.main.js → private/calendars/EthiopicCalendar.cjs} +32 -32
- package/dist/{EthiopicCalendar.main.js.map → private/calendars/EthiopicCalendar.cjs.map} +1 -1
- package/dist/{EthiopicCalendar.module.js → private/calendars/EthiopicCalendar.js} +30 -30
- package/dist/{EthiopicCalendar.module.js.map → private/calendars/EthiopicCalendar.js.map} +1 -1
- package/dist/{EthiopicCalendar.mjs → private/calendars/EthiopicCalendar.mjs} +30 -30
- package/dist/private/calendars/EthiopicCalendar.mjs.map +1 -0
- package/dist/{GregorianCalendar.main.js → private/calendars/GregorianCalendar.cjs} +31 -31
- package/dist/{GregorianCalendar.main.js.map → private/calendars/GregorianCalendar.cjs.map} +1 -1
- package/dist/{GregorianCalendar.module.js → private/calendars/GregorianCalendar.js} +27 -27
- package/dist/{GregorianCalendar.module.js.map → private/calendars/GregorianCalendar.js.map} +1 -1
- package/dist/{GregorianCalendar.mjs → private/calendars/GregorianCalendar.mjs} +27 -27
- package/dist/private/calendars/GregorianCalendar.mjs.map +1 -0
- package/dist/{HebrewCalendar.main.js → private/calendars/HebrewCalendar.cjs} +44 -44
- package/dist/{HebrewCalendar.main.js.map → private/calendars/HebrewCalendar.cjs.map} +1 -1
- package/dist/{HebrewCalendar.module.js → private/calendars/HebrewCalendar.js} +44 -44
- package/dist/{HebrewCalendar.module.js.map → private/calendars/HebrewCalendar.js.map} +1 -1
- package/dist/{HebrewCalendar.mjs → private/calendars/HebrewCalendar.mjs} +44 -44
- package/dist/private/calendars/HebrewCalendar.mjs.map +1 -0
- package/dist/{IndianCalendar.main.js → private/calendars/IndianCalendar.cjs} +20 -20
- package/dist/{IndianCalendar.main.js.map → private/calendars/IndianCalendar.cjs.map} +1 -1
- package/dist/{IndianCalendar.module.js → private/calendars/IndianCalendar.js} +20 -20
- package/dist/{IndianCalendar.module.js.map → private/calendars/IndianCalendar.js.map} +1 -1
- package/dist/{IndianCalendar.mjs → private/calendars/IndianCalendar.mjs} +20 -20
- package/dist/private/calendars/IndianCalendar.mjs.map +1 -0
- package/dist/private/calendars/IslamicCalendar.cjs +168 -0
- package/dist/private/calendars/IslamicCalendar.cjs.map +1 -0
- package/dist/private/calendars/IslamicCalendar.js +161 -0
- package/dist/{IslamicCalendar.module.js.map → private/calendars/IslamicCalendar.js.map} +1 -1
- package/dist/private/calendars/IslamicCalendar.mjs +161 -0
- package/dist/private/calendars/IslamicCalendar.mjs.map +1 -0
- package/dist/{JapaneseCalendar.main.js → private/calendars/JapaneseCalendar.cjs} +37 -37
- package/dist/{JapaneseCalendar.main.js.map → private/calendars/JapaneseCalendar.cjs.map} +1 -1
- package/dist/{JapaneseCalendar.module.js → private/calendars/JapaneseCalendar.js} +37 -37
- package/dist/{JapaneseCalendar.module.js.map → private/calendars/JapaneseCalendar.js.map} +1 -1
- package/dist/{JapaneseCalendar.mjs → private/calendars/JapaneseCalendar.mjs} +37 -37
- package/dist/private/calendars/JapaneseCalendar.mjs.map +1 -0
- package/dist/{PersianCalendar.main.js → private/calendars/PersianCalendar.cjs} +13 -13
- package/dist/{PersianCalendar.main.js.map → private/calendars/PersianCalendar.cjs.map} +1 -1
- package/dist/{PersianCalendar.module.js → private/calendars/PersianCalendar.js} +13 -13
- package/dist/{PersianCalendar.module.js.map → private/calendars/PersianCalendar.js.map} +1 -1
- package/dist/{PersianCalendar.mjs → private/calendars/PersianCalendar.mjs} +13 -13
- package/dist/private/calendars/PersianCalendar.mjs.map +1 -0
- package/dist/{TaiwanCalendar.main.js → private/calendars/TaiwanCalendar.cjs} +20 -20
- package/dist/{TaiwanCalendar.main.js.map → private/calendars/TaiwanCalendar.cjs.map} +1 -1
- package/dist/private/calendars/TaiwanCalendar.js +75 -0
- package/dist/{TaiwanCalendar.module.js.map → private/calendars/TaiwanCalendar.js.map} +1 -1
- package/dist/{TaiwanCalendar.mjs → private/calendars/TaiwanCalendar.mjs} +20 -20
- package/dist/private/calendars/TaiwanCalendar.mjs.map +1 -0
- package/dist/private/conversion.cjs +241 -0
- package/dist/private/conversion.cjs.map +1 -0
- package/dist/private/conversion.js +222 -0
- package/dist/private/conversion.js.map +1 -0
- package/dist/private/conversion.mjs +222 -0
- package/dist/private/conversion.mjs.map +1 -0
- package/dist/private/createCalendar.cjs +69 -0
- package/dist/{createCalendar.main.js.map → private/createCalendar.cjs.map} +1 -1
- package/dist/private/createCalendar.js +64 -0
- package/dist/{createCalendar.module.js.map → private/createCalendar.js.map} +1 -1
- package/dist/private/createCalendar.mjs +64 -0
- package/dist/private/createCalendar.mjs.map +1 -0
- package/dist/{manipulation.main.js → private/manipulation.cjs} +106 -109
- package/dist/private/manipulation.cjs.map +1 -0
- package/dist/{manipulation.mjs → private/manipulation.js} +88 -88
- package/dist/{manipulation.module.js.map → private/manipulation.js.map} +1 -1
- package/dist/{manipulation.module.js → private/manipulation.mjs} +93 -96
- package/dist/private/manipulation.mjs.map +1 -0
- package/dist/private/queries.cjs +359 -0
- package/dist/private/queries.cjs.map +1 -0
- package/dist/private/queries.js +326 -0
- package/dist/private/queries.js.map +1 -0
- package/dist/private/queries.mjs +324 -0
- package/dist/private/queries.mjs.map +1 -0
- package/dist/private/string.cjs +181 -0
- package/dist/private/string.cjs.map +1 -0
- package/dist/{string.mjs → private/string.js} +64 -64
- package/dist/{string.module.js.map → private/string.js.map} +1 -1
- package/dist/private/string.mjs +166 -0
- package/dist/private/string.mjs.map +1 -0
- package/dist/{utils.main.js → private/utils.cjs} +3 -3
- package/dist/{utils.main.js.map → private/utils.cjs.map} +1 -1
- package/dist/{utils.module.js → private/utils.js} +3 -3
- package/dist/{utils.module.js.map → private/utils.js.map} +1 -1
- package/dist/{utils.mjs → private/utils.mjs} +3 -3
- package/dist/private/utils.mjs.map +1 -0
- package/dist/{weekStartData.main.js → private/weekStartData.cjs} +3 -3
- package/dist/{weekStartData.main.js.map → private/weekStartData.cjs.map} +1 -1
- package/dist/{weekStartData.module.js → private/weekStartData.js} +3 -3
- package/dist/{weekStartData.module.js.map → private/weekStartData.js.map} +1 -1
- package/dist/{weekStartData.mjs → private/weekStartData.mjs} +3 -3
- package/dist/private/weekStartData.mjs.map +1 -0
- package/dist/types/src/CalendarDate.d.ts +177 -0
- package/dist/types/src/DateFormatter.d.ts +21 -0
- package/dist/types/src/calendars/BuddhistCalendar.d.ts +16 -0
- package/dist/types/src/calendars/EthiopicCalendar.d.ts +45 -0
- package/dist/types/src/calendars/GregorianCalendar.d.ts +25 -0
- package/dist/types/src/calendars/HebrewCalendar.d.ts +21 -0
- package/dist/types/src/calendars/IndianCalendar.d.ts +17 -0
- package/dist/types/src/calendars/IslamicCalendar.d.ts +48 -0
- package/dist/types/src/calendars/JapaneseCalendar.d.ts +21 -0
- package/dist/types/src/calendars/PersianCalendar.d.ts +19 -0
- package/dist/types/src/calendars/TaiwanCalendar.d.ts +19 -0
- package/dist/types/src/conversion.d.ts +42 -0
- package/dist/types/src/createCalendar.d.ts +3 -0
- package/dist/types/src/index.d.ts +17 -0
- package/dist/types/src/manipulation.d.ts +25 -0
- package/dist/types/src/queries.d.ts +87 -0
- package/dist/types/src/string.d.ts +35 -0
- package/dist/types/src/types.d.ts +132 -0
- package/dist/types/src/utils.d.ts +4 -0
- package/dist/types/src/weekStartData.d.ts +97 -0
- package/package.json +26 -11
- package/src/CalendarDate.ts +2 -0
- package/src/conversion.ts +10 -3
- package/src/index.ts +2 -0
- package/src/queries.ts +9 -3
- package/dist/CalendarDate.main.js.map +0 -1
- package/dist/CalendarDate.module.js.map +0 -1
- package/dist/DateFormatter.main.js.map +0 -1
- package/dist/IslamicCalendar.main.js +0 -168
- package/dist/IslamicCalendar.main.js.map +0 -1
- package/dist/IslamicCalendar.mjs +0 -161
- package/dist/IslamicCalendar.module.js +0 -161
- package/dist/TaiwanCalendar.module.js +0 -75
- package/dist/conversion.main.js +0 -236
- package/dist/conversion.main.js.map +0 -1
- package/dist/conversion.mjs +0 -218
- package/dist/conversion.module.js +0 -218
- package/dist/conversion.module.js.map +0 -1
- package/dist/createCalendar.main.js +0 -69
- package/dist/createCalendar.mjs +0 -64
- package/dist/createCalendar.module.js +0 -64
- package/dist/import.mjs +0 -45
- package/dist/main.js +0 -112
- package/dist/main.js.map +0 -1
- package/dist/manipulation.main.js.map +0 -1
- package/dist/module.js +0 -45
- package/dist/module.js.map +0 -1
- package/dist/queries.main.js +0 -354
- package/dist/queries.main.js.map +0 -1
- package/dist/queries.mjs +0 -320
- package/dist/queries.module.js +0 -320
- package/dist/queries.module.js.map +0 -1
- package/dist/string.main.js +0 -190
- package/dist/string.main.js.map +0 -1
- package/dist/string.module.js +0 -175
- package/dist/types.d.ts +0 -668
- package/dist/types.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {CalendarDate as $
|
|
2
|
-
import {GregorianCalendar as $
|
|
1
|
+
import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js";
|
|
2
|
+
import {GregorianCalendar as $f25df78da1f6b40f$export$80ee6245ec4f29ec} from "./GregorianCalendar.js";
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -15,7 +15,7 @@ import {GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./
|
|
|
15
15
|
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
const $
|
|
18
|
+
const $97f08bcb2befa667$var$ERA_START_DATES = [
|
|
19
19
|
[
|
|
20
20
|
1868,
|
|
21
21
|
9,
|
|
@@ -42,7 +42,7 @@ const $62225008020f0a13$var$ERA_START_DATES = [
|
|
|
42
42
|
1
|
|
43
43
|
]
|
|
44
44
|
];
|
|
45
|
-
const $
|
|
45
|
+
const $97f08bcb2befa667$var$ERA_END_DATES = [
|
|
46
46
|
[
|
|
47
47
|
1912,
|
|
48
48
|
7,
|
|
@@ -64,63 +64,63 @@ const $62225008020f0a13$var$ERA_END_DATES = [
|
|
|
64
64
|
30
|
|
65
65
|
]
|
|
66
66
|
];
|
|
67
|
-
const $
|
|
67
|
+
const $97f08bcb2befa667$var$ERA_ADDENDS = [
|
|
68
68
|
1867,
|
|
69
69
|
1911,
|
|
70
70
|
1925,
|
|
71
71
|
1988,
|
|
72
72
|
2018
|
|
73
73
|
];
|
|
74
|
-
const $
|
|
74
|
+
const $97f08bcb2befa667$var$ERA_NAMES = [
|
|
75
75
|
'meiji',
|
|
76
76
|
'taisho',
|
|
77
77
|
'showa',
|
|
78
78
|
'heisei',
|
|
79
79
|
'reiwa'
|
|
80
80
|
];
|
|
81
|
-
function $
|
|
82
|
-
const idx = $
|
|
81
|
+
function $97f08bcb2befa667$var$findEraFromGregorianDate(date) {
|
|
82
|
+
const idx = $97f08bcb2befa667$var$ERA_START_DATES.findIndex(([year, month, day])=>{
|
|
83
83
|
if (date.year < year) return true;
|
|
84
84
|
if (date.year === year && date.month < month) return true;
|
|
85
85
|
if (date.year === year && date.month === month && date.day < day) return true;
|
|
86
86
|
return false;
|
|
87
87
|
});
|
|
88
|
-
if (idx === -1) return $
|
|
88
|
+
if (idx === -1) return $97f08bcb2befa667$var$ERA_START_DATES.length - 1;
|
|
89
89
|
if (idx === 0) return 0;
|
|
90
90
|
return idx - 1;
|
|
91
91
|
}
|
|
92
|
-
function $
|
|
93
|
-
let eraAddend = $
|
|
92
|
+
function $97f08bcb2befa667$var$toGregorian(date) {
|
|
93
|
+
let eraAddend = $97f08bcb2befa667$var$ERA_ADDENDS[$97f08bcb2befa667$var$ERA_NAMES.indexOf(date.era)];
|
|
94
94
|
if (!eraAddend) throw new Error('Unknown era: ' + date.era);
|
|
95
|
-
return new (0, $
|
|
95
|
+
return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(date.year + eraAddend, date.month, date.day);
|
|
96
96
|
}
|
|
97
|
-
class $
|
|
97
|
+
class $97f08bcb2befa667$export$b746ab2b60cdffbf extends (0, $f25df78da1f6b40f$export$80ee6245ec4f29ec) {
|
|
98
98
|
fromJulianDay(jd) {
|
|
99
99
|
let date = super.fromJulianDay(jd);
|
|
100
|
-
let era = $
|
|
101
|
-
return new (0, $
|
|
100
|
+
let era = $97f08bcb2befa667$var$findEraFromGregorianDate(date);
|
|
101
|
+
return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, $97f08bcb2befa667$var$ERA_NAMES[era], date.year - $97f08bcb2befa667$var$ERA_ADDENDS[era], date.month, date.day);
|
|
102
102
|
}
|
|
103
103
|
toJulianDay(date) {
|
|
104
|
-
return super.toJulianDay($
|
|
104
|
+
return super.toJulianDay($97f08bcb2befa667$var$toGregorian(date));
|
|
105
105
|
}
|
|
106
106
|
balanceDate(date) {
|
|
107
|
-
let gregorianDate = $
|
|
108
|
-
let era = $
|
|
109
|
-
if ($
|
|
110
|
-
date.era = $
|
|
111
|
-
date.year = gregorianDate.year - $
|
|
107
|
+
let gregorianDate = $97f08bcb2befa667$var$toGregorian(date);
|
|
108
|
+
let era = $97f08bcb2befa667$var$findEraFromGregorianDate(gregorianDate);
|
|
109
|
+
if ($97f08bcb2befa667$var$ERA_NAMES[era] !== date.era) {
|
|
110
|
+
date.era = $97f08bcb2befa667$var$ERA_NAMES[era];
|
|
111
|
+
date.year = gregorianDate.year - $97f08bcb2befa667$var$ERA_ADDENDS[era];
|
|
112
112
|
}
|
|
113
113
|
// Constrain in case we went before the first supported era.
|
|
114
114
|
this.constrainDate(date);
|
|
115
115
|
}
|
|
116
116
|
constrainDate(date) {
|
|
117
|
-
let idx = $
|
|
118
|
-
let end = $
|
|
117
|
+
let idx = $97f08bcb2befa667$var$ERA_NAMES.indexOf(date.era);
|
|
118
|
+
let end = $97f08bcb2befa667$var$ERA_END_DATES[idx];
|
|
119
119
|
if (end != null) {
|
|
120
120
|
let [endYear, endMonth, endDay] = end;
|
|
121
121
|
// Constrain the year to the maximum possible value in the era.
|
|
122
122
|
// Then constrain the month and day fields within that.
|
|
123
|
-
let maxYear = endYear - $
|
|
123
|
+
let maxYear = endYear - $97f08bcb2befa667$var$ERA_ADDENDS[idx];
|
|
124
124
|
date.year = Math.max(1, Math.min(maxYear, date.year));
|
|
125
125
|
if (date.year === maxYear) {
|
|
126
126
|
date.month = Math.min(endMonth, date.month);
|
|
@@ -128,19 +128,19 @@ class $62225008020f0a13$export$b746ab2b60cdffbf extends (0, $3b62074eb05584b2$ex
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
if (date.year === 1 && idx >= 0) {
|
|
131
|
-
let [, startMonth, startDay] = $
|
|
131
|
+
let [, startMonth, startDay] = $97f08bcb2befa667$var$ERA_START_DATES[idx];
|
|
132
132
|
date.month = Math.max(startMonth, date.month);
|
|
133
133
|
if (date.month === startMonth) date.day = Math.max(startDay, date.day);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
getEras() {
|
|
137
|
-
return $
|
|
137
|
+
return $97f08bcb2befa667$var$ERA_NAMES;
|
|
138
138
|
}
|
|
139
139
|
getYearsInEra(date) {
|
|
140
140
|
// Get the number of years in the era, taking into account the date's month and day fields.
|
|
141
|
-
let era = $
|
|
142
|
-
let cur = $
|
|
143
|
-
let next = $
|
|
141
|
+
let era = $97f08bcb2befa667$var$ERA_NAMES.indexOf(date.era);
|
|
142
|
+
let cur = $97f08bcb2befa667$var$ERA_START_DATES[era];
|
|
143
|
+
let next = $97f08bcb2befa667$var$ERA_START_DATES[era + 1];
|
|
144
144
|
if (next == null) // 9999 gregorian is the maximum year allowed.
|
|
145
145
|
return 9999 - cur[0] + 1;
|
|
146
146
|
let years = next[0] - cur[0];
|
|
@@ -148,27 +148,27 @@ class $62225008020f0a13$export$b746ab2b60cdffbf extends (0, $3b62074eb05584b2$ex
|
|
|
148
148
|
return years;
|
|
149
149
|
}
|
|
150
150
|
getDaysInMonth(date) {
|
|
151
|
-
return super.getDaysInMonth($
|
|
151
|
+
return super.getDaysInMonth($97f08bcb2befa667$var$toGregorian(date));
|
|
152
152
|
}
|
|
153
153
|
getMinimumMonthInYear(date) {
|
|
154
|
-
let start = $
|
|
154
|
+
let start = $97f08bcb2befa667$var$getMinimums(date);
|
|
155
155
|
return start ? start[1] : 1;
|
|
156
156
|
}
|
|
157
157
|
getMinimumDayInMonth(date) {
|
|
158
|
-
let start = $
|
|
158
|
+
let start = $97f08bcb2befa667$var$getMinimums(date);
|
|
159
159
|
return start && date.month === start[1] ? start[2] : 1;
|
|
160
160
|
}
|
|
161
161
|
constructor(...args){
|
|
162
162
|
super(...args), this.identifier = 'japanese';
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
function $
|
|
165
|
+
function $97f08bcb2befa667$var$getMinimums(date) {
|
|
166
166
|
if (date.year === 1) {
|
|
167
|
-
let idx = $
|
|
168
|
-
return $
|
|
167
|
+
let idx = $97f08bcb2befa667$var$ERA_NAMES.indexOf(date.era);
|
|
168
|
+
return $97f08bcb2befa667$var$ERA_START_DATES[idx];
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
|
|
173
|
-
export {$
|
|
174
|
-
//# sourceMappingURL=JapaneseCalendar.
|
|
173
|
+
export {$97f08bcb2befa667$export$b746ab2b60cdffbf as JapaneseCalendar};
|
|
174
|
+
//# sourceMappingURL=JapaneseCalendar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IAAC;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAE;CAAC;AACjG,MAAM,sCAAgB;IAAC;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;CAAC;AAClF,MAAM,oCAAc;IAAC;IAAM;IAAM;IAAM;IAAM;CAAK;AAClD,MAAM,kCAAY;IAAC;IAAS;IAAU;IAAS;IAAU;CAAQ;AAEjE,SAAS,+CAAyB,IAAqB;IACrD,MAAM,MAAM,sCAAgB,SAAS,CAAC,CAAC,CAAC,MAAM,OAAO,IAAI;QACvD,IAAI,KAAK,IAAI,GAAG,MACd,OAAO;QAGT,IAAI,KAAK,IAAI,KAAK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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;;QAjGK,qBACL,aAAiC;;AAiGnC;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, CalendarIdentifier} 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: CalendarIdentifier = '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): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>): void {\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>): void {\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(): string[] {\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.
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IAAC;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM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UAAoB;QAClB,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;;QAjGK,qBACL,aAAiC;;AAiGnC;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, CalendarIdentifier} 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: CalendarIdentifier = '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): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>): void {\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>): void {\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(): string[] {\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.js.map"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {CalendarDate as $
|
|
2
|
-
import {GregorianCalendar as $
|
|
1
|
+
import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f} from "../CalendarDate.mjs";
|
|
2
|
+
import {GregorianCalendar as $93635573935797de$export$80ee6245ec4f29ec} from "./GregorianCalendar.mjs";
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -15,7 +15,7 @@ import {GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./
|
|
|
15
15
|
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
const $
|
|
18
|
+
const $34b940b49ba042df$var$ERA_START_DATES = [
|
|
19
19
|
[
|
|
20
20
|
1868,
|
|
21
21
|
9,
|
|
@@ -42,7 +42,7 @@ const $62225008020f0a13$var$ERA_START_DATES = [
|
|
|
42
42
|
1
|
|
43
43
|
]
|
|
44
44
|
];
|
|
45
|
-
const $
|
|
45
|
+
const $34b940b49ba042df$var$ERA_END_DATES = [
|
|
46
46
|
[
|
|
47
47
|
1912,
|
|
48
48
|
7,
|
|
@@ -64,63 +64,63 @@ const $62225008020f0a13$var$ERA_END_DATES = [
|
|
|
64
64
|
30
|
|
65
65
|
]
|
|
66
66
|
];
|
|
67
|
-
const $
|
|
67
|
+
const $34b940b49ba042df$var$ERA_ADDENDS = [
|
|
68
68
|
1867,
|
|
69
69
|
1911,
|
|
70
70
|
1925,
|
|
71
71
|
1988,
|
|
72
72
|
2018
|
|
73
73
|
];
|
|
74
|
-
const $
|
|
74
|
+
const $34b940b49ba042df$var$ERA_NAMES = [
|
|
75
75
|
'meiji',
|
|
76
76
|
'taisho',
|
|
77
77
|
'showa',
|
|
78
78
|
'heisei',
|
|
79
79
|
'reiwa'
|
|
80
80
|
];
|
|
81
|
-
function $
|
|
82
|
-
const idx = $
|
|
81
|
+
function $34b940b49ba042df$var$findEraFromGregorianDate(date) {
|
|
82
|
+
const idx = $34b940b49ba042df$var$ERA_START_DATES.findIndex(([year, month, day])=>{
|
|
83
83
|
if (date.year < year) return true;
|
|
84
84
|
if (date.year === year && date.month < month) return true;
|
|
85
85
|
if (date.year === year && date.month === month && date.day < day) return true;
|
|
86
86
|
return false;
|
|
87
87
|
});
|
|
88
|
-
if (idx === -1) return $
|
|
88
|
+
if (idx === -1) return $34b940b49ba042df$var$ERA_START_DATES.length - 1;
|
|
89
89
|
if (idx === 0) return 0;
|
|
90
90
|
return idx - 1;
|
|
91
91
|
}
|
|
92
|
-
function $
|
|
93
|
-
let eraAddend = $
|
|
92
|
+
function $34b940b49ba042df$var$toGregorian(date) {
|
|
93
|
+
let eraAddend = $34b940b49ba042df$var$ERA_ADDENDS[$34b940b49ba042df$var$ERA_NAMES.indexOf(date.era)];
|
|
94
94
|
if (!eraAddend) throw new Error('Unknown era: ' + date.era);
|
|
95
|
-
return new (0, $
|
|
95
|
+
return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(date.year + eraAddend, date.month, date.day);
|
|
96
96
|
}
|
|
97
|
-
class $
|
|
97
|
+
class $34b940b49ba042df$export$b746ab2b60cdffbf extends (0, $93635573935797de$export$80ee6245ec4f29ec) {
|
|
98
98
|
fromJulianDay(jd) {
|
|
99
99
|
let date = super.fromJulianDay(jd);
|
|
100
|
-
let era = $
|
|
101
|
-
return new (0, $
|
|
100
|
+
let era = $34b940b49ba042df$var$findEraFromGregorianDate(date);
|
|
101
|
+
return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, $34b940b49ba042df$var$ERA_NAMES[era], date.year - $34b940b49ba042df$var$ERA_ADDENDS[era], date.month, date.day);
|
|
102
102
|
}
|
|
103
103
|
toJulianDay(date) {
|
|
104
|
-
return super.toJulianDay($
|
|
104
|
+
return super.toJulianDay($34b940b49ba042df$var$toGregorian(date));
|
|
105
105
|
}
|
|
106
106
|
balanceDate(date) {
|
|
107
|
-
let gregorianDate = $
|
|
108
|
-
let era = $
|
|
109
|
-
if ($
|
|
110
|
-
date.era = $
|
|
111
|
-
date.year = gregorianDate.year - $
|
|
107
|
+
let gregorianDate = $34b940b49ba042df$var$toGregorian(date);
|
|
108
|
+
let era = $34b940b49ba042df$var$findEraFromGregorianDate(gregorianDate);
|
|
109
|
+
if ($34b940b49ba042df$var$ERA_NAMES[era] !== date.era) {
|
|
110
|
+
date.era = $34b940b49ba042df$var$ERA_NAMES[era];
|
|
111
|
+
date.year = gregorianDate.year - $34b940b49ba042df$var$ERA_ADDENDS[era];
|
|
112
112
|
}
|
|
113
113
|
// Constrain in case we went before the first supported era.
|
|
114
114
|
this.constrainDate(date);
|
|
115
115
|
}
|
|
116
116
|
constrainDate(date) {
|
|
117
|
-
let idx = $
|
|
118
|
-
let end = $
|
|
117
|
+
let idx = $34b940b49ba042df$var$ERA_NAMES.indexOf(date.era);
|
|
118
|
+
let end = $34b940b49ba042df$var$ERA_END_DATES[idx];
|
|
119
119
|
if (end != null) {
|
|
120
120
|
let [endYear, endMonth, endDay] = end;
|
|
121
121
|
// Constrain the year to the maximum possible value in the era.
|
|
122
122
|
// Then constrain the month and day fields within that.
|
|
123
|
-
let maxYear = endYear - $
|
|
123
|
+
let maxYear = endYear - $34b940b49ba042df$var$ERA_ADDENDS[idx];
|
|
124
124
|
date.year = Math.max(1, Math.min(maxYear, date.year));
|
|
125
125
|
if (date.year === maxYear) {
|
|
126
126
|
date.month = Math.min(endMonth, date.month);
|
|
@@ -128,19 +128,19 @@ class $62225008020f0a13$export$b746ab2b60cdffbf extends (0, $3b62074eb05584b2$ex
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
if (date.year === 1 && idx >= 0) {
|
|
131
|
-
let [, startMonth, startDay] = $
|
|
131
|
+
let [, startMonth, startDay] = $34b940b49ba042df$var$ERA_START_DATES[idx];
|
|
132
132
|
date.month = Math.max(startMonth, date.month);
|
|
133
133
|
if (date.month === startMonth) date.day = Math.max(startDay, date.day);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
getEras() {
|
|
137
|
-
return $
|
|
137
|
+
return $34b940b49ba042df$var$ERA_NAMES;
|
|
138
138
|
}
|
|
139
139
|
getYearsInEra(date) {
|
|
140
140
|
// Get the number of years in the era, taking into account the date's month and day fields.
|
|
141
|
-
let era = $
|
|
142
|
-
let cur = $
|
|
143
|
-
let next = $
|
|
141
|
+
let era = $34b940b49ba042df$var$ERA_NAMES.indexOf(date.era);
|
|
142
|
+
let cur = $34b940b49ba042df$var$ERA_START_DATES[era];
|
|
143
|
+
let next = $34b940b49ba042df$var$ERA_START_DATES[era + 1];
|
|
144
144
|
if (next == null) // 9999 gregorian is the maximum year allowed.
|
|
145
145
|
return 9999 - cur[0] + 1;
|
|
146
146
|
let years = next[0] - cur[0];
|
|
@@ -148,27 +148,27 @@ class $62225008020f0a13$export$b746ab2b60cdffbf extends (0, $3b62074eb05584b2$ex
|
|
|
148
148
|
return years;
|
|
149
149
|
}
|
|
150
150
|
getDaysInMonth(date) {
|
|
151
|
-
return super.getDaysInMonth($
|
|
151
|
+
return super.getDaysInMonth($34b940b49ba042df$var$toGregorian(date));
|
|
152
152
|
}
|
|
153
153
|
getMinimumMonthInYear(date) {
|
|
154
|
-
let start = $
|
|
154
|
+
let start = $34b940b49ba042df$var$getMinimums(date);
|
|
155
155
|
return start ? start[1] : 1;
|
|
156
156
|
}
|
|
157
157
|
getMinimumDayInMonth(date) {
|
|
158
|
-
let start = $
|
|
158
|
+
let start = $34b940b49ba042df$var$getMinimums(date);
|
|
159
159
|
return start && date.month === start[1] ? start[2] : 1;
|
|
160
160
|
}
|
|
161
161
|
constructor(...args){
|
|
162
162
|
super(...args), this.identifier = 'japanese';
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
function $
|
|
165
|
+
function $34b940b49ba042df$var$getMinimums(date) {
|
|
166
166
|
if (date.year === 1) {
|
|
167
|
-
let idx = $
|
|
168
|
-
return $
|
|
167
|
+
let idx = $34b940b49ba042df$var$ERA_NAMES.indexOf(date.era);
|
|
168
|
+
return $34b940b49ba042df$var$ERA_START_DATES[idx];
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
|
|
173
|
-
export {$
|
|
174
|
-
//# sourceMappingURL=JapaneseCalendar.
|
|
173
|
+
export {$34b940b49ba042df$export$b746ab2b60cdffbf as JapaneseCalendar};
|
|
174
|
+
//# sourceMappingURL=JapaneseCalendar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IAAC;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAE;CAAC;AACjG,MAAM,sCAAgB;IAAC;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;CAAC;AAClF,MAAM,oCAAc;IAAC;IAAM;IAAM;IAAM;IAAM;CAAK;AAClD,MAAM,kCAAY;IAAC;IAAS;IAAU;IAAS;IAAU;CAAQ;AAEjE,SAAS,+CAAyB,IAAqB;IACrD,MAAM,MAAM,sCAAgB,SAAS,CAAC,CAAC,CAAC,MAAM,OAAO,IAAI;QACvD,IAAI,KAAK,IA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,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;;QAjGK,qBACL,aAAiC;;AAiGnC;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, CalendarIdentifier} 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: CalendarIdentifier = '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): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>): void {\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>): void {\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(): string[] {\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.mjs.map"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
1
|
+
var $c51b7e0106f45dea$exports = require("../CalendarDate.cjs");
|
|
2
|
+
var $09f945753a699862$exports = require("../utils.cjs");
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
function $parcel$export(e, n, v, s) {
|
|
6
6
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
$parcel$export(module.exports, "PersianCalendar", ()
|
|
9
|
+
$parcel$export(module.exports, "PersianCalendar", function () { return $4100faec94dc031c$export$37fccdbfd14c5939; });
|
|
10
10
|
/*
|
|
11
11
|
* Copyright 2020 Adobe. All rights reserved.
|
|
12
12
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -21,9 +21,9 @@ $parcel$export(module.exports, "PersianCalendar", () => $3c060181fc7249ae$export
|
|
|
21
21
|
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
const $
|
|
24
|
+
const $4100faec94dc031c$var$PERSIAN_EPOCH = 1948320;
|
|
25
25
|
// Number of days from the start of the year to the start of each month.
|
|
26
|
-
const $
|
|
26
|
+
const $4100faec94dc031c$var$MONTH_START = [
|
|
27
27
|
0,
|
|
28
28
|
31,
|
|
29
29
|
62,
|
|
@@ -37,19 +37,19 @@ const $3c060181fc7249ae$var$MONTH_START = [
|
|
|
37
37
|
306,
|
|
38
38
|
336 // Esfand
|
|
39
39
|
];
|
|
40
|
-
class $
|
|
40
|
+
class $4100faec94dc031c$export$37fccdbfd14c5939 {
|
|
41
41
|
fromJulianDay(jd) {
|
|
42
|
-
let daysSinceEpoch = jd - $
|
|
42
|
+
let daysSinceEpoch = jd - $4100faec94dc031c$var$PERSIAN_EPOCH;
|
|
43
43
|
let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);
|
|
44
44
|
let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);
|
|
45
45
|
let dayOfYear = daysSinceEpoch - farvardin1;
|
|
46
46
|
let month = dayOfYear < 216 ? Math.floor(dayOfYear / 31) : Math.floor((dayOfYear - 6) / 30);
|
|
47
|
-
let day = dayOfYear - $
|
|
48
|
-
return new (0, $
|
|
47
|
+
let day = dayOfYear - $4100faec94dc031c$var$MONTH_START[month] + 1;
|
|
48
|
+
return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, year, month + 1, day);
|
|
49
49
|
}
|
|
50
50
|
toJulianDay(date) {
|
|
51
|
-
let jd = $
|
|
52
|
-
jd += $
|
|
51
|
+
let jd = $4100faec94dc031c$var$PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);
|
|
52
|
+
jd += $4100faec94dc031c$var$MONTH_START[date.month - 1];
|
|
53
53
|
jd += date.day;
|
|
54
54
|
return jd;
|
|
55
55
|
}
|
|
@@ -59,7 +59,7 @@ class $3c060181fc7249ae$export$37fccdbfd14c5939 {
|
|
|
59
59
|
getDaysInMonth(date) {
|
|
60
60
|
if (date.month <= 6) return 31;
|
|
61
61
|
if (date.month <= 11) return 30;
|
|
62
|
-
let isLeapYear = (0, $
|
|
62
|
+
let isLeapYear = (0, $09f945753a699862$exports.mod)(25 * date.year + 11, 33) < 8;
|
|
63
63
|
return isLeapYear ? 30 : 29;
|
|
64
64
|
}
|
|
65
65
|
getMaximumMonthsInYear() {
|
|
@@ -84,4 +84,4 @@ class $3c060181fc7249ae$export$37fccdbfd14c5939 {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
//# sourceMappingURL=PersianCalendar.
|
|
87
|
+
//# sourceMappingURL=PersianCalendar.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACxE,MAAM,oCAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAK,SAAS;CACf;AAQM,MAAM;IAGX,cAAc,EAAU,EAAgB;QACtC,IAAI,iBAAiB,KAAK;QAC1B,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,iBAAiB,CAAA,IAAK;QACtD,IAAI,aAAa,MAAO,CAAA,OAAO,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,OAAO,EAAC,IAAK;QACjE,IAAI,YAAY,iBAAiB;QACjC,IAAI,QAAQ,YAAY,MACpB,KAAK,KAAK,CAAC,YAAY,MACvB,KAAK,KAAK,CAAC,AAAC,CAAA,YAAY,CAAA,IAAK;QACjC,IAAI,MAAM,YAAY,iCAAW,CAAC,MAAM,GAAG;QAC3C,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,IAAI,EAAE,MAAM,QAAQ,GAAG;IACjD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,sCAAgB,IAAI,MAAO,CAAA,KAAK,IAAI,GAAG,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAI,GAAG,EAAC,IAAK;QACvF,MAAM,iCAAW,CAAC,KAAK,KAAK,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG;QACd,OAAO;IACT;IAEA,kBAA0B;QACxB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,IAAI,GAChB,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,IAChB,OAAO;QAGT,IAAI,aAAa,CAAA,GAAA,6BAAE,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,MAAM;QAChD,OAAO,aAAa,KAAK;IAC3B;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,gBAAwB;QACtB,8CAA8C;QAC9C,mDAAmD;QACnD,OAAO;IACT;;aAtDA,aAAiC;;AAuDnC","sources":["packages/@internationalized/date/src/calendars/PersianCalendar.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, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216\n ? Math.floor(dayOfYear / 31)\n : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 31;\n }\n\n getEras(): string[] {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACxE,MAAM,oCAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAK,SAAS;CACf;AAQM,MAAM;IAGX,cAAc,EAAU,EAAgB;QACtC,IAAI,iBAAiB,KAAK;QAC1B,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,iBAAiB,CAAA,IAAK;QACtD,IAAI,aAAa,MAAO,CAAA,OAAO,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,OAAO,EAAC,IAAK;QACjE,IAAI,YAAY,iBAAiB;QACjC,IAAI,QAAQ,YAAY,MACpB,KAAK,KAAK,CAAC,YAAY,MACvB,KAAK,KAAK,CAAC,AAAC,CAAA,YAAY,CAAA,IAAK;QACjC,IAAI,MAAM,YAAY,iCAAW,CAAC,MAAM,GAAG;QAC3C,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,IAAI,EAAE,MAAM,QAAQ,GAAG;IACjD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,sCAAgB,IAAI,MAAO,CAAA,KAAK,IAAI,GAAG,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAI,GAAG,EAAC,IAAK;QACvF,MAAM,iCAAW,CAAC,KAAK,KAAK,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG;QACd,OAAO;IACT;IAEA,kBAA0B;QACxB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,IAAI,GAChB,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,IAChB,OAAO;QAGT,IAAI,aAAa,CAAA,GAAA,6BAAE,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,MAAM;QAChD,OAAO,aAAa,KAAK;IAC3B;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,gBAAwB;QACtB,8CAA8C;QAC9C,mDAAmD;QACnD,OAAO;IACT;;aAtDA,aAAiC;;AAuDnC","sources":["packages/@internationalized/date/src/calendars/PersianCalendar.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, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216\n ? Math.floor(dayOfYear / 31)\n : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 31;\n }\n\n getEras(): string[] {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.cjs.map"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {CalendarDate as $
|
|
2
|
-
import {mod as $
|
|
1
|
+
import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js";
|
|
2
|
+
import {mod as $1797f75f9a4d3bd4$export$842a2cf37af977e1} from "../utils.js";
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -15,9 +15,9 @@ import {mod as $2b4dce13dd5a17fa$export$842a2cf37af977e1} from "./utils.module.j
|
|
|
15
15
|
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
const $
|
|
18
|
+
const $3e485caf6e85028a$var$PERSIAN_EPOCH = 1948320;
|
|
19
19
|
// Number of days from the start of the year to the start of each month.
|
|
20
|
-
const $
|
|
20
|
+
const $3e485caf6e85028a$var$MONTH_START = [
|
|
21
21
|
0,
|
|
22
22
|
31,
|
|
23
23
|
62,
|
|
@@ -31,19 +31,19 @@ const $f3ed2e4472ae7e25$var$MONTH_START = [
|
|
|
31
31
|
306,
|
|
32
32
|
336 // Esfand
|
|
33
33
|
];
|
|
34
|
-
class $
|
|
34
|
+
class $3e485caf6e85028a$export$37fccdbfd14c5939 {
|
|
35
35
|
fromJulianDay(jd) {
|
|
36
|
-
let daysSinceEpoch = jd - $
|
|
36
|
+
let daysSinceEpoch = jd - $3e485caf6e85028a$var$PERSIAN_EPOCH;
|
|
37
37
|
let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);
|
|
38
38
|
let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);
|
|
39
39
|
let dayOfYear = daysSinceEpoch - farvardin1;
|
|
40
40
|
let month = dayOfYear < 216 ? Math.floor(dayOfYear / 31) : Math.floor((dayOfYear - 6) / 30);
|
|
41
|
-
let day = dayOfYear - $
|
|
42
|
-
return new (0, $
|
|
41
|
+
let day = dayOfYear - $3e485caf6e85028a$var$MONTH_START[month] + 1;
|
|
42
|
+
return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, year, month + 1, day);
|
|
43
43
|
}
|
|
44
44
|
toJulianDay(date) {
|
|
45
|
-
let jd = $
|
|
46
|
-
jd += $
|
|
45
|
+
let jd = $3e485caf6e85028a$var$PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);
|
|
46
|
+
jd += $3e485caf6e85028a$var$MONTH_START[date.month - 1];
|
|
47
47
|
jd += date.day;
|
|
48
48
|
return jd;
|
|
49
49
|
}
|
|
@@ -53,7 +53,7 @@ class $f3ed2e4472ae7e25$export$37fccdbfd14c5939 {
|
|
|
53
53
|
getDaysInMonth(date) {
|
|
54
54
|
if (date.month <= 6) return 31;
|
|
55
55
|
if (date.month <= 11) return 30;
|
|
56
|
-
let isLeapYear = (0, $
|
|
56
|
+
let isLeapYear = (0, $1797f75f9a4d3bd4$export$842a2cf37af977e1)(25 * date.year + 11, 33) < 8;
|
|
57
57
|
return isLeapYear ? 30 : 29;
|
|
58
58
|
}
|
|
59
59
|
getMaximumMonthsInYear() {
|
|
@@ -78,5 +78,5 @@ class $f3ed2e4472ae7e25$export$37fccdbfd14c5939 {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
export {$
|
|
82
|
-
//# sourceMappingURL=PersianCalendar.
|
|
81
|
+
export {$3e485caf6e85028a$export$37fccdbfd14c5939 as PersianCalendar};
|
|
82
|
+
//# sourceMappingURL=PersianCalendar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACxE,MAAM,oCAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAK,SAAS;CACf;AAQM,MAAM;IAGX,cAAc,EAAU,EAAgB;QACtC,IAAI,iBAAiB,KAAK;QAC1B,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,iBAAiB,CAAA,IAAK;QACtD,IAAI,aAAa,MAAO,CAAA,OAAO,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,OAAO,EAAC,IAAK;QACjE,IAAI,YAAY,iBAAiB;QACjC,IAAI,QAAQ,YAAY,MACpB,KAAK,KAAK,CAAC,YAAY,MACvB,KAAK,KAAK,CAAC,AAAC,CAAA,YAAY,CAAA,IAAK;QACjC,IAAI,MAAM,YAAY,iCAAW,CAAC,MAAM,GAAG;QAC3C,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,MAAM,QAAQ,GAAG;IACjD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,sCAAgB,IAAI,MAAO,CAAA,KAAK,IAAI,GAAG,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAI,GAAG,EAAC,IAAK;QACvF,MAAM,iCAAW,CAAC,KAAK,KAAK,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG;QACd,OAAO;IACT;IAEA,kBAA0B;QACxB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,IAAI,GAChB,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,IAChB,OAAO;QAGT,IAAI,aAAa,CAAA,GAAA,yCAAE,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,MAAM;QAChD,OAAO,aAAa,KAAK;IAC3B;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,gBAAwB;QACtB,8CAA8C;QAC9C,mDAAmD;QACnD,OAAO;IACT;;aAtDA,aAAiC;;AAuDnC","sources":["packages/@internationalized/date/src/calendars/PersianCalendar.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, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216\n ? Math.floor(dayOfYear / 31)\n : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 31;\n }\n\n getEras(): string[] {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACxE,MAAM,oCAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAK,SAAS;CACf;AAQM,MAAM;IAGX,cAAc,EAAU,EAAgB;QACtC,IAAI,iBAAiB,KAAK;QAC1B,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,iBAAiB,CAAA,IAAK;QACtD,IAAI,aAAa,MAAO,CAAA,OAAO,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,OAAO,EAAC,IAAK;QACjE,IAAI,YAAY,iBAAiB;QACjC,IAAI,QAAQ,YAAY,MACpB,KAAK,KAAK,CAAC,YAAY,MACvB,KAAK,KAAK,CAAC,AAAC,CAAA,YAAY,CAAA,IAAK;QACjC,IAAI,MAAM,YAAY,iCAAW,CAAC,MAAM,GAAG;QAC3C,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,MAAM,QAAQ,GAAG;IACjD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,sCAAgB,IAAI,MAAO,CAAA,KAAK,IAAI,GAAG,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAI,GAAG,EAAC,IAAK;QACvF,MAAM,iCAAW,CAAC,KAAK,KAAK,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG;QACd,OAAO;IACT;IAEA,kBAA0B;QACxB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,IAAI,GAChB,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,IAChB,OAAO;QAGT,IAAI,aAAa,CAAA,GAAA,yCAAE,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,MAAM;QAChD,OAAO,aAAa,KAAK;IAC3B;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,gBAAwB;QACtB,8CAA8C;QAC9C,mDAAmD;QACnD,OAAO;IACT;;aAtDA,aAAiC;;AAuDnC","sources":["packages/@internationalized/date/src/calendars/PersianCalendar.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, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216\n ? Math.floor(dayOfYear / 31)\n : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 31;\n }\n\n getEras(): string[] {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.js.map"}
|