@formatjs/intl-datetimeformat 6.18.2 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +1 -4
  3. package/package.json +14 -6
  4. package/polyfill-force.js +13 -15
  5. package/polyfill.iife.js +44 -44
  6. package/polyfill.js +15 -17
  7. package/should-polyfill.js +7 -10
  8. package/src/abstract/BasicFormatMatcher.js +26 -29
  9. package/src/abstract/BestFitFormatMatcher.js +19 -23
  10. package/src/abstract/DateTimeStyleFormat.js +5 -8
  11. package/src/abstract/FormatDateTime.d.ts +1 -1
  12. package/src/abstract/FormatDateTime.js +3 -6
  13. package/src/abstract/FormatDateTimePattern.d.ts +1 -1
  14. package/src/abstract/FormatDateTimePattern.js +12 -16
  15. package/src/abstract/FormatDateTimeRange.d.ts +2 -2
  16. package/src/abstract/FormatDateTimeRange.js +3 -6
  17. package/src/abstract/FormatDateTimeRangeToParts.d.ts +2 -2
  18. package/src/abstract/FormatDateTimeRangeToParts.js +4 -7
  19. package/src/abstract/FormatDateTimeToParts.d.ts +1 -1
  20. package/src/abstract/FormatDateTimeToParts.js +5 -8
  21. package/src/abstract/InitializeDateTimeFormat.js +37 -40
  22. package/src/abstract/PartitionDateTimePattern.d.ts +2 -2
  23. package/src/abstract/PartitionDateTimePattern.js +6 -9
  24. package/src/abstract/PartitionDateTimeRangePattern.d.ts +2 -2
  25. package/src/abstract/PartitionDateTimeRangePattern.js +16 -19
  26. package/src/abstract/ToDateTimeOptions.js +3 -6
  27. package/src/abstract/ToLocalTime.js +11 -14
  28. package/src/abstract/skeleton.js +14 -20
  29. package/src/abstract/utils.js +9 -12
  30. package/src/core.d.ts +1 -1
  31. package/src/core.js +115 -116
  32. package/src/data/all-tz.js +1 -3
  33. package/src/data/links.js +1 -3
  34. package/src/get_internal_slots.js +1 -4
  35. package/src/packer.d.ts +1 -1
  36. package/src/packer.js +5 -9
  37. package/src/to_locale_string.js +8 -13
  38. package/src/types.d.ts +1 -1
  39. package/src/types.js +1 -2
  40. package/supported-locales.generated.js +1 -4
  41. package/test262-main.d.ts +1 -1
  42. package/test262-main.js +3 -6
  43. package/lib/index.d.ts +0 -1
  44. package/lib/index.js +0 -1
  45. package/lib/polyfill-force.d.ts +0 -1
  46. package/lib/polyfill-force.js +0 -44
  47. package/lib/polyfill.d.ts +0 -1
  48. package/lib/polyfill.js +0 -47
  49. package/lib/should-polyfill.d.ts +0 -1
  50. package/lib/should-polyfill.js +0 -61
  51. package/lib/src/abstract/BasicFormatMatcher.d.ts +0 -7
  52. package/lib/src/abstract/BasicFormatMatcher.js +0 -106
  53. package/lib/src/abstract/BestFitFormatMatcher.d.ts +0 -16
  54. package/lib/src/abstract/BestFitFormatMatcher.js +0 -116
  55. package/lib/src/abstract/DateTimeStyleFormat.d.ts +0 -2
  56. package/lib/src/abstract/DateTimeStyleFormat.js +0 -50
  57. package/lib/src/abstract/FormatDateTime.d.ts +0 -9
  58. package/lib/src/abstract/FormatDateTime.js +0 -15
  59. package/lib/src/abstract/FormatDateTimePattern.d.ts +0 -14
  60. package/lib/src/abstract/FormatDateTimePattern.js +0 -191
  61. package/lib/src/abstract/FormatDateTimeRange.d.ts +0 -4
  62. package/lib/src/abstract/FormatDateTimeRange.js +0 -10
  63. package/lib/src/abstract/FormatDateTimeRangeToParts.d.ts +0 -5
  64. package/lib/src/abstract/FormatDateTimeRangeToParts.js +0 -14
  65. package/lib/src/abstract/FormatDateTimeToParts.d.ts +0 -11
  66. package/lib/src/abstract/FormatDateTimeToParts.js +0 -21
  67. package/lib/src/abstract/InitializeDateTimeFormat.d.ts +0 -17
  68. package/lib/src/abstract/InitializeDateTimeFormat.js +0 -190
  69. package/lib/src/abstract/PartitionDateTimePattern.d.ts +0 -10
  70. package/lib/src/abstract/PartitionDateTimePattern.js +0 -17
  71. package/lib/src/abstract/PartitionDateTimeRangePattern.d.ts +0 -5
  72. package/lib/src/abstract/PartitionDateTimeRangePattern.js +0 -119
  73. package/lib/src/abstract/ToDateTimeOptions.d.ts +0 -7
  74. package/lib/src/abstract/ToDateTimeOptions.js +0 -63
  75. package/lib/src/abstract/ToLocalTime.d.ts +0 -26
  76. package/lib/src/abstract/ToLocalTime.js +0 -49
  77. package/lib/src/abstract/skeleton.d.ts +0 -13
  78. package/lib/src/abstract/skeleton.js +0 -294
  79. package/lib/src/abstract/utils.d.ts +0 -10
  80. package/lib/src/abstract/utils.js +0 -21
  81. package/lib/src/core.d.ts +0 -20
  82. package/lib/src/core.js +0 -300
  83. package/lib/src/data/all-tz.d.ts +0 -6
  84. package/lib/src/data/all-tz.js +0 -461
  85. package/lib/src/data/links.d.ts +0 -259
  86. package/lib/src/data/links.js +0 -260
  87. package/lib/src/get_internal_slots.d.ts +0 -2
  88. package/lib/src/get_internal_slots.js +0 -11
  89. package/lib/src/packer.d.ts +0 -4
  90. package/lib/src/packer.js +0 -39
  91. package/lib/src/to_locale_string.d.ts +0 -7
  92. package/lib/src/to_locale_string.js +0 -19
  93. package/lib/src/types.d.ts +0 -47
  94. package/lib/src/types.js +0 -1
  95. package/lib/supported-locales.generated.d.ts +0 -1
  96. package/lib/supported-locales.generated.js +0 -1
  97. package/lib/test262-main.d.ts +0 -1
  98. package/lib/test262-main.js +0 -23786
