@formatjs/intl-datetimeformat 7.1.0 → 7.1.2
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/add-all-tz.js +319 -318
- package/add-golden-tz.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +5 -5
- package/polyfill-force.js +28 -44
- package/polyfill.iife.js +2803 -3046
- package/polyfill.js +29 -45
- package/should-polyfill.js +38 -50
- package/src/abstract/BasicFormatMatcher.d.ts +5 -5
- package/src/abstract/BasicFormatMatcher.js +87 -103
- package/src/abstract/BestFitFormatMatcher.d.ts +12 -12
- package/src/abstract/BestFitFormatMatcher.js +102 -108
- package/src/abstract/DateTimeStyleFormat.d.ts +2 -2
- package/src/abstract/DateTimeStyleFormat.js +47 -62
- package/src/abstract/FormatDateTime.d.ts +7 -7
- package/src/abstract/FormatDateTime.js +12 -12
- package/src/abstract/FormatDateTimePattern.d.ts +11 -11
- package/src/abstract/FormatDateTimePattern.js +185 -198
- package/src/abstract/FormatDateTimeRange.d.ts +3 -3
- package/src/abstract/FormatDateTimeRange.js +9 -8
- package/src/abstract/FormatDateTimeRangeToParts.d.ts +4 -4
- package/src/abstract/FormatDateTimeRangeToParts.js +14 -12
- package/src/abstract/FormatDateTimeToParts.d.ts +9 -9
- package/src/abstract/FormatDateTimeToParts.js +17 -18
- package/src/abstract/InitializeDateTimeFormat.d.ts +15 -15
- package/src/abstract/InitializeDateTimeFormat.js +206 -184
- package/src/abstract/PartitionDateTimePattern.d.ts +8 -8
- package/src/abstract/PartitionDateTimePattern.js +15 -14
- package/src/abstract/PartitionDateTimeRangePattern.d.ts +4 -4
- package/src/abstract/PartitionDateTimeRangePattern.js +168 -161
- package/src/abstract/ToDateTimeOptions.d.ts +5 -5
- package/src/abstract/ToDateTimeOptions.js +68 -60
- package/src/abstract/ToLocalTime.d.ts +21 -21
- package/src/abstract/ToLocalTime.js +116 -45
- package/src/abstract/skeleton.d.ts +8 -8
- package/src/abstract/skeleton.js +231 -280
- package/src/abstract/utils.d.ts +1 -1
- package/src/abstract/utils.js +21 -20
- package/src/core.d.ts +17 -17
- package/src/core.js +250 -286
- package/src/data/all-tz.generated.d.ts +8 -0
- package/src/data/all-tz.generated.js +462 -0
- package/src/data/links.generated.d.ts +261 -0
- package/src/data/links.generated.js +260 -0
- package/src/get_internal_slots.d.ts +3 -1
- package/src/get_internal_slots.js +8 -7
- package/src/packer.d.ts +2 -2
- package/src/packer.js +23 -35
- package/src/to_locale_string.d.ts +3 -3
- package/src/to_locale_string.js +11 -11
- package/src/types.d.ts +34 -39
- package/src/types.js +1 -1
- package/supported-locales.generated.js +573 -1
- package/test262-main.d.ts +4 -1
- package/test262-main.js +24600 -44193
- package/src/data/all-tz.d.ts +0 -6
- package/src/data/all-tz.js +0 -461
- package/src/data/links.d.ts +0 -259
- package/src/data/links.js +0 -260
package/src/core.js
CHANGED
|
@@ -1,302 +1,266 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { CanonicalizeLocaleList, CanonicalizeTimeZoneName, IsValidTimeZoneName, OrdinaryHasInstance, SupportedLocales, ToNumber, defineProperty, invariant } from "@formatjs/ecma402-abstract";
|
|
2
|
+
import Decimal from "decimal.js";
|
|
3
|
+
import { FormatDateTime } from "./abstract/FormatDateTime.js";
|
|
4
|
+
import { FormatDateTimeRange } from "./abstract/FormatDateTimeRange.js";
|
|
5
|
+
import { FormatDateTimeRangeToParts } from "./abstract/FormatDateTimeRangeToParts.js";
|
|
6
|
+
import { FormatDateTimeToParts } from "./abstract/FormatDateTimeToParts.js";
|
|
7
|
+
import { InitializeDateTimeFormat } from "./abstract/InitializeDateTimeFormat.js";
|
|
8
|
+
import { parseDateTimeSkeleton } from "./abstract/skeleton.js";
|
|
9
|
+
import { DATE_TIME_PROPS } from "./abstract/utils.js";
|
|
10
|
+
import links from "./data/links.generated.js";
|
|
11
|
+
import getInternalSlots from "./get_internal_slots.js";
|
|
12
|
+
import { unpack } from "./packer.js";
|
|
13
|
+
import "./types.js";
|
|
14
|
+
const UPPERCASED_LINKS = Object.keys(links).reduce((all, l) => {
|
|
15
|
+
all[l.toUpperCase()] = links[l];
|
|
16
|
+
return all;
|
|
17
17
|
}, {});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
const RESOLVED_OPTIONS_KEYS = [
|
|
19
|
+
"locale",
|
|
20
|
+
"calendar",
|
|
21
|
+
"numberingSystem",
|
|
22
|
+
"dateStyle",
|
|
23
|
+
"timeStyle",
|
|
24
|
+
"timeZone",
|
|
25
|
+
"hourCycle",
|
|
26
|
+
"weekday",
|
|
27
|
+
"era",
|
|
28
|
+
"year",
|
|
29
|
+
"month",
|
|
30
|
+
"day",
|
|
31
|
+
"hour",
|
|
32
|
+
"minute",
|
|
33
|
+
"second",
|
|
34
|
+
"timeZoneName"
|
|
35
35
|
];
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// TypeError: Cannot redefine property: name
|
|
77
|
-
}
|
|
78
|
-
internalSlots.boundFormat = boundFormat;
|
|
79
|
-
}
|
|
80
|
-
return boundFormat;
|
|
81
|
-
},
|
|
36
|
+
const formatDescriptor = {
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true,
|
|
39
|
+
get() {
|
|
40
|
+
if (typeof this !== "object" || !OrdinaryHasInstance(DateTimeFormat, this)) {
|
|
41
|
+
throw TypeError("Intl.DateTimeFormat format property accessor called on incompatible receiver");
|
|
42
|
+
}
|
|
43
|
+
const internalSlots = getInternalSlots(this);
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
45
|
+
const dtf = this;
|
|
46
|
+
let boundFormat = internalSlots.boundFormat;
|
|
47
|
+
if (boundFormat === undefined) {
|
|
48
|
+
// https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-number-format-functions
|
|
49
|
+
boundFormat = (date) => {
|
|
50
|
+
let x;
|
|
51
|
+
if (date === undefined) {
|
|
52
|
+
x = new Decimal(Date.now());
|
|
53
|
+
} else {
|
|
54
|
+
x = ToNumber(date);
|
|
55
|
+
}
|
|
56
|
+
return FormatDateTime(dtf, x, {
|
|
57
|
+
getInternalSlots,
|
|
58
|
+
localeData: DateTimeFormat.localeData,
|
|
59
|
+
tzData: DateTimeFormat.tzData,
|
|
60
|
+
getDefaultTimeZone: DateTimeFormat.getDefaultTimeZone
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
try {
|
|
64
|
+
// https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/prototype/format/format-function-name.js
|
|
65
|
+
Object.defineProperty(boundFormat, "name", {
|
|
66
|
+
configurable: true,
|
|
67
|
+
enumerable: false,
|
|
68
|
+
writable: false,
|
|
69
|
+
value: ""
|
|
70
|
+
});
|
|
71
|
+
} catch {}
|
|
72
|
+
internalSlots.boundFormat = boundFormat;
|
|
73
|
+
}
|
|
74
|
+
return boundFormat;
|
|
75
|
+
}
|
|
82
76
|
};
|
|
83
77
|
try {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var dataLocale = internalSlots.dataLocale;
|
|
114
|
-
var dataLocaleData = DateTimeFormat.localeData[dataLocale];
|
|
115
|
-
invariant(dataLocaleData !== undefined, "Cannot load locale-dependent data for ".concat(dataLocale, "."));
|
|
116
|
-
/** IMPL END */
|
|
78
|
+
// https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/prototype/format/name.js
|
|
79
|
+
Object.defineProperty(formatDescriptor.get, "name", {
|
|
80
|
+
configurable: true,
|
|
81
|
+
enumerable: false,
|
|
82
|
+
writable: false,
|
|
83
|
+
value: "get format"
|
|
84
|
+
});
|
|
85
|
+
} catch {}
|
|
86
|
+
export const DateTimeFormat = function(locales, options) {
|
|
87
|
+
// Cannot use `new.target` bc of IE11 & TS transpiles it to something else
|
|
88
|
+
if (!this || !OrdinaryHasInstance(DateTimeFormat, this)) {
|
|
89
|
+
return new DateTimeFormat(locales, options);
|
|
90
|
+
}
|
|
91
|
+
InitializeDateTimeFormat(this, locales, options, {
|
|
92
|
+
tzData: DateTimeFormat.tzData,
|
|
93
|
+
uppercaseLinks: UPPERCASED_LINKS,
|
|
94
|
+
availableLocales: DateTimeFormat.availableLocales,
|
|
95
|
+
relevantExtensionKeys: DateTimeFormat.relevantExtensionKeys,
|
|
96
|
+
getDefaultLocale: DateTimeFormat.getDefaultLocale,
|
|
97
|
+
getDefaultTimeZone: DateTimeFormat.getDefaultTimeZone,
|
|
98
|
+
getInternalSlots,
|
|
99
|
+
localeData: DateTimeFormat.localeData
|
|
100
|
+
});
|
|
101
|
+
/** IMPL START */
|
|
102
|
+
const internalSlots = getInternalSlots(this);
|
|
103
|
+
const dataLocale = internalSlots.dataLocale;
|
|
104
|
+
const dataLocaleData = DateTimeFormat.localeData[dataLocale];
|
|
105
|
+
invariant(dataLocaleData !== undefined, `Cannot load locale-dependent data for ${dataLocale}.`);
|
|
106
|
+
/** IMPL END */
|
|
117
107
|
};
|
|
118
108
|
// Static properties
|
|
119
|
-
defineProperty(DateTimeFormat,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var DEFAULT_TIMEZONE = 'UTC';
|
|
204
|
-
DateTimeFormat.__setDefaultTimeZone = function (timeZone) {
|
|
205
|
-
if (timeZone !== undefined) {
|
|
206
|
-
timeZone = String(timeZone);
|
|
207
|
-
if (!IsValidTimeZoneName(timeZone, {
|
|
208
|
-
zoneNamesFromData: Object.keys(DateTimeFormat.tzData),
|
|
209
|
-
uppercaseLinks: UPPERCASED_LINKS,
|
|
210
|
-
})) {
|
|
211
|
-
throw new RangeError('Invalid timeZoneName');
|
|
212
|
-
}
|
|
213
|
-
timeZone = CanonicalizeTimeZoneName(timeZone, {
|
|
214
|
-
zoneNames: Object.keys(DateTimeFormat.tzData),
|
|
215
|
-
uppercaseLinks: UPPERCASED_LINKS,
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
timeZone = DEFAULT_TIMEZONE;
|
|
220
|
-
}
|
|
221
|
-
DateTimeFormat.__defaultTimeZone = timeZone;
|
|
109
|
+
defineProperty(DateTimeFormat, "supportedLocalesOf", { value: function supportedLocalesOf(locales, options) {
|
|
110
|
+
return SupportedLocales(DateTimeFormat.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
111
|
+
} });
|
|
112
|
+
defineProperty(DateTimeFormat.prototype, "resolvedOptions", { value: function resolvedOptions() {
|
|
113
|
+
if (typeof this !== "object" || !OrdinaryHasInstance(DateTimeFormat, this)) {
|
|
114
|
+
throw TypeError("Method Intl.DateTimeFormat.prototype.resolvedOptions called on incompatible receiver");
|
|
115
|
+
}
|
|
116
|
+
const internalSlots = getInternalSlots(this);
|
|
117
|
+
const ro = {};
|
|
118
|
+
for (const key of RESOLVED_OPTIONS_KEYS) {
|
|
119
|
+
let value = internalSlots[key];
|
|
120
|
+
if (key === "hourCycle") {
|
|
121
|
+
const hour12 = value === "h11" || value === "h12" ? true : value === "h23" || value === "h24" ? false : undefined;
|
|
122
|
+
if (hour12 !== undefined) {
|
|
123
|
+
ro.hour12 = hour12;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (DATE_TIME_PROPS.indexOf(key) > -1) {
|
|
127
|
+
if (internalSlots.dateStyle !== undefined || internalSlots.timeStyle !== undefined) {
|
|
128
|
+
value = undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (value !== undefined) {
|
|
132
|
+
ro[key] = value;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return ro;
|
|
136
|
+
} });
|
|
137
|
+
defineProperty(DateTimeFormat.prototype, "formatToParts", { value: function formatToParts(date) {
|
|
138
|
+
let x;
|
|
139
|
+
if (date === undefined) {
|
|
140
|
+
x = new Decimal(Date.now());
|
|
141
|
+
} else {
|
|
142
|
+
x = ToNumber(date);
|
|
143
|
+
}
|
|
144
|
+
return FormatDateTimeToParts(this, x, {
|
|
145
|
+
getInternalSlots,
|
|
146
|
+
localeData: DateTimeFormat.localeData,
|
|
147
|
+
tzData: DateTimeFormat.tzData,
|
|
148
|
+
getDefaultTimeZone: DateTimeFormat.getDefaultTimeZone
|
|
149
|
+
});
|
|
150
|
+
} });
|
|
151
|
+
defineProperty(DateTimeFormat.prototype, "formatRangeToParts", { value: function formatRangeToParts(startDate, endDate) {
|
|
152
|
+
// oxlint-disable-next-line no-this-alias
|
|
153
|
+
const dtf = this;
|
|
154
|
+
invariant(typeof dtf === "object", "receiver is not an object", TypeError);
|
|
155
|
+
invariant(startDate !== undefined && endDate !== undefined, "startDate/endDate cannot be undefined", TypeError);
|
|
156
|
+
return FormatDateTimeRangeToParts(dtf, ToNumber(startDate), ToNumber(endDate), {
|
|
157
|
+
getInternalSlots,
|
|
158
|
+
localeData: DateTimeFormat.localeData,
|
|
159
|
+
tzData: DateTimeFormat.tzData,
|
|
160
|
+
getDefaultTimeZone: DateTimeFormat.getDefaultTimeZone
|
|
161
|
+
});
|
|
162
|
+
} });
|
|
163
|
+
defineProperty(DateTimeFormat.prototype, "formatRange", { value: function formatRange(startDate, endDate) {
|
|
164
|
+
// oxlint-disable-next-line no-this-alias
|
|
165
|
+
const dtf = this;
|
|
166
|
+
invariant(typeof dtf === "object", "receiver is not an object", TypeError);
|
|
167
|
+
invariant(startDate !== undefined && endDate !== undefined, "startDate/endDate cannot be undefined", TypeError);
|
|
168
|
+
return FormatDateTimeRange(dtf, ToNumber(startDate), ToNumber(endDate), {
|
|
169
|
+
getInternalSlots,
|
|
170
|
+
localeData: DateTimeFormat.localeData,
|
|
171
|
+
tzData: DateTimeFormat.tzData,
|
|
172
|
+
getDefaultTimeZone: DateTimeFormat.getDefaultTimeZone
|
|
173
|
+
});
|
|
174
|
+
} });
|
|
175
|
+
const DEFAULT_TIMEZONE = "UTC";
|
|
176
|
+
DateTimeFormat.__setDefaultTimeZone = (timeZone) => {
|
|
177
|
+
if (timeZone !== undefined) {
|
|
178
|
+
timeZone = String(timeZone);
|
|
179
|
+
if (!IsValidTimeZoneName(timeZone, {
|
|
180
|
+
zoneNamesFromData: Object.keys(DateTimeFormat.tzData),
|
|
181
|
+
uppercaseLinks: UPPERCASED_LINKS
|
|
182
|
+
})) {
|
|
183
|
+
throw new RangeError("Invalid timeZoneName");
|
|
184
|
+
}
|
|
185
|
+
timeZone = CanonicalizeTimeZoneName(timeZone, {
|
|
186
|
+
zoneNames: Object.keys(DateTimeFormat.tzData),
|
|
187
|
+
uppercaseLinks: UPPERCASED_LINKS
|
|
188
|
+
});
|
|
189
|
+
} else {
|
|
190
|
+
timeZone = DEFAULT_TIMEZONE;
|
|
191
|
+
}
|
|
192
|
+
DateTimeFormat.__defaultTimeZone = timeZone;
|
|
222
193
|
};
|
|
223
|
-
DateTimeFormat.relevantExtensionKeys = [
|
|
194
|
+
DateTimeFormat.relevantExtensionKeys = [
|
|
195
|
+
"nu",
|
|
196
|
+
"ca",
|
|
197
|
+
"hc"
|
|
198
|
+
];
|
|
224
199
|
DateTimeFormat.__defaultTimeZone = DEFAULT_TIMEZONE;
|
|
225
|
-
DateTimeFormat.getDefaultTimeZone =
|
|
226
|
-
DateTimeFormat.__addLocaleData = function __addLocaleData() {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (!DateTimeFormat.__defaultLocale) {
|
|
264
|
-
DateTimeFormat.__defaultLocale = minimizedLocale;
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
|
|
268
|
-
var _b = data_1[_a], d = _b.data, locale = _b.locale;
|
|
269
|
-
_loop_1(d, locale);
|
|
270
|
-
}
|
|
200
|
+
DateTimeFormat.getDefaultTimeZone = () => DateTimeFormat.__defaultTimeZone;
|
|
201
|
+
DateTimeFormat.__addLocaleData = function __addLocaleData(...data) {
|
|
202
|
+
for (const { data: d, locale } of data) {
|
|
203
|
+
const { dateFormat, timeFormat, dateTimeFormat, formats, intervalFormats, ...rawData } = d;
|
|
204
|
+
const processedData = {
|
|
205
|
+
...rawData,
|
|
206
|
+
dateFormat: {
|
|
207
|
+
full: parseDateTimeSkeleton(dateFormat.full),
|
|
208
|
+
long: parseDateTimeSkeleton(dateFormat.long),
|
|
209
|
+
medium: parseDateTimeSkeleton(dateFormat.medium),
|
|
210
|
+
short: parseDateTimeSkeleton(dateFormat.short)
|
|
211
|
+
},
|
|
212
|
+
timeFormat: {
|
|
213
|
+
full: parseDateTimeSkeleton(timeFormat.full),
|
|
214
|
+
long: parseDateTimeSkeleton(timeFormat.long),
|
|
215
|
+
medium: parseDateTimeSkeleton(timeFormat.medium),
|
|
216
|
+
short: parseDateTimeSkeleton(timeFormat.short)
|
|
217
|
+
},
|
|
218
|
+
dateTimeFormat: {
|
|
219
|
+
full: parseDateTimeSkeleton(dateTimeFormat.full).pattern,
|
|
220
|
+
long: parseDateTimeSkeleton(dateTimeFormat.long).pattern,
|
|
221
|
+
medium: parseDateTimeSkeleton(dateTimeFormat.medium).pattern,
|
|
222
|
+
short: parseDateTimeSkeleton(dateTimeFormat.short).pattern
|
|
223
|
+
},
|
|
224
|
+
intervalFormatFallback: intervalFormats.intervalFormatFallback,
|
|
225
|
+
formats: {}
|
|
226
|
+
};
|
|
227
|
+
for (const calendar in formats) {
|
|
228
|
+
processedData.formats[calendar] = Object.keys(formats[calendar]).map((skeleton) => parseDateTimeSkeleton(skeleton, formats[calendar][skeleton], intervalFormats[skeleton], intervalFormats.intervalFormatFallback));
|
|
229
|
+
}
|
|
230
|
+
const minimizedLocale = new Intl.Locale(locale).minimize().toString();
|
|
231
|
+
DateTimeFormat.localeData[locale] = DateTimeFormat.localeData[minimizedLocale] = processedData;
|
|
232
|
+
DateTimeFormat.availableLocales.add(locale);
|
|
233
|
+
DateTimeFormat.availableLocales.add(minimizedLocale);
|
|
234
|
+
if (!DateTimeFormat.__defaultLocale) {
|
|
235
|
+
DateTimeFormat.__defaultLocale = minimizedLocale;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
271
238
|
};
|
|
272
|
-
Object.defineProperty(DateTimeFormat.prototype,
|
|
273
|
-
DateTimeFormat.__defaultLocale =
|
|
239
|
+
Object.defineProperty(DateTimeFormat.prototype, "format", formatDescriptor);
|
|
240
|
+
DateTimeFormat.__defaultLocale = "";
|
|
274
241
|
DateTimeFormat.localeData = {};
|
|
275
242
|
DateTimeFormat.availableLocales = new Set();
|
|
276
|
-
DateTimeFormat.getDefaultLocale =
|
|
277
|
-
|
|
243
|
+
DateTimeFormat.getDefaultLocale = () => {
|
|
244
|
+
return DateTimeFormat.__defaultLocale;
|
|
278
245
|
};
|
|
279
246
|
DateTimeFormat.polyfilled = true;
|
|
280
247
|
DateTimeFormat.tzData = {};
|
|
281
|
-
DateTimeFormat.__addTZData = function
|
|
282
|
-
|
|
248
|
+
DateTimeFormat.__addTZData = function(d) {
|
|
249
|
+
DateTimeFormat.tzData = unpack(d);
|
|
283
250
|
};
|
|
284
251
|
try {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
catch (_b) {
|
|
301
|
-
// Meta fix so we're test262-compliant, not important
|
|
302
|
-
}
|
|
252
|
+
if (typeof Symbol !== "undefined") {
|
|
253
|
+
Object.defineProperty(DateTimeFormat.prototype, Symbol.toStringTag, {
|
|
254
|
+
value: "Intl.DateTimeFormat",
|
|
255
|
+
writable: false,
|
|
256
|
+
enumerable: false,
|
|
257
|
+
configurable: true
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
Object.defineProperty(DateTimeFormat.prototype.constructor, "length", {
|
|
261
|
+
value: 1,
|
|
262
|
+
writable: false,
|
|
263
|
+
enumerable: false,
|
|
264
|
+
configurable: true
|
|
265
|
+
});
|
|
266
|
+
} catch {}
|