@internationalized/date 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/main.js +2841 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +2637 -0
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +355 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +25 -0
package/dist/main.js
ADDED
|
@@ -0,0 +1,2841 @@
|
|
|
1
|
+
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
|
|
2
|
+
|
|
3
|
+
var _babelRuntimeHelpersClassPrivateFieldLooseKey = $parcel$interopDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
4
|
+
|
|
5
|
+
function $parcel$interopDefault(a) {
|
|
6
|
+
return a && a.__esModule ? a.default : a;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
// Data from https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json
|
|
21
|
+
// Locales starting on Sunday have been removed for compression.
|
|
22
|
+
const $f9329ef83b780ce5cb2b5b95239f8$export$weekStartData = {
|
|
23
|
+
'001': 1,
|
|
24
|
+
AD: 1,
|
|
25
|
+
AE: 6,
|
|
26
|
+
AF: 6,
|
|
27
|
+
AI: 1,
|
|
28
|
+
AL: 1,
|
|
29
|
+
AM: 1,
|
|
30
|
+
AN: 1,
|
|
31
|
+
AT: 1,
|
|
32
|
+
AX: 1,
|
|
33
|
+
AZ: 1,
|
|
34
|
+
BA: 1,
|
|
35
|
+
BE: 1,
|
|
36
|
+
BG: 1,
|
|
37
|
+
BH: 6,
|
|
38
|
+
BM: 1,
|
|
39
|
+
BN: 1,
|
|
40
|
+
BY: 1,
|
|
41
|
+
CH: 1,
|
|
42
|
+
CL: 1,
|
|
43
|
+
CM: 1,
|
|
44
|
+
CR: 1,
|
|
45
|
+
CY: 1,
|
|
46
|
+
CZ: 1,
|
|
47
|
+
DE: 1,
|
|
48
|
+
DJ: 6,
|
|
49
|
+
DK: 1,
|
|
50
|
+
DZ: 6,
|
|
51
|
+
EC: 1,
|
|
52
|
+
EE: 1,
|
|
53
|
+
EG: 6,
|
|
54
|
+
ES: 1,
|
|
55
|
+
FI: 1,
|
|
56
|
+
FJ: 1,
|
|
57
|
+
FO: 1,
|
|
58
|
+
FR: 1,
|
|
59
|
+
GB: 1,
|
|
60
|
+
GE: 1,
|
|
61
|
+
GF: 1,
|
|
62
|
+
GP: 1,
|
|
63
|
+
GR: 1,
|
|
64
|
+
HR: 1,
|
|
65
|
+
HU: 1,
|
|
66
|
+
IE: 1,
|
|
67
|
+
IQ: 6,
|
|
68
|
+
IR: 6,
|
|
69
|
+
IS: 1,
|
|
70
|
+
IT: 1,
|
|
71
|
+
JO: 6,
|
|
72
|
+
KG: 1,
|
|
73
|
+
KW: 6,
|
|
74
|
+
KZ: 1,
|
|
75
|
+
LB: 1,
|
|
76
|
+
LI: 1,
|
|
77
|
+
LK: 1,
|
|
78
|
+
LT: 1,
|
|
79
|
+
LU: 1,
|
|
80
|
+
LV: 1,
|
|
81
|
+
LY: 6,
|
|
82
|
+
MC: 1,
|
|
83
|
+
MD: 1,
|
|
84
|
+
ME: 1,
|
|
85
|
+
MK: 1,
|
|
86
|
+
MN: 1,
|
|
87
|
+
MQ: 1,
|
|
88
|
+
MV: 5,
|
|
89
|
+
MY: 1,
|
|
90
|
+
NL: 1,
|
|
91
|
+
NO: 1,
|
|
92
|
+
NZ: 1,
|
|
93
|
+
OM: 6,
|
|
94
|
+
PL: 1,
|
|
95
|
+
QA: 6,
|
|
96
|
+
RE: 1,
|
|
97
|
+
RO: 1,
|
|
98
|
+
RS: 1,
|
|
99
|
+
RU: 1,
|
|
100
|
+
SD: 6,
|
|
101
|
+
SE: 1,
|
|
102
|
+
SI: 1,
|
|
103
|
+
SK: 1,
|
|
104
|
+
SM: 1,
|
|
105
|
+
SY: 6,
|
|
106
|
+
TJ: 1,
|
|
107
|
+
TM: 1,
|
|
108
|
+
TR: 1,
|
|
109
|
+
UA: 1,
|
|
110
|
+
UY: 1,
|
|
111
|
+
UZ: 1,
|
|
112
|
+
VA: 1,
|
|
113
|
+
VN: 1,
|
|
114
|
+
XK: 1
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
function isSameDay(a, b) {
|
|
118
|
+
b = toCalendar(b, a.calendar);
|
|
119
|
+
return a.era === b.era && a.year === b.year && a.month === b.month && a.day === b.day;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
exports.isSameDay = isSameDay;
|
|
123
|
+
|
|
124
|
+
function isSameMonth(a, b) {
|
|
125
|
+
b = toCalendar(b, a.calendar); // In the Japanese calendar, months can span multiple eras/years, so only compare the first of the month.
|
|
126
|
+
|
|
127
|
+
a = startOfMonth(a);
|
|
128
|
+
b = startOfMonth(b);
|
|
129
|
+
return a.era === b.era && a.year === b.year && a.month === b.month;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
exports.isSameMonth = isSameMonth;
|
|
133
|
+
|
|
134
|
+
function isSameYear(a, b) {
|
|
135
|
+
b = toCalendar(b, a.calendar);
|
|
136
|
+
a = startOfYear(a);
|
|
137
|
+
b = startOfYear(b);
|
|
138
|
+
return a.era === b.era && a.year === b.year;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
exports.isSameYear = isSameYear;
|
|
142
|
+
|
|
143
|
+
function isEqualDay(a, b) {
|
|
144
|
+
return a.calendar.identifier === b.calendar.identifier && a.era === b.era && a.year === b.year && a.month === b.month && a.day === b.day;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
exports.isEqualDay = isEqualDay;
|
|
148
|
+
|
|
149
|
+
function isEqualMonth(a, b) {
|
|
150
|
+
a = startOfMonth(a);
|
|
151
|
+
b = startOfMonth(b);
|
|
152
|
+
return a.calendar.identifier === b.calendar.identifier && a.era === b.era && a.year === b.year && a.month === b.month;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
exports.isEqualMonth = isEqualMonth;
|
|
156
|
+
|
|
157
|
+
function isEqualYear(a, b) {
|
|
158
|
+
a = startOfYear(a);
|
|
159
|
+
b = startOfYear(b);
|
|
160
|
+
return a.calendar.identifier === b.calendar.identifier && a.era === b.era && a.year === b.year;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
exports.isEqualYear = isEqualYear;
|
|
164
|
+
|
|
165
|
+
function isToday(date, timeZone) {
|
|
166
|
+
return isSameDay(date, today(timeZone));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
exports.isToday = isToday;
|
|
170
|
+
|
|
171
|
+
function getDayOfWeek(date, locale) {
|
|
172
|
+
let julian = date.calendar.toJulianDay(date); // If julian is negative, then julian % 7 will be negative, so we adjust
|
|
173
|
+
// accordingly. Julian day 0 is Monday.
|
|
174
|
+
|
|
175
|
+
let dayOfWeek = Math.ceil(julian + 1 - $ca0cdda43bc8e7de0f5e86$var$getWeekStart(locale)) % 7;
|
|
176
|
+
|
|
177
|
+
if (dayOfWeek < 0) {
|
|
178
|
+
dayOfWeek += 7;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return dayOfWeek;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
exports.getDayOfWeek = getDayOfWeek;
|
|
185
|
+
|
|
186
|
+
function now(timeZone) {
|
|
187
|
+
return fromAbsolute(Date.now(), timeZone);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
exports.now = now;
|
|
191
|
+
|
|
192
|
+
function today(timeZone) {
|
|
193
|
+
return toCalendarDate(now(timeZone));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
exports.today = today;
|
|
197
|
+
|
|
198
|
+
function compareDate(a, b) {
|
|
199
|
+
return a.calendar.toJulianDay(a) - b.calendar.toJulianDay(b);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
exports.compareDate = compareDate;
|
|
203
|
+
|
|
204
|
+
function compareTime(a, b) {
|
|
205
|
+
return $ca0cdda43bc8e7de0f5e86$var$timeToMs(a) - $ca0cdda43bc8e7de0f5e86$var$timeToMs(b);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
exports.compareTime = compareTime;
|
|
209
|
+
|
|
210
|
+
function $ca0cdda43bc8e7de0f5e86$var$timeToMs(a) {
|
|
211
|
+
return a.hour * 60 * 60 * 1000 + a.minute * 60 * 1000 + a.second * 1000 + a.millisecond;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function getHoursInDay(a, timeZone) {
|
|
215
|
+
let ms = toAbsolute(a, timeZone);
|
|
216
|
+
let tomorrow = a.add({
|
|
217
|
+
days: 1
|
|
218
|
+
});
|
|
219
|
+
let tomorrowMs = toAbsolute(tomorrow, timeZone);
|
|
220
|
+
return (tomorrowMs - ms) / 3600000;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
exports.getHoursInDay = getHoursInDay;
|
|
224
|
+
let $ca0cdda43bc8e7de0f5e86$var$localTimeZone = null;
|
|
225
|
+
|
|
226
|
+
function getLocalTimeZone() {
|
|
227
|
+
// TODO: invalidate this somehow?
|
|
228
|
+
if ($ca0cdda43bc8e7de0f5e86$var$localTimeZone == null) {
|
|
229
|
+
$ca0cdda43bc8e7de0f5e86$var$localTimeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return $ca0cdda43bc8e7de0f5e86$var$localTimeZone;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
exports.getLocalTimeZone = getLocalTimeZone;
|
|
236
|
+
|
|
237
|
+
function startOfMonth(date) {
|
|
238
|
+
// Use `subtract` instead of `set` so we don't get constrained in an era.
|
|
239
|
+
return date.subtract({
|
|
240
|
+
days: date.day - 1
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
exports.startOfMonth = startOfMonth;
|
|
245
|
+
|
|
246
|
+
function endOfMonth(date) {
|
|
247
|
+
return date.add({
|
|
248
|
+
days: date.calendar.getDaysInMonth(date) - date.day
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
exports.endOfMonth = endOfMonth;
|
|
253
|
+
|
|
254
|
+
function startOfYear(date) {
|
|
255
|
+
return startOfMonth(date.subtract({
|
|
256
|
+
months: date.month - 1
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
exports.startOfYear = startOfYear;
|
|
261
|
+
|
|
262
|
+
function endOfYear(date) {
|
|
263
|
+
return endOfMonth(date.add({
|
|
264
|
+
months: date.calendar.getMonthsInYear(date) - date.month
|
|
265
|
+
}));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
exports.endOfYear = endOfYear;
|
|
269
|
+
|
|
270
|
+
function getMinimumMonthInYear(date) {
|
|
271
|
+
if (date.calendar.getMinimumMonthInYear) {
|
|
272
|
+
return date.calendar.getMinimumMonthInYear(date);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return 1;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
exports.getMinimumMonthInYear = getMinimumMonthInYear;
|
|
279
|
+
|
|
280
|
+
function getMinimumDayInMonth(date) {
|
|
281
|
+
if (date.calendar.getMinimumDayInMonth) {
|
|
282
|
+
return date.calendar.getMinimumDayInMonth(date);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return 1;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
exports.getMinimumDayInMonth = getMinimumDayInMonth;
|
|
289
|
+
|
|
290
|
+
function startOfWeek(date, locale) {
|
|
291
|
+
let dayOfWeek = getDayOfWeek(date, locale);
|
|
292
|
+
return date.subtract({
|
|
293
|
+
days: dayOfWeek
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
exports.startOfWeek = startOfWeek;
|
|
298
|
+
|
|
299
|
+
function endOfWeek(date, locale) {
|
|
300
|
+
return startOfWeek(date, locale).add({
|
|
301
|
+
days: 6
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
exports.endOfWeek = endOfWeek;
|
|
306
|
+
const $ca0cdda43bc8e7de0f5e86$var$cachedRegions = new Map();
|
|
307
|
+
|
|
308
|
+
function $ca0cdda43bc8e7de0f5e86$var$getRegion(locale) {
|
|
309
|
+
// If the Intl.Locale API is available, use it to get the region for the locale.
|
|
310
|
+
// @ts-ignore
|
|
311
|
+
if (Intl.Locale) {
|
|
312
|
+
// Constructing an Intl.Locale is expensive, so cache the result.
|
|
313
|
+
let region = $ca0cdda43bc8e7de0f5e86$var$cachedRegions.get(locale);
|
|
314
|
+
|
|
315
|
+
if (!region) {
|
|
316
|
+
// @ts-ignore
|
|
317
|
+
region = new Intl.Locale(locale).maximize().region;
|
|
318
|
+
$ca0cdda43bc8e7de0f5e86$var$cachedRegions.set(locale, region);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return region;
|
|
322
|
+
} // If not, just try splitting the string.
|
|
323
|
+
// If the second part of the locale string is 'u',
|
|
324
|
+
// then this is a unicode extension, so ignore it.
|
|
325
|
+
// Otherwise, it should be the region.
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
let part = locale.split('-')[1];
|
|
329
|
+
return part === 'u' ? null : part;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function $ca0cdda43bc8e7de0f5e86$var$getWeekStart(locale) {
|
|
333
|
+
// TODO: use Intl.Locale for this once browsers support the weekInfo property
|
|
334
|
+
// https://github.com/tc39/proposal-intl-locale-info
|
|
335
|
+
let region = $ca0cdda43bc8e7de0f5e86$var$getRegion(locale);
|
|
336
|
+
return $f9329ef83b780ce5cb2b5b95239f8$export$weekStartData[region] || 0;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function getWeeksInMonth(date, locale) {
|
|
340
|
+
let days = date.calendar.getDaysInMonth(date);
|
|
341
|
+
return Math.ceil((getDayOfWeek(startOfMonth(date), locale) + days) / 7);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
exports.getWeeksInMonth = getWeeksInMonth;
|
|
345
|
+
|
|
346
|
+
function minDate(a, b) {
|
|
347
|
+
return a.compare(b) <= 0 ? a : b;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
exports.minDate = minDate;
|
|
351
|
+
|
|
352
|
+
function maxDate(a, b) {
|
|
353
|
+
return a.compare(b) >= 0 ? a : b;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
exports.maxDate = maxDate;
|
|
357
|
+
|
|
358
|
+
function $f839ba72fcd1ea0f3280c95c38c6e83$export$mod(amount, numerator) {
|
|
359
|
+
return amount - numerator * Math.floor(amount / numerator);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const $fdb27fe8d5b8ff356e836fe61f3645c$var$EPOCH = 1721426; // 001/01/03 Julian C.E.
|
|
363
|
+
|
|
364
|
+
function $fdb27fe8d5b8ff356e836fe61f3645c$export$gregorianToJulianDay(year, month, day) {
|
|
365
|
+
let y1 = year - 1;
|
|
366
|
+
let monthOffset = -2;
|
|
367
|
+
|
|
368
|
+
if (month <= 2) {
|
|
369
|
+
monthOffset = 0;
|
|
370
|
+
} else if ($fdb27fe8d5b8ff356e836fe61f3645c$export$isLeapYear(year)) {
|
|
371
|
+
monthOffset = -1;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return $fdb27fe8d5b8ff356e836fe61f3645c$var$EPOCH - 1 + 365 * y1 + Math.floor(y1 / 4) - Math.floor(y1 / 100) + Math.floor(y1 / 400) + Math.floor((367 * month - 362) / 12 + monthOffset + day);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function $fdb27fe8d5b8ff356e836fe61f3645c$export$isLeapYear(year) {
|
|
378
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const $fdb27fe8d5b8ff356e836fe61f3645c$var$daysInMonth = {
|
|
382
|
+
standard: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
|
|
383
|
+
leapyear: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
class GregorianCalendar {
|
|
387
|
+
constructor() {
|
|
388
|
+
this.identifier = 'gregory';
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
fromJulianDay(jd) {
|
|
392
|
+
let jd0 = jd;
|
|
393
|
+
let depoch = jd0 - $fdb27fe8d5b8ff356e836fe61f3645c$var$EPOCH;
|
|
394
|
+
let quadricent = Math.floor(depoch / 146097);
|
|
395
|
+
let dqc = $f839ba72fcd1ea0f3280c95c38c6e83$export$mod(depoch, 146097);
|
|
396
|
+
let cent = Math.floor(dqc / 36524);
|
|
397
|
+
let dcent = $f839ba72fcd1ea0f3280c95c38c6e83$export$mod(dqc, 36524);
|
|
398
|
+
let quad = Math.floor(dcent / 1461);
|
|
399
|
+
let dquad = $f839ba72fcd1ea0f3280c95c38c6e83$export$mod(dcent, 1461);
|
|
400
|
+
let yindex = Math.floor(dquad / 365);
|
|
401
|
+
let year = quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0);
|
|
402
|
+
let yearDay = jd0 - $fdb27fe8d5b8ff356e836fe61f3645c$export$gregorianToJulianDay(year, 1, 1);
|
|
403
|
+
let leapAdj = 2;
|
|
404
|
+
|
|
405
|
+
if (jd0 < $fdb27fe8d5b8ff356e836fe61f3645c$export$gregorianToJulianDay(year, 3, 1)) {
|
|
406
|
+
leapAdj = 0;
|
|
407
|
+
} else if ($fdb27fe8d5b8ff356e836fe61f3645c$export$isLeapYear(year)) {
|
|
408
|
+
leapAdj = 1;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367);
|
|
412
|
+
let day = jd0 - $fdb27fe8d5b8ff356e836fe61f3645c$export$gregorianToJulianDay(year, month, 1) + 1;
|
|
413
|
+
return new CalendarDate(this, year, month, day);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
toJulianDay(date) {
|
|
417
|
+
return $fdb27fe8d5b8ff356e836fe61f3645c$export$gregorianToJulianDay(date.year, date.month, date.day);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
getDaysInMonth(date) {
|
|
421
|
+
return $fdb27fe8d5b8ff356e836fe61f3645c$var$daysInMonth[$fdb27fe8d5b8ff356e836fe61f3645c$export$isLeapYear(date.year) ? 'leapyear' : 'standard'][date.month - 1];
|
|
422
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
getMonthsInYear(date) {
|
|
426
|
+
return 12;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
getDaysInYear(date) {
|
|
430
|
+
return $fdb27fe8d5b8ff356e836fe61f3645c$export$isLeapYear(date.year) ? 366 : 365;
|
|
431
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
getYearsInEra(date) {
|
|
435
|
+
return 9999;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
getEras() {
|
|
439
|
+
return ['BC', 'AD'];
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
getYearsToAdd(date, years) {
|
|
443
|
+
return date.era === 'BC' ? -years : years;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
balanceDate(date) {
|
|
447
|
+
if (date.year <= 0) {
|
|
448
|
+
date.era = date.era === 'BC' ? 'AD' : 'BC';
|
|
449
|
+
date.year = 1 - date.year;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
exports.GregorianCalendar = GregorianCalendar;
|
|
456
|
+
|
|
457
|
+
function epochFromDate(date) {
|
|
458
|
+
date = toCalendar(date, new GregorianCalendar());
|
|
459
|
+
return $a64489f6d663f3427da3eac0e9$var$epochFromParts(date.year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
exports.epochFromDate = epochFromDate;
|
|
463
|
+
|
|
464
|
+
function $a64489f6d663f3427da3eac0e9$var$epochFromParts(year, month, day, hour, minute, second, millisecond) {
|
|
465
|
+
// Note: Date.UTC() interprets one and two-digit years as being in the
|
|
466
|
+
// 20th century, so don't use it
|
|
467
|
+
let date = new Date();
|
|
468
|
+
date.setUTCHours(hour, minute, second, millisecond);
|
|
469
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
470
|
+
return date.getTime();
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function getTimeZoneOffset(ms, timeZone) {
|
|
474
|
+
// Fast path: for local timezone, use native Date.
|
|
475
|
+
if (timeZone === getLocalTimeZone()) {
|
|
476
|
+
return new Date(ms).getTimezoneOffset() * -60 * 1000;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
let {
|
|
480
|
+
year,
|
|
481
|
+
month,
|
|
482
|
+
day,
|
|
483
|
+
hour,
|
|
484
|
+
minute,
|
|
485
|
+
second
|
|
486
|
+
} = $a64489f6d663f3427da3eac0e9$var$getTimeZoneParts(ms, timeZone);
|
|
487
|
+
let utc = $a64489f6d663f3427da3eac0e9$var$epochFromParts(year, month, day, hour, minute, second, 0);
|
|
488
|
+
return utc - Math.floor(ms / 1000) * 1000;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
exports.getTimeZoneOffset = getTimeZoneOffset;
|
|
492
|
+
const $a64489f6d663f3427da3eac0e9$var$formattersByTimeZone = new Map();
|
|
493
|
+
|
|
494
|
+
function $a64489f6d663f3427da3eac0e9$var$getTimeZoneParts(ms, timeZone) {
|
|
495
|
+
let formatter = $a64489f6d663f3427da3eac0e9$var$formattersByTimeZone.get(timeZone);
|
|
496
|
+
|
|
497
|
+
if (!formatter) {
|
|
498
|
+
formatter = new Intl.DateTimeFormat('en-US', {
|
|
499
|
+
timeZone,
|
|
500
|
+
hour12: false,
|
|
501
|
+
era: 'short',
|
|
502
|
+
year: 'numeric',
|
|
503
|
+
month: 'numeric',
|
|
504
|
+
day: 'numeric',
|
|
505
|
+
hour: 'numeric',
|
|
506
|
+
minute: 'numeric',
|
|
507
|
+
second: 'numeric'
|
|
508
|
+
});
|
|
509
|
+
$a64489f6d663f3427da3eac0e9$var$formattersByTimeZone.set(timeZone, formatter);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
let parts = formatter.formatToParts(new Date(ms));
|
|
513
|
+
let namedParts = {};
|
|
514
|
+
|
|
515
|
+
for (let part of parts) {
|
|
516
|
+
if (part.type !== 'literal') {
|
|
517
|
+
namedParts[part.type] = part.value;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return {
|
|
522
|
+
year: namedParts.era === 'BC' ? -namedParts.year + 1 : +namedParts.year,
|
|
523
|
+
month: +namedParts.month,
|
|
524
|
+
day: +namedParts.day,
|
|
525
|
+
hour: namedParts.hour === '24' ? 0 : +namedParts.hour,
|
|
526
|
+
// bugs.chromium.org/p/chromium/issues/detail?id=1045791
|
|
527
|
+
minute: +namedParts.minute,
|
|
528
|
+
second: +namedParts.second
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const $a64489f6d663f3427da3eac0e9$var$DAYMILLIS = 86400000;
|
|
533
|
+
|
|
534
|
+
function possibleAbsolutes(date, timeZone) {
|
|
535
|
+
let ms = epochFromDate(date);
|
|
536
|
+
let earlier = ms - getTimeZoneOffset(ms - $a64489f6d663f3427da3eac0e9$var$DAYMILLIS, timeZone);
|
|
537
|
+
let later = ms - getTimeZoneOffset(ms + $a64489f6d663f3427da3eac0e9$var$DAYMILLIS, timeZone);
|
|
538
|
+
return $a64489f6d663f3427da3eac0e9$var$getValidWallTimes(date, timeZone, earlier, later);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
exports.possibleAbsolutes = possibleAbsolutes;
|
|
542
|
+
|
|
543
|
+
function $a64489f6d663f3427da3eac0e9$var$getValidWallTimes(date, timeZone, earlier, later) {
|
|
544
|
+
let found = earlier === later ? [earlier] : [earlier, later];
|
|
545
|
+
return found.filter(absolute => $a64489f6d663f3427da3eac0e9$var$isValidWallTime(date, timeZone, absolute));
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function $a64489f6d663f3427da3eac0e9$var$isValidWallTime(date, timeZone, absolute) {
|
|
549
|
+
let parts = $a64489f6d663f3427da3eac0e9$var$getTimeZoneParts(absolute, timeZone);
|
|
550
|
+
return date.year === parts.year && date.month === parts.month && date.day === parts.day && date.hour === parts.hour && date.minute === parts.minute && date.second === parts.second;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function toAbsolute(date, timeZone, disambiguation) {
|
|
554
|
+
if (disambiguation === void 0) {
|
|
555
|
+
disambiguation = 'compatible';
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
let dateTime = toCalendarDateTime(date); // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.
|
|
559
|
+
|
|
560
|
+
if (timeZone === getLocalTimeZone() && disambiguation === 'compatible') {
|
|
561
|
+
dateTime = toCalendar(dateTime, new GregorianCalendar()); // Don't use Date constructor here because two-digit years are interpreted in the 20th century.
|
|
562
|
+
|
|
563
|
+
let date = new Date();
|
|
564
|
+
date.setFullYear(dateTime.year, dateTime.month - 1, dateTime.day);
|
|
565
|
+
date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
|
|
566
|
+
return date.getTime();
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
let ms = epochFromDate(dateTime);
|
|
570
|
+
let offsetBefore = getTimeZoneOffset(ms - $a64489f6d663f3427da3eac0e9$var$DAYMILLIS, timeZone);
|
|
571
|
+
let offsetAfter = getTimeZoneOffset(ms + $a64489f6d663f3427da3eac0e9$var$DAYMILLIS, timeZone);
|
|
572
|
+
let valid = $a64489f6d663f3427da3eac0e9$var$getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);
|
|
573
|
+
|
|
574
|
+
if (valid.length === 1) {
|
|
575
|
+
return valid[0];
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (valid.length > 1) {
|
|
579
|
+
switch (disambiguation) {
|
|
580
|
+
// 'compatible' means 'earlier' for "fall back" transitions
|
|
581
|
+
case 'compatible':
|
|
582
|
+
case 'earlier':
|
|
583
|
+
return valid[0];
|
|
584
|
+
|
|
585
|
+
case 'later':
|
|
586
|
+
return valid[valid.length - 1];
|
|
587
|
+
|
|
588
|
+
case 'reject':
|
|
589
|
+
throw new RangeError('Multiple possible absolute times found');
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
switch (disambiguation) {
|
|
594
|
+
case 'earlier':
|
|
595
|
+
return Math.min(ms - offsetBefore, ms - offsetAfter);
|
|
596
|
+
// 'compatible' means 'later' for "spring forward" transitions
|
|
597
|
+
|
|
598
|
+
case 'compatible':
|
|
599
|
+
case 'later':
|
|
600
|
+
return Math.max(ms - offsetBefore, ms - offsetAfter);
|
|
601
|
+
|
|
602
|
+
case 'reject':
|
|
603
|
+
throw new RangeError('No such absolute time found');
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
exports.toAbsolute = toAbsolute;
|
|
608
|
+
|
|
609
|
+
function toDate(dateTime, timeZone, disambiguation) {
|
|
610
|
+
if (disambiguation === void 0) {
|
|
611
|
+
disambiguation = 'compatible';
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
return new Date(toAbsolute(dateTime, timeZone, disambiguation));
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
exports.toDate = toDate;
|
|
618
|
+
|
|
619
|
+
function fromAbsolute(ms, timeZone) {
|
|
620
|
+
let offset = getTimeZoneOffset(ms, timeZone);
|
|
621
|
+
let date = new Date(ms + offset);
|
|
622
|
+
let year = date.getUTCFullYear();
|
|
623
|
+
let month = date.getUTCMonth() + 1;
|
|
624
|
+
let day = date.getUTCDate();
|
|
625
|
+
let hour = date.getUTCHours();
|
|
626
|
+
let minute = date.getUTCMinutes();
|
|
627
|
+
let second = date.getUTCSeconds();
|
|
628
|
+
let millisecond = date.getUTCMilliseconds();
|
|
629
|
+
return new ZonedDateTime(year, month, day, timeZone, offset, hour, minute, second, millisecond);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
exports.fromAbsolute = fromAbsolute;
|
|
633
|
+
|
|
634
|
+
function fromDate(date, timeZone) {
|
|
635
|
+
return fromAbsolute(date.getTime(), timeZone);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
exports.fromDate = fromDate;
|
|
639
|
+
|
|
640
|
+
function fromDateToLocal(date) {
|
|
641
|
+
return fromDate(date, getLocalTimeZone());
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
exports.fromDateToLocal = fromDateToLocal;
|
|
645
|
+
|
|
646
|
+
function toCalendarDate(dateTime) {
|
|
647
|
+
return new CalendarDate(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
exports.toCalendarDate = toCalendarDate;
|
|
651
|
+
|
|
652
|
+
function toDateFields(date) {
|
|
653
|
+
return {
|
|
654
|
+
era: date.era,
|
|
655
|
+
year: date.year,
|
|
656
|
+
month: date.month,
|
|
657
|
+
day: date.day
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
exports.toDateFields = toDateFields;
|
|
662
|
+
|
|
663
|
+
function toTimeFields(date) {
|
|
664
|
+
return {
|
|
665
|
+
hour: date.hour,
|
|
666
|
+
minute: date.minute,
|
|
667
|
+
second: date.second,
|
|
668
|
+
millisecond: date.millisecond
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
exports.toTimeFields = toTimeFields;
|
|
673
|
+
|
|
674
|
+
function toCalendarDateTime(date, time) {
|
|
675
|
+
let hour = 0,
|
|
676
|
+
minute = 0,
|
|
677
|
+
second = 0,
|
|
678
|
+
millisecond = 0;
|
|
679
|
+
|
|
680
|
+
if ('timeZone' in date) {
|
|
681
|
+
({
|
|
682
|
+
hour,
|
|
683
|
+
minute,
|
|
684
|
+
second,
|
|
685
|
+
millisecond
|
|
686
|
+
} = date);
|
|
687
|
+
} else if ('hour' in date && !time) {
|
|
688
|
+
return date;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if (time) {
|
|
692
|
+
({
|
|
693
|
+
hour,
|
|
694
|
+
minute,
|
|
695
|
+
second,
|
|
696
|
+
millisecond
|
|
697
|
+
} = time);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
return new CalendarDateTime(date.calendar, date.era, date.year, date.month, date.day, hour, minute, second, millisecond);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
exports.toCalendarDateTime = toCalendarDateTime;
|
|
704
|
+
|
|
705
|
+
function toTime(dateTime) {
|
|
706
|
+
return new Time(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
exports.toTime = toTime;
|
|
710
|
+
|
|
711
|
+
function toCalendar(date, calendar) {
|
|
712
|
+
if (date.calendar.identifier === calendar.identifier) {
|
|
713
|
+
return date;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));
|
|
717
|
+
let copy = date.copy();
|
|
718
|
+
copy.calendar = calendar;
|
|
719
|
+
copy.era = calendarDate.era;
|
|
720
|
+
copy.year = calendarDate.year;
|
|
721
|
+
copy.month = calendarDate.month;
|
|
722
|
+
copy.day = calendarDate.day;
|
|
723
|
+
return copy;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
exports.toCalendar = toCalendar;
|
|
727
|
+
|
|
728
|
+
function toZoned(date, timeZone, disambiguation) {
|
|
729
|
+
if (date instanceof ZonedDateTime) {
|
|
730
|
+
if (date.timeZone === timeZone) {
|
|
731
|
+
return date;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
return toTimeZone(date, timeZone);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
let ms = toAbsolute(date, timeZone, disambiguation);
|
|
738
|
+
return fromAbsolute(ms, timeZone);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
exports.toZoned = toZoned;
|
|
742
|
+
|
|
743
|
+
function zonedToDate(date) {
|
|
744
|
+
let ms = epochFromDate(date) - date.offset;
|
|
745
|
+
return new Date(ms);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
exports.zonedToDate = zonedToDate;
|
|
749
|
+
|
|
750
|
+
function toTimeZone(date, timeZone) {
|
|
751
|
+
let ms = epochFromDate(date) - date.offset;
|
|
752
|
+
return toCalendar(fromAbsolute(ms, timeZone), date.calendar);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
exports.toTimeZone = toTimeZone;
|
|
756
|
+
|
|
757
|
+
function toLocalTimeZone(date) {
|
|
758
|
+
return toTimeZone(date, getLocalTimeZone());
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
exports.toLocalTimeZone = toLocalTimeZone;
|
|
762
|
+
const $ef0e396d65262cb58648549e1b295ffb$var$ONE_HOUR = 3600000;
|
|
763
|
+
|
|
764
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$add(date, duration) {
|
|
765
|
+
let mutableDate = date.copy();
|
|
766
|
+
let days = 'hour' in date ? $ef0e396d65262cb58648549e1b295ffb$var$addTimeFields(date, duration) : 0;
|
|
767
|
+
$ef0e396d65262cb58648549e1b295ffb$var$addYears(mutableDate, duration.years || 0);
|
|
768
|
+
|
|
769
|
+
if (mutableDate.calendar.balanceYearMonth) {
|
|
770
|
+
mutableDate.calendar.balanceYearMonth(mutableDate, date);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
mutableDate.month += duration.months || 0;
|
|
774
|
+
$ef0e396d65262cb58648549e1b295ffb$var$balanceYearMonth(mutableDate);
|
|
775
|
+
$ef0e396d65262cb58648549e1b295ffb$var$constrainMonthDay(mutableDate);
|
|
776
|
+
mutableDate.day += (duration.weeks || 0) * 7;
|
|
777
|
+
mutableDate.day += duration.days || 0;
|
|
778
|
+
mutableDate.day += days;
|
|
779
|
+
$ef0e396d65262cb58648549e1b295ffb$var$balanceDay(mutableDate);
|
|
780
|
+
|
|
781
|
+
if (mutableDate.calendar.balanceDate) {
|
|
782
|
+
mutableDate.calendar.balanceDate(mutableDate);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
return mutableDate;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function $ef0e396d65262cb58648549e1b295ffb$var$addYears(date, years) {
|
|
789
|
+
if (date.calendar.getYearsToAdd) {
|
|
790
|
+
years = date.calendar.getYearsToAdd(date, years);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
date.year += years;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
function $ef0e396d65262cb58648549e1b295ffb$var$balanceYearMonth(date) {
|
|
797
|
+
while (date.month < 1) {
|
|
798
|
+
$ef0e396d65262cb58648549e1b295ffb$var$addYears(date, -1);
|
|
799
|
+
date.month += date.calendar.getMonthsInYear(date);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
let monthsInYear = 0;
|
|
803
|
+
|
|
804
|
+
while (date.month > (monthsInYear = date.calendar.getMonthsInYear(date))) {
|
|
805
|
+
date.month -= monthsInYear;
|
|
806
|
+
$ef0e396d65262cb58648549e1b295ffb$var$addYears(date, 1);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function $ef0e396d65262cb58648549e1b295ffb$var$balanceDay(date) {
|
|
811
|
+
while (date.day < 1) {
|
|
812
|
+
date.month--;
|
|
813
|
+
$ef0e396d65262cb58648549e1b295ffb$var$balanceYearMonth(date);
|
|
814
|
+
date.day += date.calendar.getDaysInMonth(date);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
while (date.day > date.calendar.getDaysInMonth(date)) {
|
|
818
|
+
date.day -= date.calendar.getDaysInMonth(date);
|
|
819
|
+
date.month++;
|
|
820
|
+
$ef0e396d65262cb58648549e1b295ffb$var$balanceYearMonth(date);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
function $ef0e396d65262cb58648549e1b295ffb$var$constrainMonthDay(date) {
|
|
825
|
+
date.month = Math.max(1, Math.min(date.calendar.getMonthsInYear(date), date.month));
|
|
826
|
+
date.day = Math.max(1, Math.min(date.calendar.getDaysInMonth(date), date.day));
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$constrain(date) {
|
|
830
|
+
if (date.calendar.constrainDate) {
|
|
831
|
+
date.calendar.constrainDate(date);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
date.year = Math.max(1, Math.min(date.calendar.getYearsInEra(date), date.year));
|
|
835
|
+
$ef0e396d65262cb58648549e1b295ffb$var$constrainMonthDay(date);
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$invertDuration(duration) {
|
|
839
|
+
let inverseDuration = {};
|
|
840
|
+
|
|
841
|
+
for (let key in duration) {
|
|
842
|
+
if (typeof duration[key] === 'number') {
|
|
843
|
+
inverseDuration[key] = -duration[key];
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
return inverseDuration;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$subtract(date, duration) {
|
|
851
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$add(date, $ef0e396d65262cb58648549e1b295ffb$export$invertDuration(duration));
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$set(date, fields) {
|
|
855
|
+
let mutableDate = date.copy();
|
|
856
|
+
|
|
857
|
+
if (fields.era != null) {
|
|
858
|
+
mutableDate.era = fields.era;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
if (fields.year != null) {
|
|
862
|
+
mutableDate.year = fields.year;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
if (fields.month != null) {
|
|
866
|
+
mutableDate.month = fields.month;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
if (fields.day != null) {
|
|
870
|
+
mutableDate.day = fields.day;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
$ef0e396d65262cb58648549e1b295ffb$export$constrain(mutableDate);
|
|
874
|
+
return mutableDate;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$setTime(value, fields) {
|
|
878
|
+
let mutableValue = value.copy();
|
|
879
|
+
|
|
880
|
+
if (fields.hour != null) {
|
|
881
|
+
mutableValue.hour = fields.hour;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
if (fields.minute != null) {
|
|
885
|
+
mutableValue.minute = fields.minute;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
if (fields.second != null) {
|
|
889
|
+
mutableValue.second = fields.second;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
if (fields.millisecond != null) {
|
|
893
|
+
mutableValue.millisecond = fields.millisecond;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
$ef0e396d65262cb58648549e1b295ffb$export$constrainTime(mutableValue);
|
|
897
|
+
return mutableValue;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
function $ef0e396d65262cb58648549e1b295ffb$var$balanceTime(time) {
|
|
901
|
+
time.second += Math.floor(time.millisecond / 1000);
|
|
902
|
+
time.millisecond = $ef0e396d65262cb58648549e1b295ffb$var$nonNegativeMod(time.millisecond, 1000);
|
|
903
|
+
time.minute += Math.floor(time.second / 60);
|
|
904
|
+
time.second = $ef0e396d65262cb58648549e1b295ffb$var$nonNegativeMod(time.second, 60);
|
|
905
|
+
time.hour += Math.floor(time.minute / 60);
|
|
906
|
+
time.minute = $ef0e396d65262cb58648549e1b295ffb$var$nonNegativeMod(time.minute, 60);
|
|
907
|
+
let days = Math.floor(time.hour / 24);
|
|
908
|
+
time.hour = $ef0e396d65262cb58648549e1b295ffb$var$nonNegativeMod(time.hour, 24);
|
|
909
|
+
return days;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$constrainTime(time) {
|
|
913
|
+
time.millisecond = Math.max(0, Math.min(time.millisecond, 1000));
|
|
914
|
+
time.second = Math.max(0, Math.min(time.second, 59));
|
|
915
|
+
time.minute = Math.max(0, Math.min(time.minute, 59));
|
|
916
|
+
time.hour = Math.max(0, Math.min(time.hour, 23));
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
function $ef0e396d65262cb58648549e1b295ffb$var$nonNegativeMod(a, b) {
|
|
920
|
+
let result = a % b;
|
|
921
|
+
|
|
922
|
+
if (result < 0) {
|
|
923
|
+
result += b;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
return result;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
function $ef0e396d65262cb58648549e1b295ffb$var$addTimeFields(time, duration) {
|
|
930
|
+
time.hour += duration.hours || 0;
|
|
931
|
+
time.minute += duration.minutes || 0;
|
|
932
|
+
time.second += duration.seconds || 0;
|
|
933
|
+
time.millisecond += duration.milliseconds || 0;
|
|
934
|
+
return $ef0e396d65262cb58648549e1b295ffb$var$balanceTime(time);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$addTime(time, duration) {
|
|
938
|
+
let res = time.copy();
|
|
939
|
+
$ef0e396d65262cb58648549e1b295ffb$var$addTimeFields(res, duration);
|
|
940
|
+
return res;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$subtractTime(time, duration) {
|
|
944
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$addTime(time, $ef0e396d65262cb58648549e1b295ffb$export$invertDuration(duration));
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$cycleDate(value, field, amount, options) {
|
|
948
|
+
let mutable = value.copy();
|
|
949
|
+
|
|
950
|
+
switch (field) {
|
|
951
|
+
case 'era':
|
|
952
|
+
{
|
|
953
|
+
let eras = value.calendar.getEras();
|
|
954
|
+
let eraIndex = eras.indexOf(value.era);
|
|
955
|
+
|
|
956
|
+
if (eraIndex < 0) {
|
|
957
|
+
throw new Error('Invalid era: ' + value.era);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
eraIndex = $ef0e396d65262cb58648549e1b295ffb$var$cycleValue(eraIndex, amount, 0, eras.length - 1, options == null ? void 0 : options.round);
|
|
961
|
+
mutable.era = eras[eraIndex]; // Constrain the year and other fields within the era, so the era doesn't change when we balance below.
|
|
962
|
+
|
|
963
|
+
$ef0e396d65262cb58648549e1b295ffb$export$constrain(mutable);
|
|
964
|
+
break;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
case 'year':
|
|
968
|
+
{
|
|
969
|
+
if (mutable.calendar.getYearsToAdd) {
|
|
970
|
+
amount = mutable.calendar.getYearsToAdd(mutable, amount);
|
|
971
|
+
} // The year field should not cycle within the era as that can cause weird behavior affecting other fields.
|
|
972
|
+
// We need to also allow values < 1 so that decrementing goes to the previous era. If we get -Infinity back
|
|
973
|
+
// we know we wrapped around after reaching 9999 (the maximum), so set the year back to 1.
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
mutable.year = $ef0e396d65262cb58648549e1b295ffb$var$cycleValue(value.year, amount, -Infinity, 9999, options == null ? void 0 : options.round);
|
|
977
|
+
|
|
978
|
+
if (mutable.year === -Infinity) {
|
|
979
|
+
mutable.year = 1;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
if (mutable.calendar.balanceYearMonth) {
|
|
983
|
+
mutable.calendar.balanceYearMonth(mutable, value);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
break;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
case 'month':
|
|
990
|
+
mutable.month = $ef0e396d65262cb58648549e1b295ffb$var$cycleValue(value.month, amount, 1, value.calendar.getMonthsInYear(value), options == null ? void 0 : options.round);
|
|
991
|
+
break;
|
|
992
|
+
|
|
993
|
+
case 'day':
|
|
994
|
+
mutable.day = $ef0e396d65262cb58648549e1b295ffb$var$cycleValue(value.day, amount, 1, value.calendar.getDaysInMonth(value), options == null ? void 0 : options.round);
|
|
995
|
+
break;
|
|
996
|
+
|
|
997
|
+
default:
|
|
998
|
+
throw new Error('Unsupported field ' + field);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
if (value.calendar.balanceDate) {
|
|
1002
|
+
value.calendar.balanceDate(mutable);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
$ef0e396d65262cb58648549e1b295ffb$export$constrain(mutable);
|
|
1006
|
+
return mutable;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$cycleTime(value, field, amount, options) {
|
|
1010
|
+
let mutable = value.copy();
|
|
1011
|
+
|
|
1012
|
+
switch (field) {
|
|
1013
|
+
case 'hour':
|
|
1014
|
+
{
|
|
1015
|
+
let hours = value.hour;
|
|
1016
|
+
let min = 0;
|
|
1017
|
+
let max = 23;
|
|
1018
|
+
|
|
1019
|
+
if ((options == null ? void 0 : options.hourCycle) === 12) {
|
|
1020
|
+
let isPM = hours >= 12;
|
|
1021
|
+
min = isPM ? 12 : 0;
|
|
1022
|
+
max = isPM ? 23 : 11;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
mutable.hour = $ef0e396d65262cb58648549e1b295ffb$var$cycleValue(hours, amount, min, max, options == null ? void 0 : options.round);
|
|
1026
|
+
break;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
case 'minute':
|
|
1030
|
+
mutable.minute = $ef0e396d65262cb58648549e1b295ffb$var$cycleValue(value.minute, amount, 0, 59, options == null ? void 0 : options.round);
|
|
1031
|
+
break;
|
|
1032
|
+
|
|
1033
|
+
case 'second':
|
|
1034
|
+
mutable.second = $ef0e396d65262cb58648549e1b295ffb$var$cycleValue(value.second, amount, 0, 59, options == null ? void 0 : options.round);
|
|
1035
|
+
break;
|
|
1036
|
+
|
|
1037
|
+
case 'millisecond':
|
|
1038
|
+
mutable.millisecond = $ef0e396d65262cb58648549e1b295ffb$var$cycleValue(value.millisecond, amount, 0, 999, options == null ? void 0 : options.round);
|
|
1039
|
+
break;
|
|
1040
|
+
|
|
1041
|
+
default:
|
|
1042
|
+
throw new Error('Unsupported field ' + field);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
return mutable;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
function $ef0e396d65262cb58648549e1b295ffb$var$cycleValue(value, amount, min, max, round) {
|
|
1049
|
+
if (round === void 0) {
|
|
1050
|
+
round = false;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
if (round) {
|
|
1054
|
+
value += Math.sign(amount);
|
|
1055
|
+
|
|
1056
|
+
if (value < min) {
|
|
1057
|
+
value = max;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
let div = Math.abs(amount);
|
|
1061
|
+
|
|
1062
|
+
if (amount > 0) {
|
|
1063
|
+
value = Math.ceil(value / div) * div;
|
|
1064
|
+
} else {
|
|
1065
|
+
value = Math.floor(value / div) * div;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
if (value > max) {
|
|
1069
|
+
value = min;
|
|
1070
|
+
}
|
|
1071
|
+
} else {
|
|
1072
|
+
value += amount;
|
|
1073
|
+
|
|
1074
|
+
if (value < min) {
|
|
1075
|
+
value = max - (min - value - 1);
|
|
1076
|
+
} else if (value > max) {
|
|
1077
|
+
value = min + (value - max - 1);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
return value;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$addZoned(dateTime, duration) {
|
|
1085
|
+
let ms;
|
|
1086
|
+
|
|
1087
|
+
if (duration.years != null && duration.years !== 0 || duration.months != null && duration.months !== 0 || duration.days != null && duration.days !== 0) {
|
|
1088
|
+
let res = $ef0e396d65262cb58648549e1b295ffb$export$add(toCalendarDateTime(dateTime), {
|
|
1089
|
+
years: duration.years,
|
|
1090
|
+
months: duration.months,
|
|
1091
|
+
days: duration.days
|
|
1092
|
+
}); // Changing the date may change the timezone offset, so we need to recompute
|
|
1093
|
+
// using the 'compatible' disambiguation.
|
|
1094
|
+
|
|
1095
|
+
ms = toAbsolute(res, dateTime.timeZone);
|
|
1096
|
+
} else {
|
|
1097
|
+
// Otherwise, preserve the offset of the original date.
|
|
1098
|
+
ms = epochFromDate(dateTime) - dateTime.offset;
|
|
1099
|
+
} // Perform time manipulation in milliseconds rather than on the original time fields to account for DST.
|
|
1100
|
+
// For example, adding one hour during a DST transition may result in the hour field staying the same or
|
|
1101
|
+
// skipping an hour. This results in the offset field changing value instead of the specified field.
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
ms += duration.milliseconds || 0;
|
|
1105
|
+
ms += (duration.seconds || 0) * 1000;
|
|
1106
|
+
ms += (duration.minutes || 0) * 60 * 1000;
|
|
1107
|
+
ms += (duration.hours || 0) * 60 * 60 * 1000;
|
|
1108
|
+
let res = fromAbsolute(ms, dateTime.timeZone);
|
|
1109
|
+
return toCalendar(res, dateTime.calendar);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$subtractZoned(dateTime, duration) {
|
|
1113
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$addZoned(dateTime, $ef0e396d65262cb58648549e1b295ffb$export$invertDuration(duration));
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$cycleZoned(dateTime, field, amount, options) {
|
|
1117
|
+
// For date fields, we want the time to remain consistent and the UTC offset to potentially change to account for DST changes.
|
|
1118
|
+
// For time fields, we want the time to change by the amount given. This may result in the hour field staying the same, but the UTC
|
|
1119
|
+
// offset changing in the case of a backward DST transition, or skipping an hour in the case of a forward DST transition.
|
|
1120
|
+
switch (field) {
|
|
1121
|
+
case 'hour':
|
|
1122
|
+
{
|
|
1123
|
+
let min = 0;
|
|
1124
|
+
let max = 23;
|
|
1125
|
+
|
|
1126
|
+
if ((options == null ? void 0 : options.hourCycle) === 12) {
|
|
1127
|
+
let isPM = dateTime.hour >= 12;
|
|
1128
|
+
min = isPM ? 12 : 0;
|
|
1129
|
+
max = isPM ? 23 : 11;
|
|
1130
|
+
} // The minimum and maximum hour may be affected by daylight saving time.
|
|
1131
|
+
// For example, it might jump forward at midnight, and skip 1am.
|
|
1132
|
+
// Or it might end at midnight and repeat the 11pm hour. To handle this, we get
|
|
1133
|
+
// the possible absolute times for the min and max, and find the maximum range
|
|
1134
|
+
// that is within the current day.
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
let plainDateTime = toCalendarDateTime(dateTime);
|
|
1138
|
+
let minDate = toCalendar($ef0e396d65262cb58648549e1b295ffb$export$setTime(plainDateTime, {
|
|
1139
|
+
hour: min
|
|
1140
|
+
}), new GregorianCalendar());
|
|
1141
|
+
let minAbsolute = [toAbsolute(minDate, dateTime.timeZone, 'earlier'), toAbsolute(minDate, dateTime.timeZone, 'later')].filter(ms => fromAbsolute(ms, dateTime.timeZone).day === minDate.day)[0];
|
|
1142
|
+
let maxDate = toCalendar($ef0e396d65262cb58648549e1b295ffb$export$setTime(plainDateTime, {
|
|
1143
|
+
hour: max
|
|
1144
|
+
}), new GregorianCalendar());
|
|
1145
|
+
let maxAbsolute = [toAbsolute(maxDate, dateTime.timeZone, 'earlier'), toAbsolute(maxDate, dateTime.timeZone, 'later')].filter(ms => fromAbsolute(ms, dateTime.timeZone).day === maxDate.day).pop(); // Since hours may repeat, we need to operate on the absolute time in milliseconds.
|
|
1146
|
+
// This is done in hours from the Unix epoch so that cycleValue works correctly,
|
|
1147
|
+
// and then converted back to milliseconds.
|
|
1148
|
+
|
|
1149
|
+
let ms = epochFromDate(dateTime) - dateTime.offset;
|
|
1150
|
+
let hours = Math.floor(ms / $ef0e396d65262cb58648549e1b295ffb$var$ONE_HOUR);
|
|
1151
|
+
let remainder = ms % $ef0e396d65262cb58648549e1b295ffb$var$ONE_HOUR;
|
|
1152
|
+
ms = $ef0e396d65262cb58648549e1b295ffb$var$cycleValue(hours, amount, Math.floor(minAbsolute / $ef0e396d65262cb58648549e1b295ffb$var$ONE_HOUR), Math.floor(maxAbsolute / $ef0e396d65262cb58648549e1b295ffb$var$ONE_HOUR), options == null ? void 0 : options.round) * $ef0e396d65262cb58648549e1b295ffb$var$ONE_HOUR + remainder; // Now compute the new timezone offset, and convert the absolute time back to local time.
|
|
1153
|
+
|
|
1154
|
+
return toCalendar(fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
case 'minute':
|
|
1158
|
+
case 'second':
|
|
1159
|
+
case 'millisecond':
|
|
1160
|
+
// @ts-ignore
|
|
1161
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$cycleTime(dateTime, field, amount, options);
|
|
1162
|
+
|
|
1163
|
+
case 'era':
|
|
1164
|
+
case 'year':
|
|
1165
|
+
case 'month':
|
|
1166
|
+
case 'day':
|
|
1167
|
+
{
|
|
1168
|
+
let res = $ef0e396d65262cb58648549e1b295ffb$export$cycleDate(toCalendarDateTime(dateTime), field, amount, options);
|
|
1169
|
+
let ms = toAbsolute(res, dateTime.timeZone);
|
|
1170
|
+
return toCalendar(fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
default:
|
|
1174
|
+
throw new Error('Unsupported field ' + field);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
function $ef0e396d65262cb58648549e1b295ffb$export$setZoned(dateTime, fields, disambiguation) {
|
|
1179
|
+
// Set the date/time fields, and recompute the UTC offset to account for DST changes.
|
|
1180
|
+
// We also need to validate by converting back to a local time in case hours are skipped during forward DST transitions.
|
|
1181
|
+
let plainDateTime = toCalendarDateTime(dateTime);
|
|
1182
|
+
let res = $ef0e396d65262cb58648549e1b295ffb$export$setTime($ef0e396d65262cb58648549e1b295ffb$export$set(plainDateTime, fields), fields); // If the resulting plain date time values are equal, return the original time.
|
|
1183
|
+
// We don't want to change the offset when setting the time to the same value.
|
|
1184
|
+
|
|
1185
|
+
if (res.compare(plainDateTime) === 0) {
|
|
1186
|
+
return dateTime;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
let ms = toAbsolute(res, dateTime.timeZone, disambiguation);
|
|
1190
|
+
return toCalendar(fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
const $bd6bf09705eeaa0793e81f11d$var$TIME_RE = /^(\d{2})(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?$/;
|
|
1194
|
+
const $bd6bf09705eeaa0793e81f11d$var$DATE_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
1195
|
+
const $bd6bf09705eeaa0793e81f11d$var$DATE_TIME_RE = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?$/;
|
|
1196
|
+
const $bd6bf09705eeaa0793e81f11d$var$ZONED_DATE_TIME_RE = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:([+-]\d{2})(?::(\d{2}))?)?\[(.*?)\]$/;
|
|
1197
|
+
const $bd6bf09705eeaa0793e81f11d$var$ABSOLUTE_RE = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::(\d{2}))?)|Z)$/;
|
|
1198
|
+
|
|
1199
|
+
function parseTime(value) {
|
|
1200
|
+
let m = value.match($bd6bf09705eeaa0793e81f11d$var$TIME_RE);
|
|
1201
|
+
|
|
1202
|
+
if (!m) {
|
|
1203
|
+
throw new Error('Invalid ISO 8601 time string: ' + value);
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
return new Time($bd6bf09705eeaa0793e81f11d$var$parseNumber(m[1], 0, 23), m[2] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[2], 0, 59) : 0, m[3] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[3], 0, 59) : 0, m[4] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[4], 0, Infinity) * 1000 : 0);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
exports.parseTime = parseTime;
|
|
1210
|
+
|
|
1211
|
+
function parseDate(value) {
|
|
1212
|
+
let m = value.match($bd6bf09705eeaa0793e81f11d$var$DATE_RE);
|
|
1213
|
+
|
|
1214
|
+
if (!m) {
|
|
1215
|
+
throw new Error('Invalid ISO 8601 date string: ' + value);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
let date = new CalendarDate($bd6bf09705eeaa0793e81f11d$var$parseNumber(m[1], 0, 9999), $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[2], 1, 12), 1);
|
|
1219
|
+
date.day = $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[3], 0, date.calendar.getDaysInMonth(date));
|
|
1220
|
+
return date;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
exports.parseDate = parseDate;
|
|
1224
|
+
|
|
1225
|
+
function parseDateTime(value) {
|
|
1226
|
+
let m = value.match($bd6bf09705eeaa0793e81f11d$var$DATE_TIME_RE);
|
|
1227
|
+
|
|
1228
|
+
if (!m) {
|
|
1229
|
+
throw new Error('Invalid ISO 8601 date time string: ' + value);
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
let date = new CalendarDateTime($bd6bf09705eeaa0793e81f11d$var$parseNumber(m[1], 1, 9999), $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[2], 1, 12), 1, m[4] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[4], 0, 23) : 0, m[5] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[5], 0, 59) : 0, m[6] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[6], 0, 59) : 0, m[7] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[7], 0, Infinity) * 1000 : 0);
|
|
1233
|
+
date.day = $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[3], 0, date.calendar.getDaysInMonth(date));
|
|
1234
|
+
return date;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
exports.parseDateTime = parseDateTime;
|
|
1238
|
+
|
|
1239
|
+
function parseZonedDateTime(value, disambiguation) {
|
|
1240
|
+
let m = value.match($bd6bf09705eeaa0793e81f11d$var$ZONED_DATE_TIME_RE);
|
|
1241
|
+
|
|
1242
|
+
if (!m) {
|
|
1243
|
+
throw new Error('Invalid ISO 8601 date time string: ' + value);
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
let date = new ZonedDateTime($bd6bf09705eeaa0793e81f11d$var$parseNumber(m[1], 1, 9999), $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[2], 1, 12), 1, m[10], 0, m[4] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[4], 0, 23) : 0, m[5] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[5], 0, 59) : 0, m[6] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[6], 0, 59) : 0, m[7] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[7], 0, Infinity) * 1000 : 0);
|
|
1247
|
+
date.day = $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[3], 0, date.calendar.getDaysInMonth(date));
|
|
1248
|
+
let plainDateTime = toCalendarDateTime(date);
|
|
1249
|
+
let ms;
|
|
1250
|
+
|
|
1251
|
+
if (m[8]) {
|
|
1252
|
+
var _m$;
|
|
1253
|
+
|
|
1254
|
+
date.offset = $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[8], -23, 23) * 60 * 60 * 1000 + $bd6bf09705eeaa0793e81f11d$var$parseNumber((_m$ = m[9]) != null ? _m$ : '0', 0, 59) * 60 * 1000;
|
|
1255
|
+
ms = epochFromDate(date) - date.offset; // Validate offset against parsed date.
|
|
1256
|
+
|
|
1257
|
+
let absolutes = possibleAbsolutes(plainDateTime, date.timeZone);
|
|
1258
|
+
|
|
1259
|
+
if (!absolutes.includes(ms)) {
|
|
1260
|
+
throw new Error("Offset " + $bd6bf09705eeaa0793e81f11d$var$offsetToString(date.offset) + " is invalid for " + dateTimeToString(date) + " in " + date.timeZone);
|
|
1261
|
+
}
|
|
1262
|
+
} else {
|
|
1263
|
+
// Convert to absolute and back to fix invalid times due to DST.
|
|
1264
|
+
ms = toAbsolute(toCalendarDateTime(plainDateTime), date.timeZone, disambiguation);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
return fromAbsolute(ms, date.timeZone);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
exports.parseZonedDateTime = parseZonedDateTime;
|
|
1271
|
+
|
|
1272
|
+
function parseAbsolute(value, timeZone) {
|
|
1273
|
+
let m = value.match($bd6bf09705eeaa0793e81f11d$var$ABSOLUTE_RE);
|
|
1274
|
+
|
|
1275
|
+
if (!m) {
|
|
1276
|
+
throw new Error('Invalid ISO 8601 date time string: ' + value);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
let date = new ZonedDateTime($bd6bf09705eeaa0793e81f11d$var$parseNumber(m[1], 1, 9999), $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[2], 1, 12), 1, timeZone, 0, m[4] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[4], 0, 23) : 0, m[5] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[5], 0, 59) : 0, m[6] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[6], 0, 59) : 0, m[7] ? $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[7], 0, Infinity) * 1000 : 0);
|
|
1280
|
+
date.day = $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[3], 0, date.calendar.getDaysInMonth(date));
|
|
1281
|
+
|
|
1282
|
+
if (m[8]) {
|
|
1283
|
+
var _m$2;
|
|
1284
|
+
|
|
1285
|
+
date.offset = $bd6bf09705eeaa0793e81f11d$var$parseNumber(m[8], -23, 23) * 60 * 60 * 1000 + $bd6bf09705eeaa0793e81f11d$var$parseNumber((_m$2 = m[9]) != null ? _m$2 : '0', 0, 59) * 60 * 1000;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
return toTimeZone(date, timeZone);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
exports.parseAbsolute = parseAbsolute;
|
|
1292
|
+
|
|
1293
|
+
function parseAbsoluteToLocal(value) {
|
|
1294
|
+
return parseAbsolute(value, getLocalTimeZone());
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
exports.parseAbsoluteToLocal = parseAbsoluteToLocal;
|
|
1298
|
+
|
|
1299
|
+
function $bd6bf09705eeaa0793e81f11d$var$parseNumber(value, min, max) {
|
|
1300
|
+
let val = Number(value);
|
|
1301
|
+
|
|
1302
|
+
if (val < min || val > max) {
|
|
1303
|
+
throw new RangeError("Value out of range: " + min + " <= " + val + " <= " + max);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
return val;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
function timeToString(time) {
|
|
1310
|
+
return String(time.hour).padStart(2, '0') + ":" + String(time.minute).padStart(2, '0') + ":" + String(time.second).padStart(2, '0') + (time.millisecond ? String(time.millisecond / 1000).slice(1) : '');
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
exports.timeToString = timeToString;
|
|
1314
|
+
|
|
1315
|
+
function dateToString(date) {
|
|
1316
|
+
let gregorianDate = toCalendar(date, new GregorianCalendar());
|
|
1317
|
+
return String(gregorianDate.year).padStart(4, '0') + "-" + String(gregorianDate.month).padStart(2, '0') + "-" + String(gregorianDate.day).padStart(2, '0');
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
exports.dateToString = dateToString;
|
|
1321
|
+
|
|
1322
|
+
function dateTimeToString(date) {
|
|
1323
|
+
// @ts-ignore
|
|
1324
|
+
return dateToString(date) + "T" + timeToString(date);
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
exports.dateTimeToString = dateTimeToString;
|
|
1328
|
+
|
|
1329
|
+
function $bd6bf09705eeaa0793e81f11d$var$offsetToString(offset) {
|
|
1330
|
+
let sign = Math.sign(offset) < 0 ? '-' : '+';
|
|
1331
|
+
offset = Math.abs(offset);
|
|
1332
|
+
let offsetHours = Math.floor(offset / (60 * 60 * 1000));
|
|
1333
|
+
let offsetMinutes = offset % (60 * 60 * 1000) / (60 * 1000);
|
|
1334
|
+
return "" + sign + String(offsetHours).padStart(2, '0') + ":" + String(offsetMinutes).padStart(2, '0');
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
function zonedDateTimeToString(date) {
|
|
1338
|
+
return "" + dateTimeToString(date) + $bd6bf09705eeaa0793e81f11d$var$offsetToString(date.offset) + "[" + date.timeZone + "]";
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
exports.zonedDateTimeToString = zonedDateTimeToString;
|
|
1342
|
+
|
|
1343
|
+
function $d62182d5b5773c92a3ef2afcb06ab$var$shiftArgs(args) {
|
|
1344
|
+
let calendar = typeof args[0] === 'object' ? args.shift() : new GregorianCalendar();
|
|
1345
|
+
let era;
|
|
1346
|
+
|
|
1347
|
+
if (typeof args[0] === 'string') {
|
|
1348
|
+
era = args.shift();
|
|
1349
|
+
} else {
|
|
1350
|
+
let eras = calendar.getEras();
|
|
1351
|
+
era = eras[eras.length - 1];
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
let year = args.shift();
|
|
1355
|
+
let month = args.shift();
|
|
1356
|
+
let day = args.shift();
|
|
1357
|
+
return [calendar, era, year, month, day];
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
var $d62182d5b5773c92a3ef2afcb06ab$var$_type = _babelRuntimeHelpersClassPrivateFieldLooseKey("type");
|
|
1361
|
+
|
|
1362
|
+
class CalendarDate {
|
|
1363
|
+
// This prevents TypeScript from allowing other types with the same fields to match.
|
|
1364
|
+
// i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate.
|
|
1365
|
+
// If that behavior is desired, use the AnyCalendarDate interface instead.
|
|
1366
|
+
constructor() {
|
|
1367
|
+
Object.defineProperty(this, $d62182d5b5773c92a3ef2afcb06ab$var$_type, {
|
|
1368
|
+
writable: true,
|
|
1369
|
+
value: void 0
|
|
1370
|
+
});
|
|
1371
|
+
this.calendar = void 0;
|
|
1372
|
+
this.era = void 0;
|
|
1373
|
+
this.year = void 0;
|
|
1374
|
+
this.month = void 0;
|
|
1375
|
+
this.day = void 0;
|
|
1376
|
+
|
|
1377
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1378
|
+
args[_key] = arguments[_key];
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
let [calendar, era, year, month, day] = $d62182d5b5773c92a3ef2afcb06ab$var$shiftArgs(args);
|
|
1382
|
+
this.calendar = calendar;
|
|
1383
|
+
this.era = era;
|
|
1384
|
+
this.year = year;
|
|
1385
|
+
this.month = month;
|
|
1386
|
+
this.day = day;
|
|
1387
|
+
$ef0e396d65262cb58648549e1b295ffb$export$constrain(this);
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
copy() {
|
|
1391
|
+
if (this.era) {
|
|
1392
|
+
return new CalendarDate(this.calendar, this.era, this.year, this.month, this.day);
|
|
1393
|
+
} else {
|
|
1394
|
+
return new CalendarDate(this.calendar, this.year, this.month, this.day);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
add(duration) {
|
|
1399
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$add(this, duration);
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
subtract(duration) {
|
|
1403
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$subtract(this, duration);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
set(fields) {
|
|
1407
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$set(this, fields);
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
cycle(field, amount, options) {
|
|
1411
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$cycleDate(this, field, amount, options);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
toDate(timeZone) {
|
|
1415
|
+
return toDate(this, timeZone);
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
toString() {
|
|
1419
|
+
return dateToString(this);
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
compare(b) {
|
|
1423
|
+
return compareDate(this, b);
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
exports.CalendarDate = CalendarDate;
|
|
1429
|
+
|
|
1430
|
+
var $d62182d5b5773c92a3ef2afcb06ab$var$_type2 = _babelRuntimeHelpersClassPrivateFieldLooseKey("type");
|
|
1431
|
+
|
|
1432
|
+
class Time {
|
|
1433
|
+
// This prevents TypeScript from allowing other types with the same fields to match.
|
|
1434
|
+
constructor(hour = 0, minute = 0, second = 0, millisecond = 0) {
|
|
1435
|
+
this.hour = hour;
|
|
1436
|
+
this.minute = minute;
|
|
1437
|
+
this.second = second;
|
|
1438
|
+
this.millisecond = millisecond;
|
|
1439
|
+
Object.defineProperty(this, $d62182d5b5773c92a3ef2afcb06ab$var$_type2, {
|
|
1440
|
+
writable: true,
|
|
1441
|
+
value: void 0
|
|
1442
|
+
});
|
|
1443
|
+
$ef0e396d65262cb58648549e1b295ffb$export$constrainTime(this);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
copy() {
|
|
1447
|
+
return new Time(this.hour, this.minute, this.second, this.millisecond);
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
add(duration) {
|
|
1451
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$addTime(this, duration);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
subtract(duration) {
|
|
1455
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$subtractTime(this, duration);
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
set(fields) {
|
|
1459
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$setTime(this, fields);
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
cycle(field, amount, options) {
|
|
1463
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$cycleTime(this, field, amount, options);
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
toString() {
|
|
1467
|
+
return timeToString(this);
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
compare(b) {
|
|
1471
|
+
return compareTime(this, b);
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
exports.Time = Time;
|
|
1477
|
+
|
|
1478
|
+
var $d62182d5b5773c92a3ef2afcb06ab$var$_type3 = _babelRuntimeHelpersClassPrivateFieldLooseKey("type");
|
|
1479
|
+
|
|
1480
|
+
class CalendarDateTime {
|
|
1481
|
+
// This prevents TypeScript from allowing other types with the same fields to match.
|
|
1482
|
+
constructor() {
|
|
1483
|
+
Object.defineProperty(this, $d62182d5b5773c92a3ef2afcb06ab$var$_type3, {
|
|
1484
|
+
writable: true,
|
|
1485
|
+
value: void 0
|
|
1486
|
+
});
|
|
1487
|
+
this.calendar = void 0;
|
|
1488
|
+
this.era = void 0;
|
|
1489
|
+
this.year = void 0;
|
|
1490
|
+
this.month = void 0;
|
|
1491
|
+
this.day = void 0;
|
|
1492
|
+
this.hour = void 0;
|
|
1493
|
+
this.minute = void 0;
|
|
1494
|
+
this.second = void 0;
|
|
1495
|
+
this.millisecond = void 0;
|
|
1496
|
+
|
|
1497
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1498
|
+
args[_key2] = arguments[_key2];
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
let [calendar, era, year, month, day] = $d62182d5b5773c92a3ef2afcb06ab$var$shiftArgs(args);
|
|
1502
|
+
this.calendar = calendar;
|
|
1503
|
+
this.era = era;
|
|
1504
|
+
this.year = year;
|
|
1505
|
+
this.month = month;
|
|
1506
|
+
this.day = day;
|
|
1507
|
+
this.hour = args.shift() || 0;
|
|
1508
|
+
this.minute = args.shift() || 0;
|
|
1509
|
+
this.second = args.shift() || 0;
|
|
1510
|
+
this.millisecond = args.shift() || 0;
|
|
1511
|
+
$ef0e396d65262cb58648549e1b295ffb$export$constrain(this);
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
copy() {
|
|
1515
|
+
if (this.era) {
|
|
1516
|
+
return new CalendarDateTime(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
1517
|
+
} else {
|
|
1518
|
+
return new CalendarDateTime(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
add(duration) {
|
|
1523
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$add(this, duration);
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
subtract(duration) {
|
|
1527
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$subtract(this, duration);
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
set(fields) {
|
|
1531
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$set($ef0e396d65262cb58648549e1b295ffb$export$setTime(this, fields), fields);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
cycle(field, amount, options) {
|
|
1535
|
+
switch (field) {
|
|
1536
|
+
case 'era':
|
|
1537
|
+
case 'year':
|
|
1538
|
+
case 'month':
|
|
1539
|
+
case 'day':
|
|
1540
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$cycleDate(this, field, amount, options);
|
|
1541
|
+
|
|
1542
|
+
default:
|
|
1543
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$cycleTime(this, field, amount, options);
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
toDate(timeZone) {
|
|
1548
|
+
return toDate(this, timeZone);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
toString() {
|
|
1552
|
+
return dateTimeToString(this);
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
compare(b) {
|
|
1556
|
+
let res = compareDate(this, b);
|
|
1557
|
+
|
|
1558
|
+
if (res === 0) {
|
|
1559
|
+
return compareTime(this, toCalendarDateTime(b));
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
return res;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
exports.CalendarDateTime = CalendarDateTime;
|
|
1568
|
+
|
|
1569
|
+
var $d62182d5b5773c92a3ef2afcb06ab$var$_type4 = _babelRuntimeHelpersClassPrivateFieldLooseKey("type");
|
|
1570
|
+
|
|
1571
|
+
class ZonedDateTime {
|
|
1572
|
+
// This prevents TypeScript from allowing other types with the same fields to match.
|
|
1573
|
+
constructor() {
|
|
1574
|
+
Object.defineProperty(this, $d62182d5b5773c92a3ef2afcb06ab$var$_type4, {
|
|
1575
|
+
writable: true,
|
|
1576
|
+
value: void 0
|
|
1577
|
+
});
|
|
1578
|
+
this.calendar = void 0;
|
|
1579
|
+
this.era = void 0;
|
|
1580
|
+
this.year = void 0;
|
|
1581
|
+
this.month = void 0;
|
|
1582
|
+
this.day = void 0;
|
|
1583
|
+
this.hour = void 0;
|
|
1584
|
+
this.minute = void 0;
|
|
1585
|
+
this.second = void 0;
|
|
1586
|
+
this.millisecond = void 0;
|
|
1587
|
+
this.timeZone = void 0;
|
|
1588
|
+
this.offset = void 0;
|
|
1589
|
+
|
|
1590
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
1591
|
+
args[_key3] = arguments[_key3];
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
let [calendar, era, year, month, day] = $d62182d5b5773c92a3ef2afcb06ab$var$shiftArgs(args);
|
|
1595
|
+
let timeZone = args.shift();
|
|
1596
|
+
let offset = args.shift();
|
|
1597
|
+
this.calendar = calendar;
|
|
1598
|
+
this.era = era;
|
|
1599
|
+
this.year = year;
|
|
1600
|
+
this.month = month;
|
|
1601
|
+
this.day = day;
|
|
1602
|
+
this.timeZone = timeZone;
|
|
1603
|
+
this.offset = offset;
|
|
1604
|
+
this.hour = args.shift() || 0;
|
|
1605
|
+
this.minute = args.shift() || 0;
|
|
1606
|
+
this.second = args.shift() || 0;
|
|
1607
|
+
this.millisecond = args.shift() || 0;
|
|
1608
|
+
$ef0e396d65262cb58648549e1b295ffb$export$constrain(this);
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
copy() {
|
|
1612
|
+
if (this.era) {
|
|
1613
|
+
return new ZonedDateTime(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
|
|
1614
|
+
} else {
|
|
1615
|
+
return new ZonedDateTime(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
add(duration) {
|
|
1620
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$addZoned(this, duration);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
subtract(duration) {
|
|
1624
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$subtractZoned(this, duration);
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
set(fields, disambiguation) {
|
|
1628
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$setZoned(this, fields, disambiguation);
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
cycle(field, amount, options) {
|
|
1632
|
+
return $ef0e396d65262cb58648549e1b295ffb$export$cycleZoned(this, field, amount, options);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
toDate() {
|
|
1636
|
+
return zonedToDate(this);
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
toString() {
|
|
1640
|
+
return zonedDateTimeToString(this);
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
toAbsoluteString() {
|
|
1644
|
+
return this.toDate().toISOString();
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
compare(b) {
|
|
1648
|
+
// TODO: Is this a bad idea??
|
|
1649
|
+
return this.toDate().getTime() - toZoned(b, this.timeZone).toDate().getTime();
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
exports.ZonedDateTime = ZonedDateTime;
|
|
1655
|
+
const $d3cec079d200a848225dc29b5c644d27$var$ERA_START_DATES = [[1868, 9, 8], [1912, 7, 30], [1926, 12, 25], [1989, 1, 8], [2019, 5, 1]];
|
|
1656
|
+
const $d3cec079d200a848225dc29b5c644d27$var$ERA_END_DATES = [[1912, 7, 29], [1926, 12, 24], [1989, 1, 7], [2019, 4, 30]];
|
|
1657
|
+
const $d3cec079d200a848225dc29b5c644d27$var$ERA_ADDENDS = [1867, 1911, 1925, 1988, 2018];
|
|
1658
|
+
const $d3cec079d200a848225dc29b5c644d27$var$ERA_NAMES = ['meiji', 'taisho', 'showa', 'heisei', 'reiwa'];
|
|
1659
|
+
|
|
1660
|
+
function $d3cec079d200a848225dc29b5c644d27$var$findEraFromGregorianDate(date) {
|
|
1661
|
+
const idx = $d3cec079d200a848225dc29b5c644d27$var$ERA_START_DATES.findIndex((_ref) => {
|
|
1662
|
+
let [year, month, day] = _ref;
|
|
1663
|
+
|
|
1664
|
+
if (date.year < year) {
|
|
1665
|
+
return true;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
if (date.year === year && date.month < month) {
|
|
1669
|
+
return true;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
if (date.year === year && date.month === month && date.day < day) {
|
|
1673
|
+
return true;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
return false;
|
|
1677
|
+
});
|
|
1678
|
+
|
|
1679
|
+
if (idx === -1) {
|
|
1680
|
+
return $d3cec079d200a848225dc29b5c644d27$var$ERA_START_DATES.length - 1;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
if (idx === 0) {
|
|
1684
|
+
return 0;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
return idx - 1;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
function $d3cec079d200a848225dc29b5c644d27$var$toGregorian(date) {
|
|
1691
|
+
let eraAddend = $d3cec079d200a848225dc29b5c644d27$var$ERA_ADDENDS[$d3cec079d200a848225dc29b5c644d27$var$ERA_NAMES.indexOf(date.era)];
|
|
1692
|
+
|
|
1693
|
+
if (!eraAddend) {
|
|
1694
|
+
throw new Error('Unknown era: ' + date.era);
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
return new CalendarDate(date.year + eraAddend, date.month, date.day);
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
class JapaneseCalendar extends GregorianCalendar {
|
|
1701
|
+
constructor() {
|
|
1702
|
+
super(...arguments);
|
|
1703
|
+
this.identifier = 'japanese';
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
fromJulianDay(jd) {
|
|
1707
|
+
let date = super.fromJulianDay(jd);
|
|
1708
|
+
let era = $d3cec079d200a848225dc29b5c644d27$var$findEraFromGregorianDate(date);
|
|
1709
|
+
date.era = $d3cec079d200a848225dc29b5c644d27$var$ERA_NAMES[era];
|
|
1710
|
+
date.year -= $d3cec079d200a848225dc29b5c644d27$var$ERA_ADDENDS[era];
|
|
1711
|
+
return date;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
toJulianDay(date) {
|
|
1715
|
+
return super.toJulianDay($d3cec079d200a848225dc29b5c644d27$var$toGregorian(date));
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
balanceDate(date) {
|
|
1719
|
+
let gregorianDate = $d3cec079d200a848225dc29b5c644d27$var$toGregorian(date);
|
|
1720
|
+
let era = $d3cec079d200a848225dc29b5c644d27$var$findEraFromGregorianDate(gregorianDate);
|
|
1721
|
+
|
|
1722
|
+
if ($d3cec079d200a848225dc29b5c644d27$var$ERA_NAMES[era] !== date.era) {
|
|
1723
|
+
date.era = $d3cec079d200a848225dc29b5c644d27$var$ERA_NAMES[era];
|
|
1724
|
+
date.year = gregorianDate.year - $d3cec079d200a848225dc29b5c644d27$var$ERA_ADDENDS[era];
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
constrainDate(date) {
|
|
1729
|
+
let idx = $d3cec079d200a848225dc29b5c644d27$var$ERA_NAMES.indexOf(date.era);
|
|
1730
|
+
let end = $d3cec079d200a848225dc29b5c644d27$var$ERA_END_DATES[idx];
|
|
1731
|
+
|
|
1732
|
+
if (end != null) {
|
|
1733
|
+
let [endYear, endMonth, endDay] = end; // Constrain the year to the maximum possible value in the era.
|
|
1734
|
+
// Then constrain the month and day fields within that.
|
|
1735
|
+
|
|
1736
|
+
let maxYear = endYear - $d3cec079d200a848225dc29b5c644d27$var$ERA_ADDENDS[idx];
|
|
1737
|
+
date.year = Math.min(maxYear, date.year);
|
|
1738
|
+
|
|
1739
|
+
if (date.year === maxYear) {
|
|
1740
|
+
date.month = Math.min(endMonth, date.month);
|
|
1741
|
+
|
|
1742
|
+
if (date.month === endMonth) {
|
|
1743
|
+
date.day = Math.min(endDay, date.day);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
if (date.year === 1) {
|
|
1748
|
+
let [, startMonth, startDay] = $d3cec079d200a848225dc29b5c644d27$var$ERA_START_DATES[idx];
|
|
1749
|
+
date.month = Math.max(startMonth, date.month);
|
|
1750
|
+
|
|
1751
|
+
if (date.month === startMonth) {
|
|
1752
|
+
date.day = Math.max(startDay, date.day);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
getEras() {
|
|
1759
|
+
return $d3cec079d200a848225dc29b5c644d27$var$ERA_NAMES;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
getYearsInEra(date) {
|
|
1763
|
+
// Get the number of years in the era, taking into account the date's month and day fields.
|
|
1764
|
+
let era = $d3cec079d200a848225dc29b5c644d27$var$ERA_NAMES.indexOf(date.era);
|
|
1765
|
+
let next = $d3cec079d200a848225dc29b5c644d27$var$ERA_START_DATES[era + 1];
|
|
1766
|
+
|
|
1767
|
+
if (next == null) {
|
|
1768
|
+
return 9999;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
let cur = $d3cec079d200a848225dc29b5c644d27$var$ERA_START_DATES[era];
|
|
1772
|
+
let years = next[0] - cur[0];
|
|
1773
|
+
|
|
1774
|
+
if (date.month < next[1] || date.month === next[1] && date.day < next[2]) {
|
|
1775
|
+
years++;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
return years;
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
getMinimumMonthInYear(date) {
|
|
1782
|
+
let start = $d3cec079d200a848225dc29b5c644d27$var$getMinimums(date);
|
|
1783
|
+
return start ? start[1] : 1;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
getMinimumDayInMonth(date) {
|
|
1787
|
+
let start = $d3cec079d200a848225dc29b5c644d27$var$getMinimums(date);
|
|
1788
|
+
return start && date.month === start[1] ? start[2] : 1;
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
exports.JapaneseCalendar = JapaneseCalendar;
|
|
1794
|
+
|
|
1795
|
+
function $d3cec079d200a848225dc29b5c644d27$var$getMinimums(date) {
|
|
1796
|
+
if (date.year === 1) {
|
|
1797
|
+
let idx = $d3cec079d200a848225dc29b5c644d27$var$ERA_NAMES.indexOf(date.era);
|
|
1798
|
+
return $d3cec079d200a848225dc29b5c644d27$var$ERA_START_DATES[idx];
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
const $cdfe44306af6bfd9e58fece371a4981$var$BUDDHIST_ERA_START = -543;
|
|
1803
|
+
|
|
1804
|
+
class BuddhistCalendar extends GregorianCalendar {
|
|
1805
|
+
constructor() {
|
|
1806
|
+
super(...arguments);
|
|
1807
|
+
this.identifier = 'buddhist';
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
fromJulianDay(jd) {
|
|
1811
|
+
let date = super.fromJulianDay(jd);
|
|
1812
|
+
date.year -= $cdfe44306af6bfd9e58fece371a4981$var$BUDDHIST_ERA_START;
|
|
1813
|
+
return date;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
toJulianDay(date) {
|
|
1817
|
+
return super.toJulianDay(new CalendarDate(date.year + $cdfe44306af6bfd9e58fece371a4981$var$BUDDHIST_ERA_START, date.month, date.day));
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
getEras() {
|
|
1821
|
+
return ['BE'];
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
exports.BuddhistCalendar = BuddhistCalendar;
|
|
1827
|
+
const $bfc8860ccf9284c7ca2a2d1fdf8e42$var$TAIWAN_ERA_START = 1911;
|
|
1828
|
+
|
|
1829
|
+
function $bfc8860ccf9284c7ca2a2d1fdf8e42$var$gregorianYear(date) {
|
|
1830
|
+
return date.era === 'minguo' ? date.year + $bfc8860ccf9284c7ca2a2d1fdf8e42$var$TAIWAN_ERA_START : 1 - date.year + $bfc8860ccf9284c7ca2a2d1fdf8e42$var$TAIWAN_ERA_START;
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
function $bfc8860ccf9284c7ca2a2d1fdf8e42$var$gregorianToTaiwan(year, date) {
|
|
1834
|
+
let y = year - $bfc8860ccf9284c7ca2a2d1fdf8e42$var$TAIWAN_ERA_START;
|
|
1835
|
+
|
|
1836
|
+
if (y > 0) {
|
|
1837
|
+
date.era = 'minguo';
|
|
1838
|
+
date.year = y;
|
|
1839
|
+
} else {
|
|
1840
|
+
date.era = 'before_minguo';
|
|
1841
|
+
date.year = 1 - y;
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
class TaiwanCalendar extends GregorianCalendar {
|
|
1846
|
+
constructor() {
|
|
1847
|
+
super(...arguments);
|
|
1848
|
+
this.identifier = 'roc';
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
// Republic of China
|
|
1852
|
+
fromJulianDay(jd) {
|
|
1853
|
+
let date = super.fromJulianDay(jd);
|
|
1854
|
+
$bfc8860ccf9284c7ca2a2d1fdf8e42$var$gregorianToTaiwan(date.year, date);
|
|
1855
|
+
return date;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
toJulianDay(date) {
|
|
1859
|
+
return super.toJulianDay(new CalendarDate($bfc8860ccf9284c7ca2a2d1fdf8e42$var$gregorianYear(date), date.month, date.day));
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
getEras() {
|
|
1863
|
+
return ['before_minguo', 'minguo'];
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
balanceDate(date) {
|
|
1867
|
+
$bfc8860ccf9284c7ca2a2d1fdf8e42$var$gregorianToTaiwan($bfc8860ccf9284c7ca2a2d1fdf8e42$var$gregorianYear(date), date);
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
getYearsToAdd(date, years) {
|
|
1871
|
+
return date.era === 'before_minguo' ? -years : years;
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
exports.TaiwanCalendar = TaiwanCalendar;
|
|
1877
|
+
const $f9a4dcf1024f37434b4f773b9f10f678$var$PERSIAN_EPOCH = 1948321; // 622/03/19 Julian C.E.
|
|
1878
|
+
|
|
1879
|
+
function $f9a4dcf1024f37434b4f773b9f10f678$var$isLeapYear(year) {
|
|
1880
|
+
let y0 = year > 0 ? year - 474 : year - 473;
|
|
1881
|
+
let y1 = $f839ba72fcd1ea0f3280c95c38c6e83$export$mod(y0, 2820) + 474;
|
|
1882
|
+
return $f839ba72fcd1ea0f3280c95c38c6e83$export$mod((y1 + 38) * 31, 128) < 31;
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
function $f9a4dcf1024f37434b4f773b9f10f678$var$persianToJulianDay(year, month, day) {
|
|
1886
|
+
let y0 = year > 0 ? year - 474 : year - 473;
|
|
1887
|
+
let y1 = $f839ba72fcd1ea0f3280c95c38c6e83$export$mod(y0, 2820) + 474;
|
|
1888
|
+
let offset = month <= 7 ? 31 * (month - 1) : 30 * (month - 1) + 6;
|
|
1889
|
+
return $f9a4dcf1024f37434b4f773b9f10f678$var$PERSIAN_EPOCH - 1 + 1029983 * Math.floor(y0 / 2820) + 365 * (y1 - 1) + Math.floor((31 * y1 - 5) / 128) + offset + day;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
class PersianCalendar {
|
|
1893
|
+
constructor() {
|
|
1894
|
+
this.identifier = 'persian';
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
fromJulianDay(jd) {
|
|
1898
|
+
let d0 = jd - $f9a4dcf1024f37434b4f773b9f10f678$var$persianToJulianDay(475, 1, 1);
|
|
1899
|
+
let n2820 = Math.floor(d0 / 1029983);
|
|
1900
|
+
let d1 = $f839ba72fcd1ea0f3280c95c38c6e83$export$mod(d0, 1029983);
|
|
1901
|
+
let y2820 = d1 === 1029982 ? 2820 : Math.floor((128 * d1 + 46878) / 46751);
|
|
1902
|
+
let year = 474 + 2820 * n2820 + y2820;
|
|
1903
|
+
|
|
1904
|
+
if (year <= 0) {
|
|
1905
|
+
year--;
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
let yDay = jd - $f9a4dcf1024f37434b4f773b9f10f678$var$persianToJulianDay(year, 1, 1) + 1;
|
|
1909
|
+
let month = yDay <= 186 ? Math.ceil(yDay / 31) : Math.ceil((yDay - 6) / 31);
|
|
1910
|
+
let day = jd - $f9a4dcf1024f37434b4f773b9f10f678$var$persianToJulianDay(year, month, 1) + 1;
|
|
1911
|
+
return new CalendarDate(this, year, month, day);
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
toJulianDay(date) {
|
|
1915
|
+
return $f9a4dcf1024f37434b4f773b9f10f678$var$persianToJulianDay(date.year, date.month, date.day);
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
getMonthsInYear() {
|
|
1919
|
+
return 12;
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
getDaysInMonth(date) {
|
|
1923
|
+
if (date.month <= 6) {
|
|
1924
|
+
return 31;
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
if (date.month <= 11) {
|
|
1928
|
+
return 30;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
return $f9a4dcf1024f37434b4f773b9f10f678$var$isLeapYear(date.year) ? 30 : 29;
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
getEras() {
|
|
1935
|
+
return ['AP'];
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
getYearsInEra() {
|
|
1939
|
+
return 9999;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
exports.PersianCalendar = PersianCalendar;
|
|
1945
|
+
// Starts in 78 AD,
|
|
1946
|
+
const $f7146730260e0b69febbbb2e5deb182b$var$INDIAN_ERA_START = 78; // The Indian year starts 80 days later than the Gregorian year.
|
|
1947
|
+
|
|
1948
|
+
const $f7146730260e0b69febbbb2e5deb182b$var$INDIAN_YEAR_START = 80;
|
|
1949
|
+
|
|
1950
|
+
class IndianCalendar extends GregorianCalendar {
|
|
1951
|
+
constructor() {
|
|
1952
|
+
super(...arguments);
|
|
1953
|
+
this.identifier = 'indian';
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
fromJulianDay(jd) {
|
|
1957
|
+
// Gregorian date for Julian day
|
|
1958
|
+
let date = super.fromJulianDay(jd); // Year in Saka era
|
|
1959
|
+
|
|
1960
|
+
let indianYear = date.year - $f7146730260e0b69febbbb2e5deb182b$var$INDIAN_ERA_START; // Day number in Gregorian year (starting from 0)
|
|
1961
|
+
|
|
1962
|
+
let yDay = jd - $fdb27fe8d5b8ff356e836fe61f3645c$export$gregorianToJulianDay(date.year, 1, 1);
|
|
1963
|
+
let leapMonth;
|
|
1964
|
+
|
|
1965
|
+
if (yDay < $f7146730260e0b69febbbb2e5deb182b$var$INDIAN_YEAR_START) {
|
|
1966
|
+
// Day is at the end of the preceding Saka year
|
|
1967
|
+
indianYear--; // Days in leapMonth this year, previous Gregorian year
|
|
1968
|
+
|
|
1969
|
+
leapMonth = $fdb27fe8d5b8ff356e836fe61f3645c$export$isLeapYear(date.year - 1) ? 31 : 30;
|
|
1970
|
+
yDay += leapMonth + 31 * 5 + 30 * 3 + 10;
|
|
1971
|
+
} else {
|
|
1972
|
+
// Days in leapMonth this year
|
|
1973
|
+
leapMonth = $fdb27fe8d5b8ff356e836fe61f3645c$export$isLeapYear(date.year) ? 31 : 30;
|
|
1974
|
+
yDay -= $f7146730260e0b69febbbb2e5deb182b$var$INDIAN_YEAR_START;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
let indianMonth;
|
|
1978
|
+
let indianDay;
|
|
1979
|
+
|
|
1980
|
+
if (yDay < leapMonth) {
|
|
1981
|
+
indianMonth = 1;
|
|
1982
|
+
indianDay = yDay + 1;
|
|
1983
|
+
} else {
|
|
1984
|
+
let mDay = yDay - leapMonth;
|
|
1985
|
+
|
|
1986
|
+
if (mDay < 31 * 5) {
|
|
1987
|
+
indianMonth = Math.floor(mDay / 31) + 2;
|
|
1988
|
+
indianDay = mDay % 31 + 1;
|
|
1989
|
+
} else {
|
|
1990
|
+
mDay -= 31 * 5;
|
|
1991
|
+
indianMonth = Math.floor(mDay / 30) + 7;
|
|
1992
|
+
indianDay = mDay % 30 + 1;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
return new CalendarDate(this, indianYear, indianMonth, indianDay);
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
toJulianDay(date) {
|
|
2000
|
+
let year = date.year + $f7146730260e0b69febbbb2e5deb182b$var$INDIAN_ERA_START;
|
|
2001
|
+
let leapMonth;
|
|
2002
|
+
let jd;
|
|
2003
|
+
|
|
2004
|
+
if ($fdb27fe8d5b8ff356e836fe61f3645c$export$isLeapYear(year)) {
|
|
2005
|
+
leapMonth = 31;
|
|
2006
|
+
jd = $fdb27fe8d5b8ff356e836fe61f3645c$export$gregorianToJulianDay(year, 3, 21);
|
|
2007
|
+
} else {
|
|
2008
|
+
leapMonth = 30;
|
|
2009
|
+
jd = $fdb27fe8d5b8ff356e836fe61f3645c$export$gregorianToJulianDay(year, 3, 22);
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
if (date.month === 1) {
|
|
2013
|
+
return jd + date.day - 1;
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
jd += leapMonth + Math.min(date.month - 2, 5) * 31;
|
|
2017
|
+
|
|
2018
|
+
if (date.month >= 8) {
|
|
2019
|
+
jd += (date.month - 7) * 30;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
jd += date.day - 1;
|
|
2023
|
+
return jd;
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
getDaysInMonth(date) {
|
|
2027
|
+
if (date.month === 1 && $fdb27fe8d5b8ff356e836fe61f3645c$export$isLeapYear(date.year + $f7146730260e0b69febbbb2e5deb182b$var$INDIAN_ERA_START)) {
|
|
2028
|
+
return 31;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
if (date.month >= 2 && date.month <= 6) {
|
|
2032
|
+
return 31;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
return 30;
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
getYearsInEra() {
|
|
2039
|
+
return 9999;
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
getEras() {
|
|
2043
|
+
return ['saka'];
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
exports.IndianCalendar = IndianCalendar;
|
|
2049
|
+
const $a989b48226b9ac44fe33c05c41f3b63$var$CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)
|
|
2050
|
+
|
|
2051
|
+
const $a989b48226b9ac44fe33c05c41f3b63$var$ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)
|
|
2052
|
+
|
|
2053
|
+
const $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START = 1300;
|
|
2054
|
+
const $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_END = 1600;
|
|
2055
|
+
const $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_START_DAYS = 460322;
|
|
2056
|
+
|
|
2057
|
+
function $a989b48226b9ac44fe33c05c41f3b63$var$islamicToJulianDay(epoch, year, month, day) {
|
|
2058
|
+
return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + Math.floor((3 + 11 * year) / 30) + epoch - 1;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
function $a989b48226b9ac44fe33c05c41f3b63$var$julianDayToIslamic(calendar, epoch, jd) {
|
|
2062
|
+
let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);
|
|
2063
|
+
let month = Math.min(12, Math.ceil((jd - (29 + $a989b48226b9ac44fe33c05c41f3b63$var$islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1);
|
|
2064
|
+
let day = jd - $a989b48226b9ac44fe33c05c41f3b63$var$islamicToJulianDay(epoch, year, month, 1) + 1;
|
|
2065
|
+
return new CalendarDate(calendar, year, month, day);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
function $a989b48226b9ac44fe33c05c41f3b63$var$isLeapYear(year) {
|
|
2069
|
+
return (14 + 11 * year) % 30 < 11;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
class IslamicCivilCalendar {
|
|
2073
|
+
constructor() {
|
|
2074
|
+
this.identifier = 'islamic-civil';
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
fromJulianDay(jd) {
|
|
2078
|
+
return $a989b48226b9ac44fe33c05c41f3b63$var$julianDayToIslamic(this, $a989b48226b9ac44fe33c05c41f3b63$var$CIVIL_EPOC, jd);
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
toJulianDay(date) {
|
|
2082
|
+
return $a989b48226b9ac44fe33c05c41f3b63$var$islamicToJulianDay($a989b48226b9ac44fe33c05c41f3b63$var$CIVIL_EPOC, date.year, date.month, date.day);
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
getDaysInMonth(date) {
|
|
2086
|
+
let length = 29 + date.month % 2;
|
|
2087
|
+
|
|
2088
|
+
if (date.month === 12 && $a989b48226b9ac44fe33c05c41f3b63$var$isLeapYear(date.year)) {
|
|
2089
|
+
length++;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
return length;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
getMonthsInYear() {
|
|
2096
|
+
return 12;
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
getDaysInYear(date) {
|
|
2100
|
+
return $a989b48226b9ac44fe33c05c41f3b63$var$isLeapYear(date.year) ? 355 : 354;
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
getYearsInEra() {
|
|
2104
|
+
return 9999;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
getEras() {
|
|
2108
|
+
return ['AH'];
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
exports.IslamicCivilCalendar = IslamicCivilCalendar;
|
|
2114
|
+
|
|
2115
|
+
class IslamicTabularCalendar extends IslamicCivilCalendar {
|
|
2116
|
+
constructor() {
|
|
2117
|
+
super(...arguments);
|
|
2118
|
+
this.identifier = 'islamic-tbla';
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
fromJulianDay(jd) {
|
|
2122
|
+
return $a989b48226b9ac44fe33c05c41f3b63$var$julianDayToIslamic(this, $a989b48226b9ac44fe33c05c41f3b63$var$ASTRONOMICAL_EPOC, jd);
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
toJulianDay(date) {
|
|
2126
|
+
return $a989b48226b9ac44fe33c05c41f3b63$var$islamicToJulianDay($a989b48226b9ac44fe33c05c41f3b63$var$ASTRONOMICAL_EPOC, date.year, date.month, date.day);
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
} // Generated by scripts/generate-umalqura.js
|
|
2130
|
+
|
|
2131
|
+
|
|
2132
|
+
exports.IslamicTabularCalendar = IslamicTabularCalendar;
|
|
2133
|
+
const $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_DATA = 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=';
|
|
2134
|
+
let $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_MONTHLENGTH;
|
|
2135
|
+
let $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START_TABLE;
|
|
2136
|
+
|
|
2137
|
+
function $a989b48226b9ac44fe33c05c41f3b63$var$umalquraYearStart(year) {
|
|
2138
|
+
return $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_START_DAYS + $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START_TABLE[year - $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START];
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
function $a989b48226b9ac44fe33c05c41f3b63$var$umalquraMonthLength(year, month) {
|
|
2142
|
+
let idx = year - $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START;
|
|
2143
|
+
let mask = 0x01 << 11 - (month - 1);
|
|
2144
|
+
|
|
2145
|
+
if (($a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_MONTHLENGTH[idx] & mask) === 0) {
|
|
2146
|
+
return 29;
|
|
2147
|
+
} else {
|
|
2148
|
+
return 30;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
function $a989b48226b9ac44fe33c05c41f3b63$var$umalquraMonthStart(year, month) {
|
|
2153
|
+
let day = $a989b48226b9ac44fe33c05c41f3b63$var$umalquraYearStart(year);
|
|
2154
|
+
|
|
2155
|
+
for (let i = 1; i < month; i++) {
|
|
2156
|
+
day += $a989b48226b9ac44fe33c05c41f3b63$var$umalquraMonthLength(year, i);
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
return day;
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
function $a989b48226b9ac44fe33c05c41f3b63$var$umalquraYearLength(year) {
|
|
2163
|
+
return $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START_TABLE[year + 1 - $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START] - $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START_TABLE[year - $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START];
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
class IslamicUmalquraCalendar extends IslamicCivilCalendar {
|
|
2167
|
+
constructor() {
|
|
2168
|
+
super();
|
|
2169
|
+
this.identifier = 'islamic-umalqura';
|
|
2170
|
+
|
|
2171
|
+
if (!$a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_MONTHLENGTH) {
|
|
2172
|
+
$a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob($a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_DATA), c => c.charCodeAt(0)).buffer);
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
if (!$a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START_TABLE) {
|
|
2176
|
+
$a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START_TABLE = new Uint32Array($a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_END - $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START + 1);
|
|
2177
|
+
let yearStart = 0;
|
|
2178
|
+
|
|
2179
|
+
for (let year = $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START; year <= $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_END; year++) {
|
|
2180
|
+
$a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START_TABLE[year - $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START] = yearStart;
|
|
2181
|
+
|
|
2182
|
+
for (let i = 1; i <= 12; i++) {
|
|
2183
|
+
yearStart += $a989b48226b9ac44fe33c05c41f3b63$var$umalquraMonthLength(year, i);
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
fromJulianDay(jd) {
|
|
2190
|
+
let days = jd - $a989b48226b9ac44fe33c05c41f3b63$var$CIVIL_EPOC;
|
|
2191
|
+
let startDays = $a989b48226b9ac44fe33c05c41f3b63$var$umalquraYearStart($a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START);
|
|
2192
|
+
let endDays = $a989b48226b9ac44fe33c05c41f3b63$var$umalquraYearStart($a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_END);
|
|
2193
|
+
|
|
2194
|
+
if (days < startDays || days > endDays) {
|
|
2195
|
+
return super.fromJulianDay(jd);
|
|
2196
|
+
} else {
|
|
2197
|
+
let y = $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START - 1;
|
|
2198
|
+
let m = 1;
|
|
2199
|
+
let d = 1;
|
|
2200
|
+
|
|
2201
|
+
while (d > 0) {
|
|
2202
|
+
y++;
|
|
2203
|
+
d = days - $a989b48226b9ac44fe33c05c41f3b63$var$umalquraYearStart(y) + 1;
|
|
2204
|
+
let yearLength = $a989b48226b9ac44fe33c05c41f3b63$var$umalquraYearLength(y);
|
|
2205
|
+
|
|
2206
|
+
if (d === yearLength) {
|
|
2207
|
+
m = 12;
|
|
2208
|
+
break;
|
|
2209
|
+
} else if (d < yearLength) {
|
|
2210
|
+
let monthLength = $a989b48226b9ac44fe33c05c41f3b63$var$umalquraMonthLength(y, m);
|
|
2211
|
+
m = 1;
|
|
2212
|
+
|
|
2213
|
+
while (d > monthLength) {
|
|
2214
|
+
d -= monthLength;
|
|
2215
|
+
m++;
|
|
2216
|
+
monthLength = $a989b48226b9ac44fe33c05c41f3b63$var$umalquraMonthLength(y, m);
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
break;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
return new CalendarDate(this, y, m, days - $a989b48226b9ac44fe33c05c41f3b63$var$umalquraMonthStart(y, m) + 1);
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
toJulianDay(date) {
|
|
2228
|
+
if (date.year < $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START || date.year > $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_END) {
|
|
2229
|
+
return super.toJulianDay(date);
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
return $a989b48226b9ac44fe33c05c41f3b63$var$CIVIL_EPOC + $a989b48226b9ac44fe33c05c41f3b63$var$umalquraMonthStart(date.year, date.month) + (date.day - 1);
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
getDaysInMonth(date) {
|
|
2236
|
+
if (date.year < $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START || date.year > $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_END) {
|
|
2237
|
+
return super.getDaysInMonth(date);
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
return $a989b48226b9ac44fe33c05c41f3b63$var$umalquraMonthLength(date.year, date.month);
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
getDaysInYear(date) {
|
|
2244
|
+
if (date.year < $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_START || date.year > $a989b48226b9ac44fe33c05c41f3b63$var$UMALQURA_YEAR_END) {
|
|
2245
|
+
return super.getDaysInYear(date);
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
return $a989b48226b9ac44fe33c05c41f3b63$var$umalquraYearLength(date.year);
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
exports.IslamicUmalquraCalendar = IslamicUmalquraCalendar;
|
|
2254
|
+
const $cc2b03afe24b76b3bf6ec565767e7$var$HEBREW_EPOCH = 347997; // Hebrew date calculations are performed in terms of days, hours, and
|
|
2255
|
+
// "parts" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds.
|
|
2256
|
+
|
|
2257
|
+
const $cc2b03afe24b76b3bf6ec565767e7$var$HOUR_PARTS = 1080;
|
|
2258
|
+
const $cc2b03afe24b76b3bf6ec565767e7$var$DAY_PARTS = 24 * $cc2b03afe24b76b3bf6ec565767e7$var$HOUR_PARTS; // An approximate value for the length of a lunar month.
|
|
2259
|
+
// It is used to calculate the approximate year and month of a given
|
|
2260
|
+
// absolute date.
|
|
2261
|
+
|
|
2262
|
+
const $cc2b03afe24b76b3bf6ec565767e7$var$MONTH_DAYS = 29;
|
|
2263
|
+
const $cc2b03afe24b76b3bf6ec565767e7$var$MONTH_FRACT = 12 * $cc2b03afe24b76b3bf6ec565767e7$var$HOUR_PARTS + 793;
|
|
2264
|
+
const $cc2b03afe24b76b3bf6ec565767e7$var$MONTH_PARTS = $cc2b03afe24b76b3bf6ec565767e7$var$MONTH_DAYS * $cc2b03afe24b76b3bf6ec565767e7$var$DAY_PARTS + $cc2b03afe24b76b3bf6ec565767e7$var$MONTH_FRACT;
|
|
2265
|
+
|
|
2266
|
+
function $cc2b03afe24b76b3bf6ec565767e7$var$isLeapYear(year) {
|
|
2267
|
+
return $f839ba72fcd1ea0f3280c95c38c6e83$export$mod(year * 7 + 1, 19) < 7;
|
|
2268
|
+
} // Test for delay of start of new year and to avoid
|
|
2269
|
+
// Sunday, Wednesday, and Friday as start of the new year.
|
|
2270
|
+
|
|
2271
|
+
|
|
2272
|
+
function $cc2b03afe24b76b3bf6ec565767e7$var$hebrewDelay1(year) {
|
|
2273
|
+
let months = Math.floor((235 * year - 234) / 19);
|
|
2274
|
+
let parts = 12084 + 13753 * months;
|
|
2275
|
+
let day = months * 29 + Math.floor(parts / 25920);
|
|
2276
|
+
|
|
2277
|
+
if ($f839ba72fcd1ea0f3280c95c38c6e83$export$mod(3 * (day + 1), 7) < 3) {
|
|
2278
|
+
day += 1;
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
return day;
|
|
2282
|
+
} // Check for delay in start of new year due to length of adjacent years
|
|
2283
|
+
|
|
2284
|
+
|
|
2285
|
+
function $cc2b03afe24b76b3bf6ec565767e7$var$hebrewDelay2(year) {
|
|
2286
|
+
let last = $cc2b03afe24b76b3bf6ec565767e7$var$hebrewDelay1(year - 1);
|
|
2287
|
+
let present = $cc2b03afe24b76b3bf6ec565767e7$var$hebrewDelay1(year);
|
|
2288
|
+
let next = $cc2b03afe24b76b3bf6ec565767e7$var$hebrewDelay1(year + 1);
|
|
2289
|
+
|
|
2290
|
+
if (next - present === 356) {
|
|
2291
|
+
return 2;
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
if (present - last === 382) {
|
|
2295
|
+
return 1;
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
return 0;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
function $cc2b03afe24b76b3bf6ec565767e7$var$startOfYear(year) {
|
|
2302
|
+
return $cc2b03afe24b76b3bf6ec565767e7$var$hebrewDelay1(year) + $cc2b03afe24b76b3bf6ec565767e7$var$hebrewDelay2(year);
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
function $cc2b03afe24b76b3bf6ec565767e7$var$getDaysInYear(year) {
|
|
2306
|
+
return $cc2b03afe24b76b3bf6ec565767e7$var$startOfYear(year + 1) - $cc2b03afe24b76b3bf6ec565767e7$var$startOfYear(year);
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
function $cc2b03afe24b76b3bf6ec565767e7$var$getYearType(year) {
|
|
2310
|
+
let yearLength = $cc2b03afe24b76b3bf6ec565767e7$var$getDaysInYear(year);
|
|
2311
|
+
|
|
2312
|
+
if (yearLength > 380) {
|
|
2313
|
+
yearLength -= 30; // Subtract length of leap month.
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
switch (yearLength) {
|
|
2317
|
+
case 353:
|
|
2318
|
+
return 0;
|
|
2319
|
+
// deficient
|
|
2320
|
+
|
|
2321
|
+
case 354:
|
|
2322
|
+
return 1;
|
|
2323
|
+
// normal
|
|
2324
|
+
|
|
2325
|
+
case 355:
|
|
2326
|
+
return 2;
|
|
2327
|
+
// complete
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
function $cc2b03afe24b76b3bf6ec565767e7$var$getDaysInMonth(year, month) {
|
|
2332
|
+
// Normalize month numbers from 1 - 13, even on non-leap years
|
|
2333
|
+
if (month >= 6 && !$cc2b03afe24b76b3bf6ec565767e7$var$isLeapYear(year)) {
|
|
2334
|
+
month++;
|
|
2335
|
+
} // First of all, dispose of fixed-length 29 day months
|
|
2336
|
+
|
|
2337
|
+
|
|
2338
|
+
if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) {
|
|
2339
|
+
return 29;
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
let yearType = $cc2b03afe24b76b3bf6ec565767e7$var$getYearType(year); // If it's Heshvan, days depend on length of year
|
|
2343
|
+
|
|
2344
|
+
if (month === 2) {
|
|
2345
|
+
return yearType === 2 ? 30 : 29;
|
|
2346
|
+
} // Similarly, Kislev varies with the length of year
|
|
2347
|
+
|
|
2348
|
+
|
|
2349
|
+
if (month === 3) {
|
|
2350
|
+
return yearType === 0 ? 29 : 30;
|
|
2351
|
+
} // Adar I only exists in leap years
|
|
2352
|
+
|
|
2353
|
+
|
|
2354
|
+
if (month === 6) {
|
|
2355
|
+
return $cc2b03afe24b76b3bf6ec565767e7$var$isLeapYear(year) ? 30 : 0;
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
return 30;
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
class HebrewCalendar {
|
|
2362
|
+
constructor() {
|
|
2363
|
+
this.identifier = 'hebrew';
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
fromJulianDay(jd) {
|
|
2367
|
+
let d = jd - $cc2b03afe24b76b3bf6ec565767e7$var$HEBREW_EPOCH;
|
|
2368
|
+
let m = d * $cc2b03afe24b76b3bf6ec565767e7$var$DAY_PARTS / $cc2b03afe24b76b3bf6ec565767e7$var$MONTH_PARTS; // Months (approx)
|
|
2369
|
+
|
|
2370
|
+
let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx)
|
|
2371
|
+
|
|
2372
|
+
let ys = $cc2b03afe24b76b3bf6ec565767e7$var$startOfYear(year); // 1st day of year
|
|
2373
|
+
|
|
2374
|
+
let dayOfYear = Math.floor(d - ys); // Because of the postponement rules, it's possible to guess wrong. Fix it.
|
|
2375
|
+
|
|
2376
|
+
while (dayOfYear < 1) {
|
|
2377
|
+
year--;
|
|
2378
|
+
ys = $cc2b03afe24b76b3bf6ec565767e7$var$startOfYear(year);
|
|
2379
|
+
dayOfYear = Math.floor(d - ys);
|
|
2380
|
+
} // Now figure out which month we're in, and the date within that month
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
let month = 1;
|
|
2384
|
+
let monthStart = 0;
|
|
2385
|
+
|
|
2386
|
+
while (monthStart < dayOfYear) {
|
|
2387
|
+
monthStart += $cc2b03afe24b76b3bf6ec565767e7$var$getDaysInMonth(year, month);
|
|
2388
|
+
month++;
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
month--;
|
|
2392
|
+
monthStart -= $cc2b03afe24b76b3bf6ec565767e7$var$getDaysInMonth(year, month);
|
|
2393
|
+
let day = dayOfYear - monthStart;
|
|
2394
|
+
return new CalendarDate(this, year, month, day);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
toJulianDay(date) {
|
|
2398
|
+
let jd = $cc2b03afe24b76b3bf6ec565767e7$var$startOfYear(date.year);
|
|
2399
|
+
|
|
2400
|
+
for (let month = 1; month < date.month; month++) {
|
|
2401
|
+
jd += $cc2b03afe24b76b3bf6ec565767e7$var$getDaysInMonth(date.year, month);
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
return jd + date.day + $cc2b03afe24b76b3bf6ec565767e7$var$HEBREW_EPOCH;
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
getDaysInMonth(date) {
|
|
2408
|
+
return $cc2b03afe24b76b3bf6ec565767e7$var$getDaysInMonth(date.year, date.month);
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
getMonthsInYear(date) {
|
|
2412
|
+
return $cc2b03afe24b76b3bf6ec565767e7$var$isLeapYear(date.year) ? 13 : 12;
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
getDaysInYear(date) {
|
|
2416
|
+
return $cc2b03afe24b76b3bf6ec565767e7$var$getDaysInYear(date.year);
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
getYearsInEra() {
|
|
2420
|
+
return 9999;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
getEras() {
|
|
2424
|
+
return ['AM'];
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
balanceYearMonth(date, previousDate) {
|
|
2428
|
+
// Keep date in the same month when switching between leap years and non leap years
|
|
2429
|
+
if (previousDate.year !== date.year) {
|
|
2430
|
+
if ($cc2b03afe24b76b3bf6ec565767e7$var$isLeapYear(previousDate.year) && !$cc2b03afe24b76b3bf6ec565767e7$var$isLeapYear(date.year) && previousDate.month > 6) {
|
|
2431
|
+
date.month--;
|
|
2432
|
+
} else if (!$cc2b03afe24b76b3bf6ec565767e7$var$isLeapYear(previousDate.year) && $cc2b03afe24b76b3bf6ec565767e7$var$isLeapYear(date.year) && previousDate.month > 6) {
|
|
2433
|
+
date.month++;
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
exports.HebrewCalendar = HebrewCalendar;
|
|
2441
|
+
const $e97ab861d6249e3f231cf864175fa721$var$ETHIOPIC_EPOCH = 1723856;
|
|
2442
|
+
const $e97ab861d6249e3f231cf864175fa721$var$COPTIC_EPOCH = 1824665; // The delta between Amete Alem 1 and Amete Mihret 1
|
|
2443
|
+
// AA 5501 = AM 1
|
|
2444
|
+
|
|
2445
|
+
const $e97ab861d6249e3f231cf864175fa721$var$AMETE_MIHRET_DELTA = 5500;
|
|
2446
|
+
|
|
2447
|
+
function $e97ab861d6249e3f231cf864175fa721$var$ceToJulianDay(epoch, year, month, day) {
|
|
2448
|
+
return epoch + 365 * year + Math.floor(year / 4) // extra day of leap year
|
|
2449
|
+
+ 30 * (month - 1) // number of days from months (1 based)
|
|
2450
|
+
+ day - 1 // number of days for present month (1 based)
|
|
2451
|
+
;
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
function $e97ab861d6249e3f231cf864175fa721$var$julianDayToCE(calendar, epoch, jd) {
|
|
2455
|
+
let year = Math.floor(4 * (jd - epoch) / 1461);
|
|
2456
|
+
let month = 1 + Math.floor((jd - $e97ab861d6249e3f231cf864175fa721$var$ceToJulianDay(epoch, year, 1, 1)) / 30);
|
|
2457
|
+
let day = jd + 1 - $e97ab861d6249e3f231cf864175fa721$var$ceToJulianDay(epoch, year, month, 1);
|
|
2458
|
+
return new CalendarDate(calendar, year, month, day);
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
function $e97ab861d6249e3f231cf864175fa721$var$getLeapDay(year) {
|
|
2462
|
+
return Math.floor(year % 4 / 3);
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
function $e97ab861d6249e3f231cf864175fa721$var$getDaysInMonth(year, month) {
|
|
2466
|
+
// The Ethiopian and Coptic calendars have 13 months, 12 of 30 days each and
|
|
2467
|
+
// an intercalary month at the end of the year of 5 or 6 days, depending whether
|
|
2468
|
+
// the year is a leap year or not. The Leap Year follows the same rules as the
|
|
2469
|
+
// Julian Calendar so that the extra month always has six days in the year before
|
|
2470
|
+
// a Julian Leap Year.
|
|
2471
|
+
if (month % 13 !== 0) {
|
|
2472
|
+
// not intercalary month
|
|
2473
|
+
return 30;
|
|
2474
|
+
} else {
|
|
2475
|
+
// intercalary month 5 days + possible leap day
|
|
2476
|
+
return $e97ab861d6249e3f231cf864175fa721$var$getLeapDay(year) + 5;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
class EthiopicCalendar {
|
|
2481
|
+
constructor() {
|
|
2482
|
+
this.identifier = 'ethiopic';
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
fromJulianDay(jd) {
|
|
2486
|
+
let date = $e97ab861d6249e3f231cf864175fa721$var$julianDayToCE(this, $e97ab861d6249e3f231cf864175fa721$var$ETHIOPIC_EPOCH, jd);
|
|
2487
|
+
|
|
2488
|
+
if (date.year > 0) {
|
|
2489
|
+
date.era = 'AM';
|
|
2490
|
+
} else {
|
|
2491
|
+
date.era = 'AA';
|
|
2492
|
+
date.year += $e97ab861d6249e3f231cf864175fa721$var$AMETE_MIHRET_DELTA;
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
return date;
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
toJulianDay(date) {
|
|
2499
|
+
let year = date.year;
|
|
2500
|
+
|
|
2501
|
+
if (date.era === 'AA') {
|
|
2502
|
+
year -= $e97ab861d6249e3f231cf864175fa721$var$AMETE_MIHRET_DELTA;
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
return $e97ab861d6249e3f231cf864175fa721$var$ceToJulianDay($e97ab861d6249e3f231cf864175fa721$var$ETHIOPIC_EPOCH, year, date.month, date.day);
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
getDaysInMonth(date) {
|
|
2509
|
+
let year = date.year;
|
|
2510
|
+
|
|
2511
|
+
if (date.era === 'AA') {
|
|
2512
|
+
year -= $e97ab861d6249e3f231cf864175fa721$var$AMETE_MIHRET_DELTA;
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
return $e97ab861d6249e3f231cf864175fa721$var$getDaysInMonth(year, date.month);
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2518
|
+
getMonthsInYear() {
|
|
2519
|
+
return 13;
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
getDaysInYear(date) {
|
|
2523
|
+
return 365 + $e97ab861d6249e3f231cf864175fa721$var$getLeapDay(date.year);
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
getYearsInEra() {
|
|
2527
|
+
return 9999;
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
getEras() {
|
|
2531
|
+
return ['AA', 'AM'];
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
exports.EthiopicCalendar = EthiopicCalendar;
|
|
2537
|
+
|
|
2538
|
+
class EthiopicAmeteAlemCalendar extends EthiopicCalendar {
|
|
2539
|
+
constructor() {
|
|
2540
|
+
super(...arguments);
|
|
2541
|
+
this.identifier = 'ethioaa';
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
// also known as 'ethiopic-amete-alem' in ICU
|
|
2545
|
+
fromJulianDay(jd) {
|
|
2546
|
+
let date = $e97ab861d6249e3f231cf864175fa721$var$julianDayToCE(this, $e97ab861d6249e3f231cf864175fa721$var$ETHIOPIC_EPOCH, jd);
|
|
2547
|
+
date.era = 'AA';
|
|
2548
|
+
date.year += $e97ab861d6249e3f231cf864175fa721$var$AMETE_MIHRET_DELTA;
|
|
2549
|
+
return date;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
getEras() {
|
|
2553
|
+
return ['AA'];
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
exports.EthiopicAmeteAlemCalendar = EthiopicAmeteAlemCalendar;
|
|
2559
|
+
|
|
2560
|
+
class CopticCalendar extends EthiopicCalendar {
|
|
2561
|
+
constructor() {
|
|
2562
|
+
super(...arguments);
|
|
2563
|
+
this.identifier = 'coptic';
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
fromJulianDay(jd) {
|
|
2567
|
+
let date = $e97ab861d6249e3f231cf864175fa721$var$julianDayToCE(this, $e97ab861d6249e3f231cf864175fa721$var$COPTIC_EPOCH, jd);
|
|
2568
|
+
|
|
2569
|
+
if (date.year <= 0) {
|
|
2570
|
+
date.era = 'BCE';
|
|
2571
|
+
date.year = 1 - date.year;
|
|
2572
|
+
} else {
|
|
2573
|
+
date.era = 'CE';
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
return date;
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
toJulianDay(date) {
|
|
2580
|
+
let year = date.year;
|
|
2581
|
+
|
|
2582
|
+
if (date.era === 'BCE') {
|
|
2583
|
+
year = 1 - year;
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
return $e97ab861d6249e3f231cf864175fa721$var$ceToJulianDay($e97ab861d6249e3f231cf864175fa721$var$COPTIC_EPOCH, year, date.month, date.day);
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
getDaysInMonth(date) {
|
|
2590
|
+
let year = date.year;
|
|
2591
|
+
|
|
2592
|
+
if (date.era === 'BCE') {
|
|
2593
|
+
year = 1 - year;
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
return $e97ab861d6249e3f231cf864175fa721$var$getDaysInMonth(year, date.month);
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
getYearsToAdd(date, years) {
|
|
2600
|
+
return date.era === 'BCE' ? -years : years;
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
getEras() {
|
|
2604
|
+
return ['BCE', 'CE'];
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
exports.CopticCalendar = CopticCalendar;
|
|
2610
|
+
|
|
2611
|
+
function createCalendar(name) {
|
|
2612
|
+
switch (name) {
|
|
2613
|
+
case 'buddhist':
|
|
2614
|
+
return new BuddhistCalendar();
|
|
2615
|
+
|
|
2616
|
+
case 'ethiopic':
|
|
2617
|
+
return new EthiopicCalendar();
|
|
2618
|
+
|
|
2619
|
+
case 'ethioaa':
|
|
2620
|
+
return new EthiopicAmeteAlemCalendar();
|
|
2621
|
+
|
|
2622
|
+
case 'coptic':
|
|
2623
|
+
return new CopticCalendar();
|
|
2624
|
+
|
|
2625
|
+
case 'hebrew':
|
|
2626
|
+
return new HebrewCalendar();
|
|
2627
|
+
|
|
2628
|
+
case 'indian':
|
|
2629
|
+
return new IndianCalendar();
|
|
2630
|
+
|
|
2631
|
+
case 'islamic-civil':
|
|
2632
|
+
return new IslamicCivilCalendar();
|
|
2633
|
+
|
|
2634
|
+
case 'islamic-tbla':
|
|
2635
|
+
return new IslamicTabularCalendar();
|
|
2636
|
+
|
|
2637
|
+
case 'islamic-umalqura':
|
|
2638
|
+
return new IslamicUmalquraCalendar();
|
|
2639
|
+
|
|
2640
|
+
case 'japanese':
|
|
2641
|
+
return new JapaneseCalendar();
|
|
2642
|
+
|
|
2643
|
+
case 'persian':
|
|
2644
|
+
return new PersianCalendar();
|
|
2645
|
+
|
|
2646
|
+
case 'roc':
|
|
2647
|
+
return new TaiwanCalendar();
|
|
2648
|
+
|
|
2649
|
+
case 'gregory':
|
|
2650
|
+
default:
|
|
2651
|
+
return new GregorianCalendar();
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
exports.createCalendar = createCalendar;
|
|
2656
|
+
let $ecb868e9bf656e44b130863ca06$var$formatterCache = new Map();
|
|
2657
|
+
|
|
2658
|
+
class DateFormatter {
|
|
2659
|
+
constructor(locale, options) {
|
|
2660
|
+
if (options === void 0) {
|
|
2661
|
+
options = {};
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
this.formatter = void 0;
|
|
2665
|
+
this.options = void 0;
|
|
2666
|
+
this.resolvedHourCycle = void 0;
|
|
2667
|
+
this.formatter = $ecb868e9bf656e44b130863ca06$var$getCachedDateFormatter(locale, options);
|
|
2668
|
+
this.options = options;
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
format(value) {
|
|
2672
|
+
return this.formatter.format(value);
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
formatToParts(value) {
|
|
2676
|
+
return this.formatter.formatToParts(value);
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
formatRange(start, end) {
|
|
2680
|
+
// @ts-ignore
|
|
2681
|
+
if (typeof this.formatter.formatRange === 'function') {
|
|
2682
|
+
// @ts-ignore
|
|
2683
|
+
return this.formatter.formatRange(start, end);
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
if (end < start) {
|
|
2687
|
+
throw new RangeError('End date must be >= start date');
|
|
2688
|
+
} // Very basic fallback for old browsers.
|
|
2689
|
+
|
|
2690
|
+
|
|
2691
|
+
return this.formatter.format(start) + " \u2013 " + this.formatter.format(end);
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
formatRangeToParts(start, end) {
|
|
2695
|
+
// @ts-ignore
|
|
2696
|
+
if (typeof this.formatter.formatRangeToParts === 'function') {
|
|
2697
|
+
// @ts-ignore
|
|
2698
|
+
return this.formatter.formatRangeToParts(start, end);
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
if (end < start) {
|
|
2702
|
+
throw new RangeError('End date must be >= start date');
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
let startParts = this.formatter.formatToParts(start);
|
|
2706
|
+
let endParts = this.formatter.formatToParts(end);
|
|
2707
|
+
return [...startParts.map(p => _babelRuntimeHelpersExtends({}, p, {
|
|
2708
|
+
source: 'startRange'
|
|
2709
|
+
})), {
|
|
2710
|
+
type: 'literal',
|
|
2711
|
+
value: ' – ',
|
|
2712
|
+
source: 'shared'
|
|
2713
|
+
}, ...endParts.map(p => _babelRuntimeHelpersExtends({}, p, {
|
|
2714
|
+
source: 'endRange'
|
|
2715
|
+
}))];
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
resolvedOptions() {
|
|
2719
|
+
let resolvedOptions = this.formatter.resolvedOptions();
|
|
2720
|
+
|
|
2721
|
+
if ($ecb868e9bf656e44b130863ca06$var$hasBuggyResolvedHourCycle()) {
|
|
2722
|
+
if (!this.resolvedHourCycle) {
|
|
2723
|
+
this.resolvedHourCycle = $ecb868e9bf656e44b130863ca06$var$getResolvedHourCycle(resolvedOptions.locale, this.options);
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
resolvedOptions.hourCycle = this.resolvedHourCycle;
|
|
2727
|
+
resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
return resolvedOptions;
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2733
|
+
} // There are multiple bugs involving the hour12 and hourCycle options in various browser engines.
|
|
2734
|
+
// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)
|
|
2735
|
+
// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)
|
|
2736
|
+
// rather than h12 (12:00 - 11:59).
|
|
2737
|
+
// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal
|
|
2738
|
+
// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]
|
|
2739
|
+
// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791
|
|
2740
|
+
// [2] https://github.com/tc39/ecma402/issues/402
|
|
2741
|
+
// [3] https://bugs.webkit.org/show_bug.cgi?id=229313
|
|
2742
|
+
// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802
|
|
2743
|
+
|
|
2744
|
+
|
|
2745
|
+
exports.DateFormatter = DateFormatter;
|
|
2746
|
+
const $ecb868e9bf656e44b130863ca06$var$hour12Preferences = {
|
|
2747
|
+
true: {
|
|
2748
|
+
// Only Japanese uses the h11 style for 12 hour time. All others use h12.
|
|
2749
|
+
ja: 'h11'
|
|
2750
|
+
},
|
|
2751
|
+
false: {// All locales use h23 for 24 hour time. None use h24.
|
|
2752
|
+
}
|
|
2753
|
+
};
|
|
2754
|
+
|
|
2755
|
+
function $ecb868e9bf656e44b130863ca06$var$getCachedDateFormatter(locale, options) {
|
|
2756
|
+
if (options === void 0) {
|
|
2757
|
+
options = {};
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
// Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.
|
|
2761
|
+
// Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.
|
|
2762
|
+
if (typeof options.hour12 === 'boolean' && $ecb868e9bf656e44b130863ca06$var$hasBuggyHour12Behavior()) {
|
|
2763
|
+
options = _babelRuntimeHelpersExtends({}, options);
|
|
2764
|
+
let pref = $ecb868e9bf656e44b130863ca06$var$hour12Preferences[String(options.hour12)][locale.split('-')[0]];
|
|
2765
|
+
let defaultHourCycle = options.hour12 ? 'h12' : 'h23';
|
|
2766
|
+
options.hourCycle = pref != null ? pref : defaultHourCycle;
|
|
2767
|
+
delete options.hour12;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');
|
|
2771
|
+
|
|
2772
|
+
if ($ecb868e9bf656e44b130863ca06$var$formatterCache.has(cacheKey)) {
|
|
2773
|
+
return $ecb868e9bf656e44b130863ca06$var$formatterCache.get(cacheKey);
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
let numberFormatter = new Intl.DateTimeFormat(locale, options);
|
|
2777
|
+
$ecb868e9bf656e44b130863ca06$var$formatterCache.set(cacheKey, numberFormatter);
|
|
2778
|
+
return numberFormatter;
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
let $ecb868e9bf656e44b130863ca06$var$_hasBuggyHour12Behavior = null;
|
|
2782
|
+
|
|
2783
|
+
function $ecb868e9bf656e44b130863ca06$var$hasBuggyHour12Behavior() {
|
|
2784
|
+
if ($ecb868e9bf656e44b130863ca06$var$_hasBuggyHour12Behavior == null) {
|
|
2785
|
+
$ecb868e9bf656e44b130863ca06$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', {
|
|
2786
|
+
hour: 'numeric',
|
|
2787
|
+
hour12: false
|
|
2788
|
+
}).format(new Date(2020, 2, 3, 0)) === '24';
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
return $ecb868e9bf656e44b130863ca06$var$_hasBuggyHour12Behavior;
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
let $ecb868e9bf656e44b130863ca06$var$_hasBuggyResolvedHourCycle = null;
|
|
2795
|
+
|
|
2796
|
+
function $ecb868e9bf656e44b130863ca06$var$hasBuggyResolvedHourCycle() {
|
|
2797
|
+
if ($ecb868e9bf656e44b130863ca06$var$_hasBuggyResolvedHourCycle == null) {
|
|
2798
|
+
$ecb868e9bf656e44b130863ca06$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', {
|
|
2799
|
+
hour: 'numeric',
|
|
2800
|
+
hour12: false
|
|
2801
|
+
}).resolvedOptions().hourCycle === 'h12';
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
return $ecb868e9bf656e44b130863ca06$var$_hasBuggyResolvedHourCycle;
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
function $ecb868e9bf656e44b130863ca06$var$getResolvedHourCycle(locale, options) {
|
|
2808
|
+
if (!options.timeStyle && !options.hour) {
|
|
2809
|
+
return undefined;
|
|
2810
|
+
} // Work around buggy results in resolved hourCycle and hour12 options in WebKit.
|
|
2811
|
+
// Format the minimum possible hour and maximum possible hour in a day and parse the results.
|
|
2812
|
+
|
|
2813
|
+
|
|
2814
|
+
locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');
|
|
2815
|
+
locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';
|
|
2816
|
+
let formatter = $ecb868e9bf656e44b130863ca06$var$getCachedDateFormatter(locale, _babelRuntimeHelpersExtends({}, options, {
|
|
2817
|
+
timeZone: undefined // use local timezone
|
|
2818
|
+
|
|
2819
|
+
}));
|
|
2820
|
+
let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find(p => p.type === 'hour').value, 10);
|
|
2821
|
+
let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find(p => p.type === 'hour').value, 10);
|
|
2822
|
+
|
|
2823
|
+
if (min === 0 && max === 23) {
|
|
2824
|
+
return 'h23';
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2827
|
+
if (min === 24 && max === 23) {
|
|
2828
|
+
return 'h24';
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2831
|
+
if (min === 0 && max === 11) {
|
|
2832
|
+
return 'h11';
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
if (min === 12 && max === 11) {
|
|
2836
|
+
return 'h12';
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
throw new Error('Unexpected hour cycle result');
|
|
2840
|
+
}
|
|
2841
|
+
//# sourceMappingURL=main.js.map
|