@formatjs/intl-datetimeformat 6.11.2 → 6.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/LICENSE.md +1 -1
  2. package/lib/index.js +1 -4
  3. package/lib/polyfill-force.js +10 -12
  4. package/lib/polyfill.js +12 -14
  5. package/lib/should-polyfill.js +4 -8
  6. package/lib/src/abstract/BasicFormatMatcher.js +26 -30
  7. package/lib/src/abstract/BestFitFormatMatcher.js +19 -24
  8. package/lib/src/abstract/DateTimeStyleFormat.js +5 -9
  9. package/lib/src/abstract/FormatDateTime.js +3 -7
  10. package/lib/src/abstract/FormatDateTimePattern.js +7 -11
  11. package/lib/src/abstract/FormatDateTimeRange.js +3 -7
  12. package/lib/src/abstract/FormatDateTimeRangeToParts.js +3 -7
  13. package/lib/src/abstract/FormatDateTimeToParts.js +5 -9
  14. package/lib/src/abstract/InitializeDateTimeFormat.d.ts +1 -1
  15. package/lib/src/abstract/InitializeDateTimeFormat.js +37 -43
  16. package/lib/src/abstract/PartitionDateTimePattern.js +5 -9
  17. package/lib/src/abstract/PartitionDateTimeRangePattern.js +16 -20
  18. package/lib/src/abstract/ToDateTimeOptions.js +3 -7
  19. package/lib/src/abstract/ToLocalTime.js +12 -16
  20. package/lib/src/abstract/skeleton.js +15 -22
  21. package/lib/src/abstract/utils.js +9 -12
  22. package/lib/src/core.js +106 -109
  23. package/lib/src/data/all-tz.js +1 -3
  24. package/lib/src/data/links.js +1 -3
  25. package/lib/src/get_internal_slots.js +1 -4
  26. package/lib/src/packer.js +5 -10
  27. package/lib/src/to_locale_string.js +8 -14
  28. package/lib/src/types.js +1 -2
  29. package/lib/supported-locales.generated.js +1 -4
  30. package/lib/test262-main.js +3 -6
  31. package/package.json +4 -4
  32. package/polyfill.iife.js +6302 -9407
  33. package/src/abstract/InitializeDateTimeFormat.d.ts +1 -1
  34. package/src/abstract/InitializeDateTimeFormat.js +3 -5
  35. package/src/abstract/skeleton.js +1 -1
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 FormatJS
3
+ Copyright (c) 2023 FormatJS
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/lib/index.js CHANGED
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./src/core"), exports);
1
+ export * from './src/core';
@@ -1,21 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var _1 = require("./");
4
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
- var to_locale_string_1 = require("./src/to_locale_string");
6
- (0, ecma402_abstract_1.defineProperty)(Intl, 'DateTimeFormat', { value: _1.DateTimeFormat });
7
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleString', {
1
+ import { DateTimeFormat } from './';
2
+ import { defineProperty } from '@formatjs/ecma402-abstract';
3
+ import { toLocaleString as _toLocaleString, toLocaleDateString as _toLocaleDateString, toLocaleTimeString as _toLocaleTimeString, } from './src/to_locale_string';
4
+ defineProperty(Intl, 'DateTimeFormat', { value: DateTimeFormat });
5
+ defineProperty(Date.prototype, 'toLocaleString', {
8
6
  value: function toLocaleString(locales, options) {
9
- return (0, to_locale_string_1.toLocaleString)(this, locales, options);
7
+ return _toLocaleString(this, locales, options);
10
8
  },
11
9
  });
12
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleDateString', {
10
+ defineProperty(Date.prototype, 'toLocaleDateString', {
13
11
  value: function toLocaleDateString(locales, options) {
14
- return (0, to_locale_string_1.toLocaleDateString)(this, locales, options);
12
+ return _toLocaleDateString(this, locales, options);
15
13
  },
16
14
  });
17
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleTimeString', {
15
+ defineProperty(Date.prototype, 'toLocaleTimeString', {
18
16
  value: function toLocaleTimeString(locales, options) {
19
- return (0, to_locale_string_1.toLocaleTimeString)(this, locales, options);
17
+ return _toLocaleTimeString(this, locales, options);
20
18
  },
21
19
  });
