@internationalized/date 3.5.4-nightly.4624 → 3.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BuddhistCalendar.main.js +2 -2
- package/dist/BuddhistCalendar.mjs +2 -2
- package/dist/BuddhistCalendar.module.js +2 -2
- package/dist/CalendarDate.main.js +6 -6
- package/dist/CalendarDate.mjs +6 -6
- package/dist/CalendarDate.module.js +6 -6
- package/dist/DateFormatter.main.js +30 -30
- package/dist/DateFormatter.mjs +30 -30
- package/dist/DateFormatter.module.js +30 -30
- package/dist/EthiopicCalendar.main.js +20 -20
- package/dist/EthiopicCalendar.mjs +20 -20
- package/dist/EthiopicCalendar.module.js +20 -20
- package/dist/GregorianCalendar.main.js +9 -9
- package/dist/GregorianCalendar.mjs +9 -9
- package/dist/GregorianCalendar.module.js +9 -9
- package/dist/HebrewCalendar.main.js +2 -2
- package/dist/HebrewCalendar.mjs +2 -2
- package/dist/HebrewCalendar.module.js +2 -2
- package/dist/IndianCalendar.main.js +2 -2
- package/dist/IndianCalendar.mjs +2 -2
- package/dist/IndianCalendar.module.js +2 -2
- package/dist/IslamicCalendar.main.js +5 -5
- package/dist/IslamicCalendar.mjs +5 -5
- package/dist/IslamicCalendar.module.js +5 -5
- package/dist/JapaneseCalendar.main.js +7 -7
- package/dist/JapaneseCalendar.mjs +7 -7
- package/dist/JapaneseCalendar.module.js +7 -7
- package/dist/PersianCalendar.main.js +2 -2
- package/dist/PersianCalendar.mjs +2 -2
- package/dist/PersianCalendar.module.js +2 -2
- package/dist/TaiwanCalendar.main.js +8 -8
- package/dist/TaiwanCalendar.mjs +8 -8
- package/dist/TaiwanCalendar.module.js +8 -8
- package/dist/conversion.main.js +28 -28
- package/dist/conversion.mjs +28 -28
- package/dist/conversion.module.js +28 -28
- package/dist/createCalendar.main.js +13 -13
- package/dist/createCalendar.mjs +13 -13
- package/dist/createCalendar.module.js +13 -13
- package/dist/manipulation.main.js +26 -26
- package/dist/manipulation.mjs +26 -26
- package/dist/manipulation.module.js +26 -26
- package/dist/queries.main.js +2 -2
- package/dist/queries.mjs +2 -2
- package/dist/queries.module.js +2 -2
- package/dist/string.main.js +19 -19
- package/dist/string.mjs +19 -19
- package/dist/string.module.js +19 -19
- package/dist/weekStartData.main.js +1 -1
- package/dist/weekStartData.mjs +1 -1
- package/dist/weekStartData.module.js +1 -1
- package/package.json +2 -2
|
@@ -33,7 +33,7 @@ class $561c4ef058278b74$export$42d20a78301dee44 extends (0, $af14c9812fdceb33$ex
|
|
|
33
33
|
}
|
|
34
34
|
getEras() {
|
|
35
35
|
return [
|
|
36
|
-
|
|
36
|
+
'BE'
|
|
37
37
|
];
|
|
38
38
|
}
|
|
39
39
|
getDaysInMonth(date) {
|
|
@@ -42,7 +42,7 @@ class $561c4ef058278b74$export$42d20a78301dee44 extends (0, $af14c9812fdceb33$ex
|
|
|
42
42
|
balanceDate() {}
|
|
43
43
|
constructor(...args){
|
|
44
44
|
super(...args);
|
|
45
|
-
this.identifier =
|
|
45
|
+
this.identifier = 'buddhist';
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
function $561c4ef058278b74$var$toGregorian(date) {
|
|
@@ -27,7 +27,7 @@ class $8d73d47422ca7302$export$42d20a78301dee44 extends (0, $3b62074eb05584b2$ex
|
|
|
27
27
|
}
|
|
28
28
|
getEras() {
|
|
29
29
|
return [
|
|
30
|
-
|
|
30
|
+
'BE'
|
|
31
31
|
];
|
|
32
32
|
}
|
|
33
33
|
getDaysInMonth(date) {
|
|
@@ -36,7 +36,7 @@ class $8d73d47422ca7302$export$42d20a78301dee44 extends (0, $3b62074eb05584b2$ex
|
|
|
36
36
|
balanceDate() {}
|
|
37
37
|
constructor(...args){
|
|
38
38
|
super(...args);
|
|
39
|
-
this.identifier =
|
|
39
|
+
this.identifier = 'buddhist';
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function $8d73d47422ca7302$var$toGregorian(date) {
|
|
@@ -27,7 +27,7 @@ class $8d73d47422ca7302$export$42d20a78301dee44 extends (0, $3b62074eb05584b2$ex
|
|
|
27
27
|
}
|
|
28
28
|
getEras() {
|
|
29
29
|
return [
|
|
30
|
-
|
|
30
|
+
'BE'
|
|
31
31
|
];
|
|
32
32
|
}
|
|
33
33
|
getDaysInMonth(date) {
|
|
@@ -36,7 +36,7 @@ class $8d73d47422ca7302$export$42d20a78301dee44 extends (0, $3b62074eb05584b2$ex
|
|
|
36
36
|
balanceDate() {}
|
|
37
37
|
constructor(...args){
|
|
38
38
|
super(...args);
|
|
39
|
-
this.identifier =
|
|
39
|
+
this.identifier = 'buddhist';
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function $8d73d47422ca7302$var$toGregorian(date) {
|
|
@@ -31,9 +31,9 @@ $parcel$export(module.exports, "ZonedDateTime", () => $625ad1e1f4c43bc1$export$d
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
function $625ad1e1f4c43bc1$var$shiftArgs(args) {
|
|
34
|
-
let calendar = typeof args[0] ===
|
|
34
|
+
let calendar = typeof args[0] === 'object' ? args.shift() : new (0, $af14c9812fdceb33$exports.GregorianCalendar)();
|
|
35
35
|
let era;
|
|
36
|
-
if (typeof args[0] ===
|
|
36
|
+
if (typeof args[0] === 'string') era = args.shift();
|
|
37
37
|
else {
|
|
38
38
|
let eras = calendar.getEras();
|
|
39
39
|
era = eras[eras.length - 1];
|
|
@@ -159,10 +159,10 @@ class $625ad1e1f4c43bc1$export$ca871e8dbb80966f {
|
|
|
159
159
|
* When the resulting value reaches the limits of the field, it wraps around.
|
|
160
160
|
*/ cycle(field, amount, options) {
|
|
161
161
|
switch(field){
|
|
162
|
-
case
|
|
163
|
-
case
|
|
164
|
-
case
|
|
165
|
-
case
|
|
162
|
+
case 'era':
|
|
163
|
+
case 'year':
|
|
164
|
+
case 'month':
|
|
165
|
+
case 'day':
|
|
166
166
|
return (0, $5c0571aa5b6fb5da$exports.cycleDate)(this, field, amount, options);
|
|
167
167
|
default:
|
|
168
168
|
return (0, $5c0571aa5b6fb5da$exports.cycleTime)(this, field, amount, options);
|
package/dist/CalendarDate.mjs
CHANGED
|
@@ -22,9 +22,9 @@ import {_ as $aksy1$_} from "@swc/helpers/_/_class_private_field_init";
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
function $35ea8db9cb2ccb90$var$shiftArgs(args) {
|
|
25
|
-
let calendar = typeof args[0] ===
|
|
25
|
+
let calendar = typeof args[0] === 'object' ? args.shift() : new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)();
|
|
26
26
|
let era;
|
|
27
|
-
if (typeof args[0] ===
|
|
27
|
+
if (typeof args[0] === 'string') era = args.shift();
|
|
28
28
|
else {
|
|
29
29
|
let eras = calendar.getEras();
|
|
30
30
|
era = eras[eras.length - 1];
|
|
@@ -150,10 +150,10 @@ class $35ea8db9cb2ccb90$export$ca871e8dbb80966f {
|
|
|
150
150
|
* When the resulting value reaches the limits of the field, it wraps around.
|
|
151
151
|
*/ cycle(field, amount, options) {
|
|
152
152
|
switch(field){
|
|
153
|
-
case
|
|
154
|
-
case
|
|
155
|
-
case
|
|
156
|
-
case
|
|
153
|
+
case 'era':
|
|
154
|
+
case 'year':
|
|
155
|
+
case 'month':
|
|
156
|
+
case 'day':
|
|
157
157
|
return (0, $735220c2d4774dd3$export$d52ced6badfb9a4c)(this, field, amount, options);
|
|
158
158
|
default:
|
|
159
159
|
return (0, $735220c2d4774dd3$export$dd02b3e0007dfe28)(this, field, amount, options);
|
|
@@ -22,9 +22,9 @@ import {_ as $aksy1$_} from "@swc/helpers/_/_class_private_field_init";
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
function $35ea8db9cb2ccb90$var$shiftArgs(args) {
|
|
25
|
-
let calendar = typeof args[0] ===
|
|
25
|
+
let calendar = typeof args[0] === 'object' ? args.shift() : new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)();
|
|
26
26
|
let era;
|
|
27
|
-
if (typeof args[0] ===
|
|
27
|
+
if (typeof args[0] === 'string') era = args.shift();
|
|
28
28
|
else {
|
|
29
29
|
let eras = calendar.getEras();
|
|
30
30
|
era = eras[eras.length - 1];
|
|
@@ -150,10 +150,10 @@ class $35ea8db9cb2ccb90$export$ca871e8dbb80966f {
|
|
|
150
150
|
* When the resulting value reaches the limits of the field, it wraps around.
|
|
151
151
|
*/ cycle(field, amount, options) {
|
|
152
152
|
switch(field){
|
|
153
|
-
case
|
|
154
|
-
case
|
|
155
|
-
case
|
|
156
|
-
case
|
|
153
|
+
case 'era':
|
|
154
|
+
case 'year':
|
|
155
|
+
case 'month':
|
|
156
|
+
case 'day':
|
|
157
157
|
return (0, $735220c2d4774dd3$export$d52ced6badfb9a4c)(this, field, amount, options);
|
|
158
158
|
default:
|
|
159
159
|
return (0, $735220c2d4774dd3$export$dd02b3e0007dfe28)(this, field, amount, options);
|
|
@@ -24,32 +24,32 @@ class $8f23a04ae90a588b$export$ad991b66133851cf {
|
|
|
24
24
|
}
|
|
25
25
|
/** Formats a date range as a string. */ formatRange(start, end) {
|
|
26
26
|
// @ts-ignore
|
|
27
|
-
if (typeof this.formatter.formatRange ===
|
|
27
|
+
if (typeof this.formatter.formatRange === 'function') // @ts-ignore
|
|
28
28
|
return this.formatter.formatRange(start, end);
|
|
29
|
-
if (end < start) throw new RangeError(
|
|
29
|
+
if (end < start) throw new RangeError('End date must be >= start date');
|
|
30
30
|
// Very basic fallback for old browsers.
|
|
31
31
|
return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`;
|
|
32
32
|
}
|
|
33
33
|
/** Formats a date range as an array of parts. */ formatRangeToParts(start, end) {
|
|
34
34
|
// @ts-ignore
|
|
35
|
-
if (typeof this.formatter.formatRangeToParts ===
|
|
35
|
+
if (typeof this.formatter.formatRangeToParts === 'function') // @ts-ignore
|
|
36
36
|
return this.formatter.formatRangeToParts(start, end);
|
|
37
|
-
if (end < start) throw new RangeError(
|
|
37
|
+
if (end < start) throw new RangeError('End date must be >= start date');
|
|
38
38
|
let startParts = this.formatter.formatToParts(start);
|
|
39
39
|
let endParts = this.formatter.formatToParts(end);
|
|
40
40
|
return [
|
|
41
41
|
...startParts.map((p)=>({
|
|
42
42
|
...p,
|
|
43
|
-
source:
|
|
43
|
+
source: 'startRange'
|
|
44
44
|
})),
|
|
45
45
|
{
|
|
46
|
-
type:
|
|
46
|
+
type: 'literal',
|
|
47
47
|
value: " \u2013 ",
|
|
48
|
-
source:
|
|
48
|
+
source: 'shared'
|
|
49
49
|
},
|
|
50
50
|
...endParts.map((p)=>({
|
|
51
51
|
...p,
|
|
52
|
-
source:
|
|
52
|
+
source: 'endRange'
|
|
53
53
|
}))
|
|
54
54
|
];
|
|
55
55
|
}
|
|
@@ -58,11 +58,11 @@ class $8f23a04ae90a588b$export$ad991b66133851cf {
|
|
|
58
58
|
if ($8f23a04ae90a588b$var$hasBuggyResolvedHourCycle()) {
|
|
59
59
|
if (!this.resolvedHourCycle) this.resolvedHourCycle = $8f23a04ae90a588b$var$getResolvedHourCycle(resolvedOptions.locale, this.options);
|
|
60
60
|
resolvedOptions.hourCycle = this.resolvedHourCycle;
|
|
61
|
-
resolvedOptions.hour12 = this.resolvedHourCycle ===
|
|
61
|
+
resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';
|
|
62
62
|
}
|
|
63
63
|
// Safari uses a different name for the Ethiopic (Amete Alem) calendar.
|
|
64
64
|
// https://bugs.webkit.org/show_bug.cgi?id=241564
|
|
65
|
-
if (resolvedOptions.calendar ===
|
|
65
|
+
if (resolvedOptions.calendar === 'ethiopic-amete-alem') resolvedOptions.calendar = 'ethioaa';
|
|
66
66
|
return resolvedOptions;
|
|
67
67
|
}
|
|
68
68
|
constructor(locale, options = {}){
|
|
@@ -83,7 +83,7 @@ class $8f23a04ae90a588b$export$ad991b66133851cf {
|
|
|
83
83
|
const $8f23a04ae90a588b$var$hour12Preferences = {
|
|
84
84
|
true: {
|
|
85
85
|
// Only Japanese uses the h11 style for 12 hour time. All others use h12.
|
|
86
|
-
ja:
|
|
86
|
+
ja: 'h11'
|
|
87
87
|
},
|
|
88
88
|
false: {
|
|
89
89
|
}
|
|
@@ -91,16 +91,16 @@ const $8f23a04ae90a588b$var$hour12Preferences = {
|
|
|
91
91
|
function $8f23a04ae90a588b$var$getCachedDateFormatter(locale, options = {}) {
|
|
92
92
|
// Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.
|
|
93
93
|
// Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.
|
|
94
|
-
if (typeof options.hour12 ===
|
|
94
|
+
if (typeof options.hour12 === 'boolean' && $8f23a04ae90a588b$var$hasBuggyHour12Behavior()) {
|
|
95
95
|
options = {
|
|
96
96
|
...options
|
|
97
97
|
};
|
|
98
|
-
let pref = $8f23a04ae90a588b$var$hour12Preferences[String(options.hour12)][locale.split(
|
|
99
|
-
let defaultHourCycle = options.hour12 ?
|
|
98
|
+
let pref = $8f23a04ae90a588b$var$hour12Preferences[String(options.hour12)][locale.split('-')[0]];
|
|
99
|
+
let defaultHourCycle = options.hour12 ? 'h12' : 'h23';
|
|
100
100
|
options.hourCycle = pref !== null && pref !== void 0 ? pref : defaultHourCycle;
|
|
101
101
|
delete options.hour12;
|
|
102
102
|
}
|
|
103
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() :
|
|
103
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : '');
|
|
104
104
|
if ($8f23a04ae90a588b$var$formatterCache.has(cacheKey)) return $8f23a04ae90a588b$var$formatterCache.get(cacheKey);
|
|
105
105
|
let numberFormatter = new Intl.DateTimeFormat(locale, options);
|
|
106
106
|
$8f23a04ae90a588b$var$formatterCache.set(cacheKey, numberFormatter);
|
|
@@ -108,37 +108,37 @@ function $8f23a04ae90a588b$var$getCachedDateFormatter(locale, options = {}) {
|
|
|
108
108
|
}
|
|
109
109
|
let $8f23a04ae90a588b$var$_hasBuggyHour12Behavior = null;
|
|
110
110
|
function $8f23a04ae90a588b$var$hasBuggyHour12Behavior() {
|
|
111
|
-
if ($8f23a04ae90a588b$var$_hasBuggyHour12Behavior == null) $8f23a04ae90a588b$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat(
|
|
112
|
-
hour:
|
|
111
|
+
if ($8f23a04ae90a588b$var$_hasBuggyHour12Behavior == null) $8f23a04ae90a588b$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', {
|
|
112
|
+
hour: 'numeric',
|
|
113
113
|
hour12: false
|
|
114
|
-
}).format(new Date(2020, 2, 3, 0)) ===
|
|
114
|
+
}).format(new Date(2020, 2, 3, 0)) === '24';
|
|
115
115
|
return $8f23a04ae90a588b$var$_hasBuggyHour12Behavior;
|
|
116
116
|
}
|
|
117
117
|
let $8f23a04ae90a588b$var$_hasBuggyResolvedHourCycle = null;
|
|
118
118
|
function $8f23a04ae90a588b$var$hasBuggyResolvedHourCycle() {
|
|
119
|
-
if ($8f23a04ae90a588b$var$_hasBuggyResolvedHourCycle == null) $8f23a04ae90a588b$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat(
|
|
120
|
-
hour:
|
|
119
|
+
if ($8f23a04ae90a588b$var$_hasBuggyResolvedHourCycle == null) $8f23a04ae90a588b$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', {
|
|
120
|
+
hour: 'numeric',
|
|
121
121
|
hour12: false
|
|
122
|
-
}).resolvedOptions().hourCycle ===
|
|
122
|
+
}).resolvedOptions().hourCycle === 'h12';
|
|
123
123
|
return $8f23a04ae90a588b$var$_hasBuggyResolvedHourCycle;
|
|
124
124
|
}
|
|
125
125
|
function $8f23a04ae90a588b$var$getResolvedHourCycle(locale, options) {
|
|
126
126
|
if (!options.timeStyle && !options.hour) return undefined;
|
|
127
127
|
// Work around buggy results in resolved hourCycle and hour12 options in WebKit.
|
|
128
128
|
// Format the minimum possible hour and maximum possible hour in a day and parse the results.
|
|
129
|
-
locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/,
|
|
130
|
-
locale += (locale.includes(
|
|
129
|
+
locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');
|
|
130
|
+
locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';
|
|
131
131
|
let formatter = $8f23a04ae90a588b$var$getCachedDateFormatter(locale, {
|
|
132
132
|
...options,
|
|
133
133
|
timeZone: undefined // use local timezone
|
|
134
134
|
});
|
|
135
|
-
let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type ===
|
|
136
|
-
let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type ===
|
|
137
|
-
if (min === 0 && max === 23) return
|
|
138
|
-
if (min === 24 && max === 23) return
|
|
139
|
-
if (min === 0 && max === 11) return
|
|
140
|
-
if (min === 12 && max === 11) return
|
|
141
|
-
throw new Error(
|
|
135
|
+
let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type === 'hour').value, 10);
|
|
136
|
+
let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type === 'hour').value, 10);
|
|
137
|
+
if (min === 0 && max === 23) return 'h23';
|
|
138
|
+
if (min === 24 && max === 23) return 'h24';
|
|
139
|
+
if (min === 0 && max === 11) return 'h11';
|
|
140
|
+
if (min === 12 && max === 11) return 'h12';
|
|
141
|
+
throw new Error('Unexpected hour cycle result');
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
|
package/dist/DateFormatter.mjs
CHANGED
|
@@ -18,32 +18,32 @@ class $fb18d541ea1ad717$export$ad991b66133851cf {
|
|
|
18
18
|
}
|
|
19
19
|
/** Formats a date range as a string. */ formatRange(start, end) {
|
|
20
20
|
// @ts-ignore
|
|
21
|
-
if (typeof this.formatter.formatRange ===
|
|
21
|
+
if (typeof this.formatter.formatRange === 'function') // @ts-ignore
|
|
22
22
|
return this.formatter.formatRange(start, end);
|
|
23
|
-
if (end < start) throw new RangeError(
|
|
23
|
+
if (end < start) throw new RangeError('End date must be >= start date');
|
|
24
24
|
// Very basic fallback for old browsers.
|
|
25
25
|
return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`;
|
|
26
26
|
}
|
|
27
27
|
/** Formats a date range as an array of parts. */ formatRangeToParts(start, end) {
|
|
28
28
|
// @ts-ignore
|
|
29
|
-
if (typeof this.formatter.formatRangeToParts ===
|
|
29
|
+
if (typeof this.formatter.formatRangeToParts === 'function') // @ts-ignore
|
|
30
30
|
return this.formatter.formatRangeToParts(start, end);
|
|
31
|
-
if (end < start) throw new RangeError(
|
|
31
|
+
if (end < start) throw new RangeError('End date must be >= start date');
|
|
32
32
|
let startParts = this.formatter.formatToParts(start);
|
|
33
33
|
let endParts = this.formatter.formatToParts(end);
|
|
34
34
|
return [
|
|
35
35
|
...startParts.map((p)=>({
|
|
36
36
|
...p,
|
|
37
|
-
source:
|
|
37
|
+
source: 'startRange'
|
|
38
38
|
})),
|
|
39
39
|
{
|
|
40
|
-
type:
|
|
40
|
+
type: 'literal',
|
|
41
41
|
value: " \u2013 ",
|
|
42
|
-
source:
|
|
42
|
+
source: 'shared'
|
|
43
43
|
},
|
|
44
44
|
...endParts.map((p)=>({
|
|
45
45
|
...p,
|
|
46
|
-
source:
|
|
46
|
+
source: 'endRange'
|
|
47
47
|
}))
|
|
48
48
|
];
|
|
49
49
|
}
|
|
@@ -52,11 +52,11 @@ class $fb18d541ea1ad717$export$ad991b66133851cf {
|
|
|
52
52
|
if ($fb18d541ea1ad717$var$hasBuggyResolvedHourCycle()) {
|
|
53
53
|
if (!this.resolvedHourCycle) this.resolvedHourCycle = $fb18d541ea1ad717$var$getResolvedHourCycle(resolvedOptions.locale, this.options);
|
|
54
54
|
resolvedOptions.hourCycle = this.resolvedHourCycle;
|
|
55
|
-
resolvedOptions.hour12 = this.resolvedHourCycle ===
|
|
55
|
+
resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';
|
|
56
56
|
}
|
|
57
57
|
// Safari uses a different name for the Ethiopic (Amete Alem) calendar.
|
|
58
58
|
// https://bugs.webkit.org/show_bug.cgi?id=241564
|
|
59
|
-
if (resolvedOptions.calendar ===
|
|
59
|
+
if (resolvedOptions.calendar === 'ethiopic-amete-alem') resolvedOptions.calendar = 'ethioaa';
|
|
60
60
|
return resolvedOptions;
|
|
61
61
|
}
|
|
62
62
|
constructor(locale, options = {}){
|
|
@@ -77,7 +77,7 @@ class $fb18d541ea1ad717$export$ad991b66133851cf {
|
|
|
77
77
|
const $fb18d541ea1ad717$var$hour12Preferences = {
|
|
78
78
|
true: {
|
|
79
79
|
// Only Japanese uses the h11 style for 12 hour time. All others use h12.
|
|
80
|
-
ja:
|
|
80
|
+
ja: 'h11'
|
|
81
81
|
},
|
|
82
82
|
false: {
|
|
83
83
|
}
|
|
@@ -85,16 +85,16 @@ const $fb18d541ea1ad717$var$hour12Preferences = {
|
|
|
85
85
|
function $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options = {}) {
|
|
86
86
|
// Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.
|
|
87
87
|
// Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.
|
|
88
|
-
if (typeof options.hour12 ===
|
|
88
|
+
if (typeof options.hour12 === 'boolean' && $fb18d541ea1ad717$var$hasBuggyHour12Behavior()) {
|
|
89
89
|
options = {
|
|
90
90
|
...options
|
|
91
91
|
};
|
|
92
|
-
let pref = $fb18d541ea1ad717$var$hour12Preferences[String(options.hour12)][locale.split(
|
|
93
|
-
let defaultHourCycle = options.hour12 ?
|
|
92
|
+
let pref = $fb18d541ea1ad717$var$hour12Preferences[String(options.hour12)][locale.split('-')[0]];
|
|
93
|
+
let defaultHourCycle = options.hour12 ? 'h12' : 'h23';
|
|
94
94
|
options.hourCycle = pref !== null && pref !== void 0 ? pref : defaultHourCycle;
|
|
95
95
|
delete options.hour12;
|
|
96
96
|
}
|
|
97
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() :
|
|
97
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : '');
|
|
98
98
|
if ($fb18d541ea1ad717$var$formatterCache.has(cacheKey)) return $fb18d541ea1ad717$var$formatterCache.get(cacheKey);
|
|
99
99
|
let numberFormatter = new Intl.DateTimeFormat(locale, options);
|
|
100
100
|
$fb18d541ea1ad717$var$formatterCache.set(cacheKey, numberFormatter);
|
|
@@ -102,37 +102,37 @@ function $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options = {}) {
|
|
|
102
102
|
}
|
|
103
103
|
let $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = null;
|
|
104
104
|
function $fb18d541ea1ad717$var$hasBuggyHour12Behavior() {
|
|
105
|
-
if ($fb18d541ea1ad717$var$_hasBuggyHour12Behavior == null) $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat(
|
|
106
|
-
hour:
|
|
105
|
+
if ($fb18d541ea1ad717$var$_hasBuggyHour12Behavior == null) $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', {
|
|
106
|
+
hour: 'numeric',
|
|
107
107
|
hour12: false
|
|
108
|
-
}).format(new Date(2020, 2, 3, 0)) ===
|
|
108
|
+
}).format(new Date(2020, 2, 3, 0)) === '24';
|
|
109
109
|
return $fb18d541ea1ad717$var$_hasBuggyHour12Behavior;
|
|
110
110
|
}
|
|
111
111
|
let $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = null;
|
|
112
112
|
function $fb18d541ea1ad717$var$hasBuggyResolvedHourCycle() {
|
|
113
|
-
if ($fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle == null) $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat(
|
|
114
|
-
hour:
|
|
113
|
+
if ($fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle == null) $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', {
|
|
114
|
+
hour: 'numeric',
|
|
115
115
|
hour12: false
|
|
116
|
-
}).resolvedOptions().hourCycle ===
|
|
116
|
+
}).resolvedOptions().hourCycle === 'h12';
|
|
117
117
|
return $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle;
|
|
118
118
|
}
|
|
119
119
|
function $fb18d541ea1ad717$var$getResolvedHourCycle(locale, options) {
|
|
120
120
|
if (!options.timeStyle && !options.hour) return undefined;
|
|
121
121
|
// Work around buggy results in resolved hourCycle and hour12 options in WebKit.
|
|
122
122
|
// Format the minimum possible hour and maximum possible hour in a day and parse the results.
|
|
123
|
-
locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/,
|
|
124
|
-
locale += (locale.includes(
|
|
123
|
+
locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');
|
|
124
|
+
locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';
|
|
125
125
|
let formatter = $fb18d541ea1ad717$var$getCachedDateFormatter(locale, {
|
|
126
126
|
...options,
|
|
127
127
|
timeZone: undefined // use local timezone
|
|
128
128
|
});
|
|
129
|
-
let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type ===
|
|
130
|
-
let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type ===
|
|
131
|
-
if (min === 0 && max === 23) return
|
|
132
|
-
if (min === 24 && max === 23) return
|
|
133
|
-
if (min === 0 && max === 11) return
|
|
134
|
-
if (min === 12 && max === 11) return
|
|
135
|
-
throw new Error(
|
|
129
|
+
let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type === 'hour').value, 10);
|
|
130
|
+
let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type === 'hour').value, 10);
|
|
131
|
+
if (min === 0 && max === 23) return 'h23';
|
|
132
|
+
if (min === 24 && max === 23) return 'h24';
|
|
133
|
+
if (min === 0 && max === 11) return 'h11';
|
|
134
|
+
if (min === 12 && max === 11) return 'h12';
|
|
135
|
+
throw new Error('Unexpected hour cycle result');
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
|
|
@@ -18,32 +18,32 @@ class $fb18d541ea1ad717$export$ad991b66133851cf {
|
|
|
18
18
|
}
|
|
19
19
|
/** Formats a date range as a string. */ formatRange(start, end) {
|
|
20
20
|
// @ts-ignore
|
|
21
|
-
if (typeof this.formatter.formatRange ===
|
|
21
|
+
if (typeof this.formatter.formatRange === 'function') // @ts-ignore
|
|
22
22
|
return this.formatter.formatRange(start, end);
|
|
23
|
-
if (end < start) throw new RangeError(
|
|
23
|
+
if (end < start) throw new RangeError('End date must be >= start date');
|
|
24
24
|
// Very basic fallback for old browsers.
|
|
25
25
|
return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`;
|
|
26
26
|
}
|
|
27
27
|
/** Formats a date range as an array of parts. */ formatRangeToParts(start, end) {
|
|
28
28
|
// @ts-ignore
|
|
29
|
-
if (typeof this.formatter.formatRangeToParts ===
|
|
29
|
+
if (typeof this.formatter.formatRangeToParts === 'function') // @ts-ignore
|
|
30
30
|
return this.formatter.formatRangeToParts(start, end);
|
|
31
|
-
if (end < start) throw new RangeError(
|
|
31
|
+
if (end < start) throw new RangeError('End date must be >= start date');
|
|
32
32
|
let startParts = this.formatter.formatToParts(start);
|
|
33
33
|
let endParts = this.formatter.formatToParts(end);
|
|
34
34
|
return [
|
|
35
35
|
...startParts.map((p)=>({
|
|
36
36
|
...p,
|
|
37
|
-
source:
|
|
37
|
+
source: 'startRange'
|
|
38
38
|
})),
|
|
39
39
|
{
|
|
40
|
-
type:
|
|
40
|
+
type: 'literal',
|
|
41
41
|
value: " \u2013 ",
|
|
42
|
-
source:
|
|
42
|
+
source: 'shared'
|
|
43
43
|
},
|
|
44
44
|
...endParts.map((p)=>({
|
|
45
45
|
...p,
|
|
46
|
-
source:
|
|
46
|
+
source: 'endRange'
|
|
47
47
|
}))
|
|
48
48
|
];
|
|
49
49
|
}
|
|
@@ -52,11 +52,11 @@ class $fb18d541ea1ad717$export$ad991b66133851cf {
|
|
|
52
52
|
if ($fb18d541ea1ad717$var$hasBuggyResolvedHourCycle()) {
|
|
53
53
|
if (!this.resolvedHourCycle) this.resolvedHourCycle = $fb18d541ea1ad717$var$getResolvedHourCycle(resolvedOptions.locale, this.options);
|
|
54
54
|
resolvedOptions.hourCycle = this.resolvedHourCycle;
|
|
55
|
-
resolvedOptions.hour12 = this.resolvedHourCycle ===
|
|
55
|
+
resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';
|
|
56
56
|
}
|
|
57
57
|
// Safari uses a different name for the Ethiopic (Amete Alem) calendar.
|
|
58
58
|
// https://bugs.webkit.org/show_bug.cgi?id=241564
|
|
59
|
-
if (resolvedOptions.calendar ===
|
|
59
|
+
if (resolvedOptions.calendar === 'ethiopic-amete-alem') resolvedOptions.calendar = 'ethioaa';
|
|
60
60
|
return resolvedOptions;
|
|
61
61
|
}
|
|
62
62
|
constructor(locale, options = {}){
|
|
@@ -77,7 +77,7 @@ class $fb18d541ea1ad717$export$ad991b66133851cf {
|
|
|
77
77
|
const $fb18d541ea1ad717$var$hour12Preferences = {
|
|
78
78
|
true: {
|
|
79
79
|
// Only Japanese uses the h11 style for 12 hour time. All others use h12.
|
|
80
|
-
ja:
|
|
80
|
+
ja: 'h11'
|
|
81
81
|
},
|
|
82
82
|
false: {
|
|
83
83
|
}
|
|
@@ -85,16 +85,16 @@ const $fb18d541ea1ad717$var$hour12Preferences = {
|
|
|
85
85
|
function $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options = {}) {
|
|
86
86
|
// Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.
|
|
87
87
|
// Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.
|
|
88
|
-
if (typeof options.hour12 ===
|
|
88
|
+
if (typeof options.hour12 === 'boolean' && $fb18d541ea1ad717$var$hasBuggyHour12Behavior()) {
|
|
89
89
|
options = {
|
|
90
90
|
...options
|
|
91
91
|
};
|
|
92
|
-
let pref = $fb18d541ea1ad717$var$hour12Preferences[String(options.hour12)][locale.split(
|
|
93
|
-
let defaultHourCycle = options.hour12 ?
|
|
92
|
+
let pref = $fb18d541ea1ad717$var$hour12Preferences[String(options.hour12)][locale.split('-')[0]];
|
|
93
|
+
let defaultHourCycle = options.hour12 ? 'h12' : 'h23';
|
|
94
94
|
options.hourCycle = pref !== null && pref !== void 0 ? pref : defaultHourCycle;
|
|
95
95
|
delete options.hour12;
|
|
96
96
|
}
|
|
97
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() :
|
|
97
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : '');
|
|
98
98
|
if ($fb18d541ea1ad717$var$formatterCache.has(cacheKey)) return $fb18d541ea1ad717$var$formatterCache.get(cacheKey);
|
|
99
99
|
let numberFormatter = new Intl.DateTimeFormat(locale, options);
|
|
100
100
|
$fb18d541ea1ad717$var$formatterCache.set(cacheKey, numberFormatter);
|
|
@@ -102,37 +102,37 @@ function $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options = {}) {
|
|
|
102
102
|
}
|
|
103
103
|
let $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = null;
|
|
104
104
|
function $fb18d541ea1ad717$var$hasBuggyHour12Behavior() {
|
|
105
|
-
if ($fb18d541ea1ad717$var$_hasBuggyHour12Behavior == null) $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat(
|
|
106
|
-
hour:
|
|
105
|
+
if ($fb18d541ea1ad717$var$_hasBuggyHour12Behavior == null) $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', {
|
|
106
|
+
hour: 'numeric',
|
|
107
107
|
hour12: false
|
|
108
|
-
}).format(new Date(2020, 2, 3, 0)) ===
|
|
108
|
+
}).format(new Date(2020, 2, 3, 0)) === '24';
|
|
109
109
|
return $fb18d541ea1ad717$var$_hasBuggyHour12Behavior;
|
|
110
110
|
}
|
|
111
111
|
let $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = null;
|
|
112
112
|
function $fb18d541ea1ad717$var$hasBuggyResolvedHourCycle() {
|
|
113
|
-
if ($fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle == null) $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat(
|
|
114
|
-
hour:
|
|
113
|
+
if ($fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle == null) $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', {
|
|
114
|
+
hour: 'numeric',
|
|
115
115
|
hour12: false
|
|
116
|
-
}).resolvedOptions().hourCycle ===
|
|
116
|
+
}).resolvedOptions().hourCycle === 'h12';
|
|
117
117
|
return $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle;
|
|
118
118
|
}
|
|
119
119
|
function $fb18d541ea1ad717$var$getResolvedHourCycle(locale, options) {
|
|
120
120
|
if (!options.timeStyle && !options.hour) return undefined;
|
|
121
121
|
// Work around buggy results in resolved hourCycle and hour12 options in WebKit.
|
|
122
122
|
// Format the minimum possible hour and maximum possible hour in a day and parse the results.
|
|
123
|
-
locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/,
|
|
124
|
-
locale += (locale.includes(
|
|
123
|
+
locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');
|
|
124
|
+
locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';
|
|
125
125
|
let formatter = $fb18d541ea1ad717$var$getCachedDateFormatter(locale, {
|
|
126
126
|
...options,
|
|
127
127
|
timeZone: undefined // use local timezone
|
|
128
128
|
});
|
|
129
|
-
let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type ===
|
|
130
|
-
let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type ===
|
|
131
|
-
if (min === 0 && max === 23) return
|
|
132
|
-
if (min === 24 && max === 23) return
|
|
133
|
-
if (min === 0 && max === 11) return
|
|
134
|
-
if (min === 12 && max === 11) return
|
|
135
|
-
throw new Error(
|
|
129
|
+
let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type === 'hour').value, 10);
|
|
130
|
+
let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type === 'hour').value, 10);
|
|
131
|
+
if (min === 0 && max === 23) return 'h23';
|
|
132
|
+
if (min === 24 && max === 23) return 'h24';
|
|
133
|
+
if (min === 0 && max === 11) return 'h11';
|
|
134
|
+
if (min === 12 && max === 11) return 'h12';
|
|
135
|
+
throw new Error('Unexpected hour cycle result');
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
|