@@ -1,294 +0,0 @@
1
- import { __assign } from "tslib";
2
- import { RangePatternType, } from '@formatjs/ecma402-abstract';
3
- /**
4
- * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
5
- * Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js
6
- * with some tweaks
7
- */
8
- var DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
9
- // trim patterns after transformations
10
- var expPatternTrimmer = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
11
- function matchSkeletonPattern(match, result) {
12
- var len = match.length;
13
- switch (match[0]) {
14
- // Era
15
- case 'G':
16
- result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
17
- return '{era}';
18
- // Year
19
- case 'y':
20
- case 'Y':
21
- case 'u':
22
- case 'U':
23
- case 'r':
24
- result.year = len === 2 ? '2-digit' : 'numeric';
25
- return '{year}';
26
- // Quarter
27
- case 'q':
28
- case 'Q':
29
- throw new RangeError('`w/Q` (quarter) patterns are not supported');
30
- // Month
31
- case 'M':
32
- case 'L':
33
- result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1];
34
- return '{month}';
35
- // Week
36
- case 'w':
37
- case 'W':
38
- throw new RangeError('`w/W` (week of year) patterns are not supported');
39
- case 'd':
40
- result.day = ['numeric', '2-digit'][len - 1];
41
- return '{day}';
42
- case 'D':
43
- case 'F':
44
- case 'g':
45
- result.day = 'numeric';
46
- return '{day}';
47
- // Weekday
48
- case 'E':
49
- result.weekday = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
50
- return '{weekday}';
51
- case 'e':
52
- result.weekday = [
53
- undefined,
54
- undefined,
55
- 'short',
56
- 'long',
57
- 'narrow',
58
- 'short',
59
- ][len - 1];
60
- return '{weekday}';
61
- case 'c':
62
- result.weekday = [
63
- undefined,
64
- undefined,
65
- 'short',
66
- 'long',
67
- 'narrow',
68
- 'short',
69
- ][len - 1];
70
- return '{weekday}';
71
- // Period
72
- case 'a': // AM, PM
73
- case 'b': // am, pm, noon, midnight
74
- case 'B': // flexible day periods
75
- result.hour12 = true;
76
- return '{ampm}';
77
- // Hour
78
- case 'h':
79
- result.hour = ['numeric', '2-digit'][len - 1];
80
- result.hour12 = true;
81
- return '{hour}';
82
- case 'H':
83
- result.hour = ['numeric', '2-digit'][len - 1];
84
- return '{hour}';
85
- case 'K':
86
- result.hour = ['numeric', '2-digit'][len - 1];
87
- result.hour12 = true;
88
- return '{hour}';
89
- case 'k':
90
- result.hour = ['numeric', '2-digit'][len - 1];
91
- return '{hour}';
92
- case 'j':
93
- case 'J':
94
- case 'C':
95
- throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead');
96
- // Minute
97
- case 'm':
98
- result.minute = ['numeric', '2-digit'][len - 1];
99
- return '{minute}';
100
- // Second
101
- case 's':
102
- result.second = ['numeric', '2-digit'][len - 1];
103
- return '{second}';
104
- case 'S':
105
- case 'A':
106
- result.second = 'numeric';
107
- return '{second}';
108
- // Zone
109
- case 'z': // 1..3, 4: specific non-location format
110
- case 'Z': // 1..3, 4, 5: The ISO8601 varios formats
111
- case 'O': // 1, 4: milliseconds in day short, long
112
- case 'v': // 1, 4: generic non-location format
113
- case 'V': // 1, 2, 3, 4: time zone ID or city
114
- case 'X': // 1, 2, 3, 4: The ISO8601 varios formats
115
- case 'x': // 1, 2, 3, 4: The ISO8601 varios formats
116
- result.timeZoneName = len < 4 ? 'short' : 'long';
117
- return '{timeZoneName}';
118
- }
119
- return '';
120
- }
121
- function skeletonTokenToTable2(c) {
122
- switch (c) {
123
- // Era
124
- case 'G':
125
- return 'era';
126
- // Year
127
- case 'y':
128
- case 'Y':
129
- case 'u':
130
- case 'U':
131
- case 'r':
132
- return 'year';
133
- // Month
134
- case 'M':
135
- case 'L':
136
- return 'month';
137
- // Day
138
- case 'd':
139
- case 'D':
140
- case 'F':
141
- case 'g':
142
- return 'day';
143
- // Period
144
- case 'a': // AM, PM
145
- case 'b': // am, pm, noon, midnight
146
- case 'B': // flexible day periods
147
- return 'ampm';
148
- // Hour
149
- case 'h':
150
- case 'H':
151
- case 'K':
152
- case 'k':
153
- return 'hour';
154
- // Minute
155
- case 'm':
156
- return 'minute';
157
- // Second
158
- case 's':
159
- case 'S':
160
- case 'A':
161
- return 'second';
162
- default:
163
- throw new RangeError('Invalid range pattern token');
164
- }
165
- }
166
- export function processDateTimePattern(pattern, result) {
167
- var literals = [];
168
- // Use skeleton to populate result, but use mapped pattern to populate pattern
169
- var pattern12 = pattern
170
- // Double apostrophe
171
- .replace(/'{2}/g, '{apostrophe}')
172
- // Apostrophe-escaped
173
- .replace(/'(.*?)'/g, function (_, literal) {
174
- literals.push(literal);
175
- return "$$".concat(literals.length - 1, "$$");
176
- })
177
- .replace(DATE_TIME_REGEX, function (m) { return matchSkeletonPattern(m, result || {}); });
178
- //Restore literals
179
- if (literals.length) {
180
- pattern12 = pattern12
181
- .replace(/\$\$(\d+)\$\$/g, function (_, i) {
182
- return literals[+i];
183
- })
184
- .replace(/\{apostrophe\}/g, "'");
185
- }
186
- // Handle apostrophe-escaped things
187
- return [
188
- pattern12
189
- .replace(/([\s\uFEFF\xA0])\{ampm\}([\s\uFEFF\xA0])/, '$1')
190
- .replace('{ampm}', '')
191
- .replace(expPatternTrimmer, ''),
192
- pattern12,
193
- ];
194
- }
195
- /**
196
- * Parse Date time skeleton into Intl.DateTimeFormatOptions
197
- * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
198
- * @public
199
- * @param skeleton skeleton string
200
- */
201
- export function parseDateTimeSkeleton(skeleton, rawPattern, rangePatterns, intervalFormatFallback) {
202
- if (rawPattern === void 0) { rawPattern = skeleton; }
203
- var result = {
204
- pattern: '',
205
- pattern12: '',
206
- skeleton: skeleton,
207
- rawPattern: rawPattern,
208
- rangePatterns: {},
209
- rangePatterns12: {},
210
- };
211
- if (rangePatterns) {
212
- for (var k in rangePatterns) {
213
- var key = skeletonTokenToTable2(k);
214
- var rawPattern_1 = rangePatterns[k];
215
- var intervalResult = {
216
- patternParts: [],
217
- };
218
- var _a = processDateTimePattern(rawPattern_1, intervalResult), pattern_1 = _a[0], pattern12_1 = _a[1];
219
- result.rangePatterns[key] = __assign(__assign({}, intervalResult), { patternParts: splitRangePattern(pattern_1) });
220
- result.rangePatterns12[key] = __assign(__assign({}, intervalResult), { patternParts: splitRangePattern(pattern12_1) });
221
- }
222
- }
223
- if (intervalFormatFallback) {
224
- var patternParts = splitFallbackRangePattern(intervalFormatFallback);
225
- result.rangePatterns.default = {
226
- patternParts: patternParts,
227
- };
228
- result.rangePatterns12.default = {
229
- patternParts: patternParts,
230
- };
231
- }
232
- // Process skeleton
233
- skeleton.replace(DATE_TIME_REGEX, function (m) { return matchSkeletonPattern(m, result); });
234
- var _b = processDateTimePattern(rawPattern), pattern = _b[0], pattern12 = _b[1];
235
- result.pattern = pattern;
236
- result.pattern12 = pattern12;
237
- return result;
238
- }
239
- export function splitFallbackRangePattern(pattern) {
240
- var parts = pattern.split(/(\{[0|1]\})/g).filter(Boolean);
241
- return parts.map(function (pattern) {
242
- switch (pattern) {
243
- case '{0}':
244
- return {
245
- source: RangePatternType.startRange,
246
- pattern: pattern,
247
- };
248
- case '{1}':
249
- return {
250
- source: RangePatternType.endRange,
251
- pattern: pattern,
252
- };
253
- default:
254
- return {
255
- source: RangePatternType.shared,
256
- pattern: pattern,
257
- };
258
- }
259
- });
260
- }
261
- export function splitRangePattern(pattern) {
262
- var PART_REGEX = /\{(.*?)\}/g;
263
- // Map of part and index within the string
264
- var parts = {};
265
- var match;
266
- var splitIndex = 0;
267
- while ((match = PART_REGEX.exec(pattern))) {
268
- if (!(match[0] in parts)) {
269
- parts[match[0]] = match.index;
270
- }
271
- else {
272
- splitIndex = match.index;
273
- break;
274
- }
275
- }
276
- if (!splitIndex) {
277
- return [
278
- {
279
- source: RangePatternType.startRange,
280
- pattern: pattern,
281
- },
282
- ];
283
- }
284
- return [
285
- {
286
- source: RangePatternType.startRange,
287
- pattern: pattern.slice(0, splitIndex),
288
- },
289
- {
290
- source: RangePatternType.endRange,
291
- pattern: pattern.slice(splitIndex),
292
- },
293
- ];
294
- }
@@ -1,10 +0,0 @@
1
- import { IntlDateTimeFormatInternal, TABLE_6 } from '@formatjs/ecma402-abstract';
2
- export declare const DATE_TIME_PROPS: Array<keyof Pick<IntlDateTimeFormatInternal, TABLE_6>>;
3
- export declare const removalPenalty = 120;
4
- export declare const additionPenalty = 20;
5
- export declare const differentNumericTypePenalty = 15;
6
- export declare const longLessPenalty = 8;
7
- export declare const longMorePenalty = 6;
8
- export declare const shortLessPenalty = 6;
9
- export declare const shortMorePenalty = 3;
10
- export declare const offsetPenalty = 1;
@@ -1,21 +0,0 @@
1
- export var DATE_TIME_PROPS = [
2
- 'weekday',
3
- 'era',
4
- 'year',
5
- 'month',
6
- 'day',
7
- 'dayPeriod',
8
- 'hour',
9
- 'minute',
10
- 'second',
11
- 'fractionalSecondDigits',
12
- 'timeZoneName',
13
- ];
14
- export var removalPenalty = 120;
15
- export var additionPenalty = 20;
16
- export var differentNumericTypePenalty = 15;
17
- export var longLessPenalty = 8;
18
- export var longMorePenalty = 6;
19
- export var shortLessPenalty = 6;
20
- export var shortMorePenalty = 3;
21
- export var offsetPenalty = 1;
package/lib/src/core.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import { DateTimeFormatLocaleInternalData, DateTimeFormat as IDateTimeFormat, UnpackedZoneData } from '@formatjs/ecma402-abstract';
2
- import { PackedData, RawDateTimeLocaleData } from './types';
3
- export interface DateTimeFormatConstructor {
4
- new (locales?: string | string[], options?: Intl.DateTimeFormatOptions): IDateTimeFormat;
5
- (locales?: string | string[], options?: Intl.DateTimeFormatOptions): IDateTimeFormat;
6
- __addLocaleData(...data: RawDateTimeLocaleData[]): void;
7
- supportedLocalesOf(locales: string | string[], options?: Pick<Intl.DateTimeFormatOptions, 'localeMatcher'>): string[];
8
- getDefaultLocale(): string;
9
- relevantExtensionKeys: string[];
10
- __defaultLocale: string;
11
- __defaultTimeZone: string;
12
- __setDefaultTimeZone(tz: string): void;
13
- getDefaultTimeZone(): string;
14
- localeData: Record<string, DateTimeFormatLocaleInternalData>;
15
- availableLocales: Set<string>;
16
- polyfilled: boolean;
17
- tzData: Record<string, UnpackedZoneData[]>;
18
- __addTZData(d: PackedData): void;
19
- }
20
- export declare const DateTimeFormat: DateTimeFormatConstructor;
package/lib/src/core.js DELETED
@@ -1,300 +0,0 @@
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';
5
- import { FormatDateTimeRange } from './abstract/FormatDateTimeRange';
6
- import { FormatDateTimeRangeToParts } from './abstract/FormatDateTimeRangeToParts';
7
- import { FormatDateTimeToParts } from './abstract/FormatDateTimeToParts';
8
- import { InitializeDateTimeFormat } from './abstract/InitializeDateTimeFormat';
9
- import { parseDateTimeSkeleton } from './abstract/skeleton';
10
- import { DATE_TIME_PROPS } from './abstract/utils';
11
- import links from './data/links';
12
- import getInternalSlots from './get_internal_slots';
13
- import { unpack } from './packer';
14
- var UPPERCASED_LINKS = Object.keys(links).reduce(function (all, l) {
15
- all[l.toUpperCase()] = links[l];
16
- return all;
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',
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 (e) {
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
- },
82
- };
83
- 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 (e) {
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 */
117
- };
118
- // 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
- var dtf = this;
178
- invariant(typeof dtf === 'object', 'receiver is not an object', TypeError);
179
- invariant(startDate !== undefined && endDate !== undefined, 'startDate/endDate cannot be undefined', TypeError);
180
- return FormatDateTimeRangeToParts(dtf, ToNumber(startDate), ToNumber(endDate), {
181
- getInternalSlots: getInternalSlots,
182
- localeData: DateTimeFormat.localeData,
183
- tzData: DateTimeFormat.tzData,
184
- getDefaultTimeZone: DateTimeFormat.getDefaultTimeZone,
185
- });
186
- },
187
- });
188
- defineProperty(DateTimeFormat.prototype, 'formatRange', {
189
- value: function formatRange(startDate, endDate) {
190
- var dtf = this;
191
- invariant(typeof dtf === 'object', 'receiver is not an object', TypeError);
192
- invariant(startDate !== undefined && endDate !== undefined, 'startDate/endDate cannot be undefined', TypeError);
193
- return FormatDateTimeRange(dtf, ToNumber(startDate), ToNumber(endDate), {
194
- getInternalSlots: getInternalSlots,
195
- localeData: DateTimeFormat.localeData,
196
- tzData: DateTimeFormat.tzData,
197
- getDefaultTimeZone: DateTimeFormat.getDefaultTimeZone,
198
- });
199
- },
200
- });
201
- var DEFAULT_TIMEZONE = 'UTC';
202
- DateTimeFormat.__setDefaultTimeZone = function (timeZone) {
203
- if (timeZone !== undefined) {
204
- timeZone = String(timeZone);
205
- if (!IsValidTimeZoneName(timeZone, {
206
- zoneNamesFromData: Object.keys(DateTimeFormat.tzData),
207
- uppercaseLinks: UPPERCASED_LINKS,
208
- })) {
209
- throw new RangeError('Invalid timeZoneName');
210
- }
211
- timeZone = CanonicalizeTimeZoneName(timeZone, {
212
- zoneNames: Object.keys(DateTimeFormat.tzData),
213
- uppercaseLinks: UPPERCASED_LINKS,
214
- });
215
- }
216
- else {
217
- timeZone = DEFAULT_TIMEZONE;
218
- }
219
- DateTimeFormat.__defaultTimeZone = timeZone;
220
- };
221
- DateTimeFormat.relevantExtensionKeys = ['nu', 'ca', 'hc'];
222
- DateTimeFormat.__defaultTimeZone = DEFAULT_TIMEZONE;
223
- DateTimeFormat.getDefaultTimeZone = function () { return DateTimeFormat.__defaultTimeZone; };
224
- DateTimeFormat.__addLocaleData = function __addLocaleData() {
225
- var data = [];
226
- for (var _i = 0; _i < arguments.length; _i++) {
227
- data[_i] = arguments[_i];
228
- }
229
- var _loop_1 = function (d, locale) {
230
- var dateFormat = d.dateFormat, timeFormat = d.timeFormat, dateTimeFormat = d.dateTimeFormat, formats = d.formats, intervalFormats = d.intervalFormats, rawData = __rest(d, ["dateFormat", "timeFormat", "dateTimeFormat", "formats", "intervalFormats"]);
231
- var processedData = __assign(__assign({}, rawData), { dateFormat: {
232
- full: parseDateTimeSkeleton(dateFormat.full),
233
- long: parseDateTimeSkeleton(dateFormat.long),
234
- medium: parseDateTimeSkeleton(dateFormat.medium),
235
- short: parseDateTimeSkeleton(dateFormat.short),
236
- }, timeFormat: {
237
- full: parseDateTimeSkeleton(timeFormat.full),
238
- long: parseDateTimeSkeleton(timeFormat.long),
239
- medium: parseDateTimeSkeleton(timeFormat.medium),
240
- short: parseDateTimeSkeleton(timeFormat.short),
241
- }, dateTimeFormat: {
242
- full: parseDateTimeSkeleton(dateTimeFormat.full).pattern,
243
- long: parseDateTimeSkeleton(dateTimeFormat.long).pattern,
244
- medium: parseDateTimeSkeleton(dateTimeFormat.medium).pattern,
245
- short: parseDateTimeSkeleton(dateTimeFormat.short).pattern,
246
- }, formats: {} });
247
- var _loop_2 = function (calendar) {
248
- processedData.formats[calendar] = Object.keys(formats[calendar]).map(function (skeleton) {
249
- return parseDateTimeSkeleton(skeleton, formats[calendar][skeleton], intervalFormats[skeleton], intervalFormats.intervalFormatFallback);
250
- });
251
- };
252
- for (var calendar in formats) {
253
- _loop_2(calendar);
254
- }
255
- var minimizedLocale = new Intl.Locale(locale)
256
- .minimize()
257
- .toString();
258
- DateTimeFormat.localeData[locale] = DateTimeFormat.localeData[minimizedLocale] = processedData;
259
- DateTimeFormat.availableLocales.add(locale);
260
- DateTimeFormat.availableLocales.add(minimizedLocale);
261
- if (!DateTimeFormat.__defaultLocale) {
262
- DateTimeFormat.__defaultLocale = minimizedLocale;
263
- }
264
- };
265
- for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
266
- var _b = data_1[_a], d = _b.data, locale = _b.locale;
267
- _loop_1(d, locale);
268
- }
269
- };
270
- Object.defineProperty(DateTimeFormat.prototype, 'format', formatDescriptor);
271
- DateTimeFormat.__defaultLocale = '';
272
- DateTimeFormat.localeData = {};
273
- DateTimeFormat.availableLocales = new Set();
274
- DateTimeFormat.getDefaultLocale = function () {
275
- return DateTimeFormat.__defaultLocale;
276
- };
277
- DateTimeFormat.polyfilled = true;
278
- DateTimeFormat.tzData = {};
279
- DateTimeFormat.__addTZData = function (d) {
280
- DateTimeFormat.tzData = unpack(d);
281
- };
282
- try {
283
- if (typeof Symbol !== 'undefined') {
284
- Object.defineProperty(DateTimeFormat.prototype, Symbol.toStringTag, {
285
- value: 'Intl.DateTimeFormat',
286
- writable: false,
287
- enumerable: false,
288
- configurable: true,
289
- });
290
- }
291
- Object.defineProperty(DateTimeFormat.prototype.constructor, 'length', {
292
- value: 1,
293
- writable: false,
294
- enumerable: false,
295
- configurable: true,
296
- });
297
- }
298
- catch (e) {
299
- // Meta fix so we're test262-compliant, not important
300
- }
@@ -1,6 +0,0 @@
1
- declare const data: {
2
- abbrvs: string;
3
- offsets: string;
4
- zones: string[];
5
- };
6
- export default data;