package/lib/polyfill.js CHANGED
@@ -1,35 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var _1 = require("./");
4
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
- var should_polyfill_1 = require("./should-polyfill");
6
- var to_locale_string_1 = require("./src/to_locale_string");
7
- if ((0, should_polyfill_1.shouldPolyfill)()) {
8
- (0, ecma402_abstract_1.defineProperty)(Intl, 'DateTimeFormat', { value: _1.DateTimeFormat });
9
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleString', {
1
+ import { DateTimeFormat } from './';
2
+ import { defineProperty } from '@formatjs/ecma402-abstract';
3
+ import { shouldPolyfill } from './should-polyfill';
4
+ import { toLocaleString as _toLocaleString, toLocaleDateString as _toLocaleDateString, toLocaleTimeString as _toLocaleTimeString, } from './src/to_locale_string';
5
+ if (shouldPolyfill()) {
6
+ defineProperty(Intl, 'DateTimeFormat', { value: DateTimeFormat });
7
+ defineProperty(Date.prototype, 'toLocaleString', {
10
8
  value: function toLocaleString(locales, options) {
11
9
  try {
12
- return (0, to_locale_string_1.toLocaleString)(this, locales, options);
10
+ return _toLocaleString(this, locales, options);
13
11
  }
14
12
  catch (error) {
15
13
  return 'Invalid Date';
16
14
  }
17
15
  },
18
16
  });
19
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleDateString', {
17
+ defineProperty(Date.prototype, 'toLocaleDateString', {
20
18
  value: function toLocaleDateString(locales, options) {
21
19
  try {
22
- return (0, to_locale_string_1.toLocaleDateString)(this, locales, options);
20
+ return _toLocaleDateString(this, locales, options);
23
21
  }
24
22
  catch (error) {
25
23
  return 'Invalid Date';
26
24
  }
27
25
  },
28
26
  });
29
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleTimeString', {
27
+ defineProperty(Date.prototype, 'toLocaleTimeString', {
30
28
  value: function toLocaleTimeString(locales, options) {
31
29
  try {
32
- return (0, to_locale_string_1.toLocaleTimeString)(this, locales, options);
30
+ return _toLocaleTimeString(this, locales, options);
33
31
  }
34
32
  catch (error) {
35
33
  return 'Invalid Date';
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldPolyfill = void 0;
4
- var intl_localematcher_1 = require("@formatjs/intl-localematcher");
5
- var supported_locales_generated_1 = require("./supported-locales.generated");
1
+ import { match } from '@formatjs/intl-localematcher';
2
+ import { supportedLocales } from './supported-locales.generated';
6
3
  function supportsDateStyle() {
7
4
  try {
8
5
  return !!new Intl.DateTimeFormat(undefined, {
@@ -50,7 +47,7 @@ function supportedLocalesOf(locale) {
50
47
  var locales = Array.isArray(locale) ? locale : [locale];
51
48
  return (Intl.DateTimeFormat.supportedLocalesOf(locales).length === locales.length);
52
49
  }
53
- function shouldPolyfill(locale) {
50
+ export function shouldPolyfill(locale) {
54
51
  if (locale === void 0) { locale = 'en'; }
55
52
  if (!('DateTimeFormat' in Intl) ||
56
53
  !('formatToParts' in Intl.DateTimeFormat.prototype) ||
@@ -59,7 +56,6 @@ function shouldPolyfill(locale) {
59
56
  hasUnthrownDateTimeStyleBug() ||
60
57
  !supportsDateStyle() ||
61
58
  !supportedLocalesOf(locale)) {
62
- return locale ? (0, intl_localematcher_1.match)([locale], supported_locales_generated_1.supportedLocales, 'en') : undefined;
59
+ return locale ? match([locale], supportedLocales, 'en') : undefined;
63
60
  }
64
61
  }
65
- exports.shouldPolyfill = shouldPolyfill;
@@ -1,78 +1,75 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BasicFormatMatcher = void 0;
4
- var tslib_1 = require("tslib");
5
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
6
- var utils_1 = require("./utils");
1
+ import { __assign } from "tslib";
2
+ import { invariant } from '@formatjs/ecma402-abstract';
3
+ import { DATE_TIME_PROPS, additionPenalty, removalPenalty, longMorePenalty, shortMorePenalty, shortLessPenalty, longLessPenalty, offsetPenalty, } from './utils';
7
4
  /**
8
5
  * https://tc39.es/ecma402/#sec-basicformatmatcher
9
6
  * @param options
10
7
  * @param formats
11
8
  */
12
- function BasicFormatMatcher(options, formats) {
9
+ export function BasicFormatMatcher(options, formats) {
13
10
  var bestScore = -Infinity;
14
11
  var bestFormat = formats[0];
15
- (0, ecma402_abstract_1.invariant)(Array.isArray(formats), 'formats should be a list of things');
12
+ invariant(Array.isArray(formats), 'formats should be a list of things');
16
13
  for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
17
14
  var format = formats_1[_i];
18
15
  var score = 0;
19
- for (var _a = 0, DATE_TIME_PROPS_1 = utils_1.DATE_TIME_PROPS; _a < DATE_TIME_PROPS_1.length; _a++) {
16
+ for (var _a = 0, DATE_TIME_PROPS_1 = DATE_TIME_PROPS; _a < DATE_TIME_PROPS_1.length; _a++) {
20
17
  var prop = DATE_TIME_PROPS_1[_a];
21
18
  var optionsProp = options[prop];
22
19
  var formatProp = format[prop];
23
20
  if (optionsProp === undefined && formatProp !== undefined) {
24
- score -= utils_1.additionPenalty;
21
+ score -= additionPenalty;
25
22
  }
26
23
  else if (optionsProp !== undefined && formatProp === undefined) {
27
- score -= utils_1.removalPenalty;
24
+ score -= removalPenalty;
28
25
  }
29
26
  else if (prop === 'timeZoneName') {
30
27
  if (optionsProp === 'short' || optionsProp === 'shortGeneric') {
31
28
  if (formatProp === 'shortOffset') {
32
- score -= utils_1.offsetPenalty;
29
+ score -= offsetPenalty;
33
30
  }
34
31
  else if (formatProp === 'longOffset') {
35
- score -= utils_1.offsetPenalty + utils_1.shortMorePenalty;
32
+ score -= offsetPenalty + shortMorePenalty;
36
33
  }
37
34
  else if (optionsProp === 'short' && formatProp === 'long') {
38
- score -= utils_1.shortMorePenalty;
35
+ score -= shortMorePenalty;
39
36
  }
40
37
  else if (optionsProp === 'shortGeneric' &&
41
38
  formatProp === 'longGeneric') {
42
- score -= utils_1.shortMorePenalty;
39
+ score -= shortMorePenalty;
43
40
  }
44
41
  else if (optionsProp !== formatProp) {
45
- score -= utils_1.removalPenalty;
42
+ score -= removalPenalty;
46
43
  }
47
44
  }
48
45
  else if (optionsProp === 'shortOffset' &&
49
46
  formatProp === 'longOffset') {
50
- score -= utils_1.shortMorePenalty;
47
+ score -= shortMorePenalty;
51
48
  }
52
49
  else if (optionsProp === 'long' || optionsProp === 'longGeneric') {
53
50
  if (formatProp === 'longOffset') {
54
- score -= utils_1.offsetPenalty;
51
+ score -= offsetPenalty;
55
52
  }
56
53
  else if (formatProp === 'shortOffset') {
57
- score -= utils_1.offsetPenalty + utils_1.longLessPenalty;
54
+ score -= offsetPenalty + longLessPenalty;
58
55
  }
59
56
  else if (optionsProp === 'long' && formatProp === 'short') {
60
- score -= utils_1.longLessPenalty;
57
+ score -= longLessPenalty;
61
58
  }
62
59
  else if (optionsProp === 'longGeneric' &&
63
60
  formatProp === 'shortGeneric') {
64
- score -= utils_1.longLessPenalty;
61
+ score -= longLessPenalty;
65
62
  }
66
63
  else if (optionsProp !== formatProp) {
67
- score -= utils_1.removalPenalty;
64
+ score -= removalPenalty;
68
65
  }
69
66
  }
70
67
  else if (optionsProp === 'longOffset' &&
71
68
  formatProp === 'shortOffset') {
72
- score -= utils_1.longLessPenalty;
69
+ score -= longLessPenalty;
73
70
  }
74
71
  else if (optionsProp !== formatProp) {
75
- score -= utils_1.removalPenalty;
72
+ score -= removalPenalty;
76
73
  }
77
74
  }
78
75
  else if (optionsProp !== formatProp) {
@@ -87,16 +84,16 @@ function BasicFormatMatcher(options, formats) {
87
84
  var formatPropIndex = values.indexOf(formatProp);
88
85
  var delta = Math.max(-2, Math.min(formatPropIndex - optionsPropIndex, 2));
89
86
  if (delta === 2) {
90
- score -= utils_1.longMorePenalty;
87
+ score -= longMorePenalty;
91
88
  }
92
89
  else if (delta === 1) {
93
- score -= utils_1.shortMorePenalty;
90
+ score -= shortMorePenalty;
94
91
  }
95
92
  else if (delta === -1) {
96
- score -= utils_1.shortLessPenalty;
93
+ score -= shortLessPenalty;
97
94
  }
98
95
  else if (delta === -2) {
99
- score -= utils_1.longLessPenalty;
96
+ score -= longLessPenalty;
100
97
  }
101
98
  }
102
99
  }
@@ -105,6 +102,5 @@ function BasicFormatMatcher(options, formats) {
105
102
  bestFormat = format;
106
103
  }
107
104
  }
108
- return tslib_1.__assign({}, bestFormat);
105
+ return __assign({}, bestFormat);
109
106
  }
110
- exports.BasicFormatMatcher = BasicFormatMatcher;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BestFitFormatMatcher = exports.bestFitFormatMatcherScore = void 0;
4
- var tslib_1 = require("tslib");
5
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
6
- var utils_1 = require("./utils");
7
- var skeleton_1 = require("./skeleton");
1
+ import { __assign } from "tslib";
2
+ import { invariant } from '@formatjs/ecma402-abstract';
3
+ import { DATE_TIME_PROPS, removalPenalty, additionPenalty, differentNumericTypePenalty, longMorePenalty, shortMorePenalty, shortLessPenalty, longLessPenalty, } from './utils';
4
+ import { processDateTimePattern } from './skeleton';
8
5
  function isNumericType(t) {
9
6
  return t === 'numeric' || t === '2-digit';
10
7
  }
@@ -14,29 +11,29 @@ function isNumericType(t) {
14
11
  * @param options
15
12
  * @param format
16
13
  */
17
- function bestFitFormatMatcherScore(options, format) {
14
+ export function bestFitFormatMatcherScore(options, format) {
18
15
  var score = 0;
19
16
  if (options.hour12 && !format.hour12) {
20
- score -= utils_1.removalPenalty;
17
+ score -= removalPenalty;
21
18
  }
22
19
  else if (!options.hour12 && format.hour12) {
23
- score -= utils_1.additionPenalty;
20
+ score -= additionPenalty;
24
21
  }
25
- for (var _i = 0, DATE_TIME_PROPS_1 = utils_1.DATE_TIME_PROPS; _i < DATE_TIME_PROPS_1.length; _i++) {
22
+ for (var _i = 0, DATE_TIME_PROPS_1 = DATE_TIME_PROPS; _i < DATE_TIME_PROPS_1.length; _i++) {
26
23
  var prop = DATE_TIME_PROPS_1[_i];
27
24
  var optionsProp = options[prop];
28
25
  var formatProp = format[prop];
29
26
  if (optionsProp === undefined && formatProp !== undefined) {
30
- score -= utils_1.additionPenalty;
27
+ score -= additionPenalty;
31
28
  }
32
29
  else if (optionsProp !== undefined && formatProp === undefined) {
33
- score -= utils_1.removalPenalty;
30
+ score -= removalPenalty;
34
31
  }
35
32
  else if (optionsProp !== formatProp) {
36
33
  // extra penalty for numeric vs non-numeric
37
34
  if (isNumericType(optionsProp) !==
38
35
  isNumericType(formatProp)) {
39
- score -= utils_1.differentNumericTypePenalty;
36
+ score -= differentNumericTypePenalty;
40
37
  }
41
38
  else {
42
39
  var values = ['2-digit', 'numeric', 'narrow', 'short', 'long'];
@@ -44,23 +41,22 @@ function bestFitFormatMatcherScore(options, format) {
44
41
  var formatPropIndex = values.indexOf(formatProp);
45
42
  var delta = Math.max(-2, Math.min(formatPropIndex - optionsPropIndex, 2));
46
43
  if (delta === 2) {
47
- score -= utils_1.longMorePenalty;
44
+ score -= longMorePenalty;
48
45
  }
49
46
  else if (delta === 1) {
50
- score -= utils_1.shortMorePenalty;
47
+ score -= shortMorePenalty;
51
48
  }
52
49
  else if (delta === -1) {
53
- score -= utils_1.shortLessPenalty;
50
+ score -= shortLessPenalty;
54
51
  }
55
52
  else if (delta === -2) {
56
- score -= utils_1.longLessPenalty;
53
+ score -= longLessPenalty;
57
54
  }
58
55
  }
59
56
  }
60
57
  }
61
58
  return score;
62
59
  }
63
- exports.bestFitFormatMatcherScore = bestFitFormatMatcherScore;
64
60
  /**
65
61
  * https://tc39.es/ecma402/#sec-bestfitformatmatcher
66
62
  * Just alias to basic for now
@@ -68,10 +64,10 @@ exports.bestFitFormatMatcherScore = bestFitFormatMatcherScore;
68
64
  * @param formats
69
65
  * @param implDetails Implementation details
70
66
  */
71
- function BestFitFormatMatcher(options, formats) {
67
+ export function BestFitFormatMatcher(options, formats) {
72
68
  var bestScore = -Infinity;
73
69
  var bestFormat = formats[0];
74
- (0, ecma402_abstract_1.invariant)(Array.isArray(formats), 'formats should be a list of things');
70
+ invariant(Array.isArray(formats), 'formats should be a list of things');
75
71
  for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
76
72
  var format = formats_1[_i];
77
73
  var score = bestFitFormatMatcherScore(options, format);
@@ -80,9 +76,9 @@ function BestFitFormatMatcher(options, formats) {
80
76
  bestFormat = format;
81
77
  }
82
78
  }
83
- var skeletonFormat = tslib_1.__assign({}, bestFormat);
79
+ var skeletonFormat = __assign({}, bestFormat);
84
80
  var patternFormat = { rawPattern: bestFormat.rawPattern };
85
- (0, skeleton_1.processDateTimePattern)(bestFormat.rawPattern, patternFormat);
81
+ processDateTimePattern(bestFormat.rawPattern, patternFormat);
86
82
  // Kinda following https://github.com/unicode-org/icu/blob/dd50e38f459d84e9bf1b0c618be8483d318458ad/icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java
87
83
  // Method adjustFieldTypes
88
84
  for (var prop in skeletonFormat) {
@@ -118,4 +114,3 @@ function BestFitFormatMatcher(options, formats) {
118
114
  patternFormat.rangePatterns12 = skeletonFormat.rangePatterns12;
119
115
  return patternFormat;
120
116
  }
121
- exports.BestFitFormatMatcher = BestFitFormatMatcher;
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DateTimeStyleFormat = void 0;
4
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
- function DateTimeStyleFormat(dateStyle, timeStyle, dataLocaleData) {
1
+ import { invariant, } from '@formatjs/ecma402-abstract';
2
+ export function DateTimeStyleFormat(dateStyle, timeStyle, dataLocaleData) {
6
3
  var dateFormat, timeFormat;
7
4
  if (timeStyle !== undefined) {
8
- (0, ecma402_abstract_1.invariant)(timeStyle === 'full' ||
5
+ invariant(timeStyle === 'full' ||
9
6
  timeStyle === 'long' ||
10
7
  timeStyle === 'medium' ||
11
8
  timeStyle === 'short', 'invalid timeStyle');
12
9
  timeFormat = dataLocaleData.timeFormat[timeStyle];
13
10
  }
14
11
  if (dateStyle !== undefined) {
15
- (0, ecma402_abstract_1.invariant)(dateStyle === 'full' ||
12
+ invariant(dateStyle === 'full' ||
16
13
  dateStyle === 'long' ||
17
14
  dateStyle === 'medium' ||
18
15
  dateStyle === 'short', 'invalid dateStyle');
@@ -48,7 +45,6 @@ function DateTimeStyleFormat(dateStyle, timeStyle, dataLocaleData) {
48
45
  if (timeStyle !== undefined) {
49
46
  return timeFormat;
50
47
  }
51
- (0, ecma402_abstract_1.invariant)(dateStyle !== undefined, 'dateStyle should not be undefined');
48
+ invariant(dateStyle !== undefined, 'dateStyle should not be undefined');
52
49
  return dateFormat;
53
50
  }
54
- exports.DateTimeStyleFormat = DateTimeStyleFormat;
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatDateTime = void 0;
4
- var PartitionDateTimePattern_1 = require("./PartitionDateTimePattern");
1
+ import { PartitionDateTimePattern } from './PartitionDateTimePattern';
5
2
  /**
6
3
  * https://tc39.es/ecma402/#sec-formatdatetime
7
4
  * @param dtf DateTimeFormat
8
5
  * @param x
9
6
  */
10
- function FormatDateTime(dtf, x, implDetails) {
11
- var parts = (0, PartitionDateTimePattern_1.PartitionDateTimePattern)(dtf, x, implDetails);
7
+ export function FormatDateTime(dtf, x, implDetails) {
8
+ var parts = PartitionDateTimePattern(dtf, x, implDetails);
12
9
  var result = '';
13
10
  for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
14
11
  var part = parts_1[_i];
@@ -16,4 +13,3 @@ function FormatDateTime(dtf, x, implDetails) {
16
13
  }
17
14
  return result;
18
15
  }
19
- exports.FormatDateTime = FormatDateTime;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatDateTimePattern = void 0;
4
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
- var utils_1 = require("./utils");
6
- var ToLocalTime_1 = require("./ToLocalTime");
1
+ import { TimeClip, } from '@formatjs/ecma402-abstract';
2
+ import { DATE_TIME_PROPS } from './utils';
3
+ import { ToLocalTime } from './ToLocalTime';
7
4
  function pad(n) {
8
5
  if (n < 10) {
9
6
  return "0".concat(n);
@@ -37,9 +34,9 @@ function offsetToGmtString(gmtFormat, hourFormat, offsetInMs, style) {
37
34
  * @param dtf
38
35
  * @param x
39
36
  */
40
- function FormatDateTimePattern(dtf, patternParts, x, _a) {
37
+ export function FormatDateTimePattern(dtf, patternParts, x, _a) {
41
38
  var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, getDefaultTimeZone = _a.getDefaultTimeZone, tzData = _a.tzData;
42
- x = (0, ecma402_abstract_1.TimeClip)(x);
39
+ x = TimeClip(x);
43
40
  /** IMPL START */
44
41
  var internalSlots = getInternalSlots(dtf);
45
42
  var dataLocale = internalSlots.dataLocale;
@@ -61,7 +58,7 @@ function FormatDateTimePattern(dtf, patternParts, x, _a) {
61
58
  nf3Options.useGrouping = false;
62
59
  nf3 = new Intl.NumberFormat(locale, nf3Options);
63
60
  }
64
- var tm = (0, ToLocalTime_1.ToLocalTime)(x,
61
+ var tm = ToLocalTime(x,
65
62
  // @ts-ignore
66
63
  internalSlots.calendar, internalSlots.timeZone, { tzData: tzData });
67
64
  var result = [];
@@ -102,7 +99,7 @@ function FormatDateTimePattern(dtf, patternParts, x, _a) {
102
99
  }
103
100
  result.push({ type: p, value: fv });
104
101
  }
105
- else if (utils_1.DATE_TIME_PROPS.indexOf(p) > -1) {
102
+ else if (DATE_TIME_PROPS.indexOf(p) > -1) {
106
103
  var fv = '';
107
104
  var f = internalSlots[p];
108
105
  // @ts-ignore
@@ -187,4 +184,3 @@ function FormatDateTimePattern(dtf, patternParts, x, _a) {
187
184
  }
188
185
  return result;
189
186
  }
190
- exports.FormatDateTimePattern = FormatDateTimePattern;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatDateTimeRange = void 0;
4
- var PartitionDateTimeRangePattern_1 = require("./PartitionDateTimeRangePattern");
5
- function FormatDateTimeRange(dtf, x, y, implDetails) {
6
- var parts = (0, PartitionDateTimeRangePattern_1.PartitionDateTimeRangePattern)(dtf, x, y, implDetails);
1
+ import { PartitionDateTimeRangePattern } from './PartitionDateTimeRangePattern';
2
+ export function FormatDateTimeRange(dtf, x, y, implDetails) {
3
+ var parts = PartitionDateTimeRangePattern(dtf, x, y, implDetails);
7
4
  var result = '';
8
5
  for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
9
6
  var part = parts_1[_i];
@@ -11,4 +8,3 @@ function FormatDateTimeRange(dtf, x, y, implDetails) {
11
8
  }
12
9
  return result;
13
10
  }
14
- exports.FormatDateTimeRange = FormatDateTimeRange;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatDateTimeRangeToParts = void 0;
4
- var PartitionDateTimeRangePattern_1 = require("./PartitionDateTimeRangePattern");
5
- function FormatDateTimeRangeToParts(dtf, x, y, implDetails) {
6
- var parts = (0, PartitionDateTimeRangePattern_1.PartitionDateTimeRangePattern)(dtf, x, y, implDetails);
1
+ import { PartitionDateTimeRangePattern } from './PartitionDateTimeRangePattern';
2
+ export function FormatDateTimeRangeToParts(dtf, x, y, implDetails) {
3
+ var parts = PartitionDateTimeRangePattern(dtf, x, y, implDetails);
7
4
  var result = new Array(0);
8
5
  for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
9
6
  var part = parts_1[_i];
@@ -15,4 +12,3 @@ function FormatDateTimeRangeToParts(dtf, x, y, implDetails) {
15
12
  }
16
13
  return result;
17
14
  }
18
- exports.FormatDateTimeRangeToParts = FormatDateTimeRangeToParts;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatDateTimeToParts = void 0;
4
- var PartitionDateTimePattern_1 = require("./PartitionDateTimePattern");
5
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
1
+ import { PartitionDateTimePattern } from './PartitionDateTimePattern';
2
+ import { ArrayCreate } from '@formatjs/ecma402-abstract';
6
3
  /**
7
4
  * https://tc39.es/ecma402/#sec-formatdatetimetoparts
8
5
  *
@@ -10,9 +7,9 @@ var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
10
7
  * @param x
11
8
  * @param implDetails
12
9
  */
13
- function FormatDateTimeToParts(dtf, x, implDetails) {
14
- var parts = (0, PartitionDateTimePattern_1.PartitionDateTimePattern)(dtf, x, implDetails);
15
- var result = (0, ecma402_abstract_1.ArrayCreate)(0);
10
+ export function FormatDateTimeToParts(dtf, x, implDetails) {
11
+ var parts = PartitionDateTimePattern(dtf, x, implDetails);
12
+ var result = ArrayCreate(0);
16
13
  for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
17
14
  var part = parts_1[_i];
18
15
  result.push({
@@ -22,4 +19,3 @@ function FormatDateTimeToParts(dtf, x, implDetails) {
22
19
  }
23
20
  return result;
24
21
  }
25
- exports.FormatDateTimeToParts = FormatDateTimeToParts;
@@ -1,4 +1,4 @@
1
- import { IntlDateTimeFormatInternal, DateTimeFormatLocaleInternalData, DateTimeFormat as DateTimeFormat } from '@formatjs/ecma402-abstract';
1
+ import { DateTimeFormat, DateTimeFormatLocaleInternalData, IntlDateTimeFormatInternal } from '@formatjs/ecma402-abstract';
2
2
  /**
3
3
  * https://tc39.es/ecma402/#sec-initializedatetimeformat
4
4
  * @param dtf DateTimeFormat