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