@formatjs/ecma402-abstract 1.9.0 → 1.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/IsValidTimeZoneName.d.ts +1 -1
  2. package/IsValidTimeZoneName.d.ts.map +1 -1
  3. package/IsValidTimeZoneName.js +6 -1
  4. package/NumberFormat/InitializeNumberFormat.d.ts +2 -2
  5. package/NumberFormat/InitializeNumberFormat.d.ts.map +1 -1
  6. package/NumberFormat/digit-mapping.generated.d.ts +2 -0
  7. package/NumberFormat/digit-mapping.generated.d.ts.map +1 -0
  8. package/NumberFormat/digit-mapping.generated.js +4 -0
  9. package/NumberFormat/format_to_parts.js +2 -3
  10. package/index.d.ts +1 -23
  11. package/index.d.ts.map +1 -1
  12. package/index.js +13 -38
  13. package/lib/IsValidTimeZoneName.d.ts +1 -1
  14. package/lib/IsValidTimeZoneName.d.ts.map +1 -1
  15. package/lib/IsValidTimeZoneName.js +6 -1
  16. package/lib/NumberFormat/InitializeNumberFormat.d.ts +2 -2
  17. package/lib/NumberFormat/InitializeNumberFormat.d.ts.map +1 -1
  18. package/lib/NumberFormat/digit-mapping.generated.d.ts +2 -0
  19. package/lib/NumberFormat/digit-mapping.generated.d.ts.map +1 -0
  20. package/lib/NumberFormat/digit-mapping.generated.js +1 -0
  21. package/lib/NumberFormat/format_to_parts.js +1 -1
  22. package/lib/index.d.ts +1 -23
  23. package/lib/index.d.ts.map +1 -1
  24. package/lib/index.js +1 -23
  25. package/lib/types/date-time.d.ts +2 -1
  26. package/lib/types/date-time.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/types/date-time.d.ts +2 -1
  29. package/types/date-time.d.ts.map +1 -1
  30. package/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
  31. package/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
  32. package/DateTimeFormat/BasicFormatMatcher.js +0 -61
  33. package/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
  34. package/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
  35. package/DateTimeFormat/BestFitFormatMatcher.js +0 -121
  36. package/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
  37. package/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
  38. package/DateTimeFormat/DateTimeStyleFormat.js +0 -54
  39. package/DateTimeFormat/FormatDateTime.d.ts +0 -8
  40. package/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
  41. package/DateTimeFormat/FormatDateTime.js +0 -19
  42. package/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
  43. package/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
  44. package/DateTimeFormat/FormatDateTimePattern.js +0 -182
  45. package/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
  46. package/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
  47. package/DateTimeFormat/FormatDateTimeRange.js +0 -14
  48. package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
  49. package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
  50. package/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -18
  51. package/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
  52. package/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
  53. package/DateTimeFormat/FormatDateTimeToParts.js +0 -25
  54. package/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
  55. package/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
  56. package/DateTimeFormat/InitializeDateTimeFormat.js +0 -188
  57. package/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
  58. package/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
  59. package/DateTimeFormat/PartitionDateTimePattern.js +0 -24
  60. package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
  61. package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
  62. package/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -128
  63. package/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
  64. package/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
  65. package/DateTimeFormat/ToDateTimeOptions.js +0 -67
  66. package/DateTimeFormat/ToLocalTime.d.ts +0 -26
  67. package/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
  68. package/DateTimeFormat/ToLocalTime.js +0 -55
  69. package/DateTimeFormat/skeleton.d.ts +0 -14
  70. package/DateTimeFormat/skeleton.d.ts.map +0 -1
  71. package/DateTimeFormat/skeleton.js +0 -301
  72. package/DateTimeFormat/utils.d.ts +0 -10
  73. package/DateTimeFormat/utils.d.ts.map +0 -1
  74. package/DateTimeFormat/utils.js +0 -21
  75. package/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
  76. package/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
  77. package/DisplayNames/CanonicalCodeForDisplayNames.js +0 -37
  78. package/NumberFormat/digit-mapping.json +0 -1
  79. package/PluralRules/GetOperands.d.ts +0 -32
  80. package/PluralRules/GetOperands.d.ts.map +0 -1
  81. package/PluralRules/GetOperands.js +0 -51
  82. package/PluralRules/InitializePluralRules.d.ts +0 -9
  83. package/PluralRules/InitializePluralRules.d.ts.map +0 -1
  84. package/PluralRules/InitializePluralRules.js +0 -24
  85. package/PluralRules/ResolvePlural.d.ts +0 -13
  86. package/PluralRules/ResolvePlural.d.ts.map +0 -1
  87. package/PluralRules/ResolvePlural.js +0 -29
  88. package/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
  89. package/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
  90. package/RelativeTimeFormat/FormatRelativeTime.js +0 -14
  91. package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
  92. package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
  93. package/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -22
  94. package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
  95. package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
  96. package/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -41
  97. package/RelativeTimeFormat/MakePartsList.d.ts +0 -2
  98. package/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
  99. package/RelativeTimeFormat/MakePartsList.js +0 -31
  100. package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
  101. package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
  102. package/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -58
  103. package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
  104. package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
  105. package/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -40
  106. package/lib/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
  107. package/lib/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
  108. package/lib/DateTimeFormat/BasicFormatMatcher.js +0 -57
  109. package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
  110. package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
  111. package/lib/DateTimeFormat/BestFitFormatMatcher.js +0 -116
  112. package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
  113. package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
  114. package/lib/DateTimeFormat/DateTimeStyleFormat.js +0 -50
  115. package/lib/DateTimeFormat/FormatDateTime.d.ts +0 -8
  116. package/lib/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
  117. package/lib/DateTimeFormat/FormatDateTime.js +0 -15
  118. package/lib/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
  119. package/lib/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
  120. package/lib/DateTimeFormat/FormatDateTimePattern.js +0 -178
  121. package/lib/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
  122. package/lib/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
  123. package/lib/DateTimeFormat/FormatDateTimeRange.js +0 -10
  124. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
  125. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
  126. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -14
  127. package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
  128. package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
  129. package/lib/DateTimeFormat/FormatDateTimeToParts.js +0 -21
  130. package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
  131. package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
  132. package/lib/DateTimeFormat/InitializeDateTimeFormat.js +0 -184
  133. package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
  134. package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
  135. package/lib/DateTimeFormat/PartitionDateTimePattern.js +0 -20
  136. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
  137. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
  138. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -124
  139. package/lib/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
  140. package/lib/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
  141. package/lib/DateTimeFormat/ToDateTimeOptions.js +0 -63
  142. package/lib/DateTimeFormat/ToLocalTime.d.ts +0 -26
  143. package/lib/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
  144. package/lib/DateTimeFormat/ToLocalTime.js +0 -51
  145. package/lib/DateTimeFormat/skeleton.d.ts +0 -14
  146. package/lib/DateTimeFormat/skeleton.d.ts.map +0 -1
  147. package/lib/DateTimeFormat/skeleton.js +0 -294
  148. package/lib/DateTimeFormat/utils.d.ts +0 -10
  149. package/lib/DateTimeFormat/utils.d.ts.map +0 -1
  150. package/lib/DateTimeFormat/utils.js +0 -18
  151. package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
  152. package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
  153. package/lib/DisplayNames/CanonicalCodeForDisplayNames.js +0 -33
  154. package/lib/NumberFormat/digit-mapping.json +0 -1
  155. package/lib/PluralRules/GetOperands.d.ts +0 -32
  156. package/lib/PluralRules/GetOperands.d.ts.map +0 -1
  157. package/lib/PluralRules/GetOperands.js +0 -47
  158. package/lib/PluralRules/InitializePluralRules.d.ts +0 -9
  159. package/lib/PluralRules/InitializePluralRules.d.ts.map +0 -1
  160. package/lib/PluralRules/InitializePluralRules.js +0 -20
  161. package/lib/PluralRules/ResolvePlural.d.ts +0 -13
  162. package/lib/PluralRules/ResolvePlural.d.ts.map +0 -1
  163. package/lib/PluralRules/ResolvePlural.js +0 -25
  164. package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
  165. package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
  166. package/lib/RelativeTimeFormat/FormatRelativeTime.js +0 -10
  167. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
  168. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
  169. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -18
  170. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
  171. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
  172. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -37
  173. package/lib/RelativeTimeFormat/MakePartsList.d.ts +0 -2
  174. package/lib/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
  175. package/lib/RelativeTimeFormat/MakePartsList.js +0 -27
  176. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
  177. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
  178. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -54
  179. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
  180. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
  181. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -36
@@ -1,188 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InitializeDateTimeFormat = void 0;
4
- var CanonicalizeLocaleList_1 = require("../CanonicalizeLocaleList");
5
- var ToDateTimeOptions_1 = require("./ToDateTimeOptions");
6
- var GetOption_1 = require("../GetOption");
7
- var ResolveLocale_1 = require("../ResolveLocale");
8
- var IsValidTimeZoneName_1 = require("../IsValidTimeZoneName");
9
- var CanonicalizeTimeZoneName_1 = require("../CanonicalizeTimeZoneName");
10
- var BasicFormatMatcher_1 = require("./BasicFormatMatcher");
11
- var BestFitFormatMatcher_1 = require("./BestFitFormatMatcher");
12
- var utils_1 = require("../utils");
13
- var utils_2 = require("./utils");
14
- var DateTimeStyleFormat_1 = require("./DateTimeStyleFormat");
15
- var GetNumberOption_1 = require("../GetNumberOption");
16
- function isTimeRelated(opt) {
17
- for (var _i = 0, _a = ['hour', 'minute', 'second']; _i < _a.length; _i++) {
18
- var prop = _a[_i];
19
- var value = opt[prop];
20
- if (value !== undefined) {
21
- return true;
22
- }
23
- }
24
- return false;
25
- }
26
- function resolveHourCycle(hc, hcDefault, hour12) {
27
- if (hc == null) {
28
- hc = hcDefault;
29
- }
30
- if (hour12 !== undefined) {
31
- if (hour12) {
32
- if (hcDefault === 'h11' || hcDefault === 'h23') {
33
- hc = 'h11';
34
- }
35
- else {
36
- hc = 'h12';
37
- }
38
- }
39
- else {
40
- utils_1.invariant(!hour12, 'hour12 must not be set');
41
- if (hcDefault === 'h11' || hcDefault === 'h23') {
42
- hc = 'h23';
43
- }
44
- else {
45
- hc = 'h24';
46
- }
47
- }
48
- }
49
- return hc;
50
- }
51
- var TYPE_REGEX = /^[a-z0-9]{3,8}$/i;
52
- /**
53
- * https://tc39.es/ecma402/#sec-initializedatetimeformat
54
- * @param dtf DateTimeFormat
55
- * @param locales locales
56
- * @param opts options
57
- */
58
- function InitializeDateTimeFormat(dtf, locales, opts, _a) {
59
- var getInternalSlots = _a.getInternalSlots, availableLocales = _a.availableLocales, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale, getDefaultTimeZone = _a.getDefaultTimeZone, relevantExtensionKeys = _a.relevantExtensionKeys, tzData = _a.tzData, uppercaseLinks = _a.uppercaseLinks;
60
- // @ts-ignore
61
- var requestedLocales = CanonicalizeLocaleList_1.CanonicalizeLocaleList(locales);
62
- var options = ToDateTimeOptions_1.ToDateTimeOptions(opts, 'any', 'date');
63
- var opt = Object.create(null);
64
- var matcher = GetOption_1.GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
65
- opt.localeMatcher = matcher;
66
- var calendar = GetOption_1.GetOption(options, 'calendar', 'string', undefined, undefined);
67
- if (calendar !== undefined && !TYPE_REGEX.test(calendar)) {
68
- throw new RangeError('Malformed calendar');
69
- }
70
- var internalSlots = getInternalSlots(dtf);
71
- opt.ca = calendar;
72
- var numberingSystem = GetOption_1.GetOption(options, 'numberingSystem', 'string', undefined, undefined);
73
- if (numberingSystem !== undefined && !TYPE_REGEX.test(numberingSystem)) {
74
- throw new RangeError('Malformed numbering system');
75
- }
76
- opt.nu = numberingSystem;
77
- var hour12 = GetOption_1.GetOption(options, 'hour12', 'boolean', undefined, undefined);
78
- var hourCycle = GetOption_1.GetOption(options, 'hourCycle', 'string', ['h11', 'h12', 'h23', 'h24'], undefined);
79
- if (hour12 !== undefined) {
80
- // @ts-ignore
81
- hourCycle = null;
82
- }
83
- opt.hc = hourCycle;
84
- var r = ResolveLocale_1.ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
85
- internalSlots.locale = r.locale;
86
- calendar = r.ca;
87
- internalSlots.calendar = calendar;
88
- internalSlots.hourCycle = r.hc;
89
- internalSlots.numberingSystem = r.nu;
90
- var dataLocale = r.dataLocale;
91
- internalSlots.dataLocale = dataLocale;
92
- var timeZone = options.timeZone;
93
- if (timeZone !== undefined) {
94
- timeZone = String(timeZone);
95
- if (!IsValidTimeZoneName_1.IsValidTimeZoneName(timeZone, { tzData: tzData, uppercaseLinks: uppercaseLinks })) {
96
- throw new RangeError('Invalid timeZoneName');
97
- }
98
- timeZone = CanonicalizeTimeZoneName_1.CanonicalizeTimeZoneName(timeZone, { tzData: tzData, uppercaseLinks: uppercaseLinks });
99
- }
100
- else {
101
- timeZone = getDefaultTimeZone();
102
- }
103
- internalSlots.timeZone = timeZone;
104
- opt = Object.create(null);
105
- opt.weekday = GetOption_1.GetOption(options, 'weekday', 'string', ['narrow', 'short', 'long'], undefined);
106
- opt.era = GetOption_1.GetOption(options, 'era', 'string', ['narrow', 'short', 'long'], undefined);
107
- opt.year = GetOption_1.GetOption(options, 'year', 'string', ['2-digit', 'numeric'], undefined);
108
- opt.month = GetOption_1.GetOption(options, 'month', 'string', ['2-digit', 'numeric', 'narrow', 'short', 'long'], undefined);
109
- opt.day = GetOption_1.GetOption(options, 'day', 'string', ['2-digit', 'numeric'], undefined);
110
- opt.hour = GetOption_1.GetOption(options, 'hour', 'string', ['2-digit', 'numeric'], undefined);
111
- opt.minute = GetOption_1.GetOption(options, 'minute', 'string', ['2-digit', 'numeric'], undefined);
112
- opt.second = GetOption_1.GetOption(options, 'second', 'string', ['2-digit', 'numeric'], undefined);
113
- opt.timeZoneName = GetOption_1.GetOption(options, 'timeZoneName', 'string', ['short', 'long'], undefined);
114
- opt.fractionalSecondDigits = GetNumberOption_1.GetNumberOption(options, 'fractionalSecondDigits', 1, 3,
115
- // @ts-expect-error
116
- undefined);
117
- var dataLocaleData = localeData[dataLocale];
118
- utils_1.invariant(!!dataLocaleData, "Missing locale data for " + dataLocale);
119
- var formats = dataLocaleData.formats[calendar];
120
- // UNSPECCED: IMPLEMENTATION DETAILS
121
- if (!formats) {
122
- throw new RangeError("Calendar \"" + calendar + "\" is not supported. Try setting \"calendar\" to 1 of the following: " + Object.keys(dataLocaleData.formats).join(', '));
123
- }
124
- var formatMatcher = GetOption_1.GetOption(options, 'formatMatcher', 'string', ['basic', 'best fit'], 'best fit');
125
- var dateStyle = GetOption_1.GetOption(options, 'dateStyle', 'string', ['full', 'long', 'medium', 'short'], undefined);
126
- internalSlots.dateStyle = dateStyle;
127
- var timeStyle = GetOption_1.GetOption(options, 'timeStyle', 'string', ['full', 'long', 'medium', 'short'], undefined);
128
- internalSlots.timeStyle = timeStyle;
129
- var bestFormat;
130
- if (dateStyle === undefined && timeStyle === undefined) {
131
- if (formatMatcher === 'basic') {
132
- bestFormat = BasicFormatMatcher_1.BasicFormatMatcher(opt, formats);
133
- }
134
- else {
135
- // IMPL DETAILS START
136
- if (isTimeRelated(opt)) {
137
- var hc = resolveHourCycle(internalSlots.hourCycle, dataLocaleData.hourCycle, hour12);
138
- opt.hour12 = hc === 'h11' || hc === 'h12';
139
- }
140
- // IMPL DETAILS END
141
- bestFormat = BestFitFormatMatcher_1.BestFitFormatMatcher(opt, formats);
142
- }
143
- }
144
- else {
145
- for (var _i = 0, DATE_TIME_PROPS_1 = utils_2.DATE_TIME_PROPS; _i < DATE_TIME_PROPS_1.length; _i++) {
146
- var prop = DATE_TIME_PROPS_1[_i];
147
- var p = opt[prop];
148
- if (p !== undefined) {
149
- throw new TypeError("Intl.DateTimeFormat can't set option " + prop + " when " + (dateStyle ? 'dateStyle' : 'timeStyle') + " is used");
150
- }
151
- }
152
- bestFormat = DateTimeStyleFormat_1.DateTimeStyleFormat(dateStyle, timeStyle, dataLocaleData);
153
- }
154
- // IMPL DETAIL START
155
- // For debugging
156
- internalSlots.format = bestFormat;
157
- // IMPL DETAIL END
158
- for (var prop in opt) {
159
- var p = bestFormat[prop];
160
- if (p !== undefined) {
161
- internalSlots[prop] = p;
162
- }
163
- }
164
- var pattern;
165
- var rangePatterns;
166
- if (internalSlots.hour !== undefined) {
167
- var hc = resolveHourCycle(internalSlots.hourCycle, dataLocaleData.hourCycle, hour12);
168
- internalSlots.hourCycle = hc;
169
- if (hc === 'h11' || hc === 'h12') {
170
- pattern = bestFormat.pattern12;
171
- rangePatterns = bestFormat.rangePatterns12;
172
- }
173
- else {
174
- pattern = bestFormat.pattern;
175
- rangePatterns = bestFormat.rangePatterns;
176
- }
177
- }
178
- else {
179
- // @ts-ignore
180
- internalSlots.hourCycle = undefined;
181
- pattern = bestFormat.pattern;
182
- rangePatterns = bestFormat.rangePatterns;
183
- }
184
- internalSlots.pattern = pattern;
185
- internalSlots.rangePatterns = rangePatterns;
186
- return dtf;
187
- }
188
- exports.InitializeDateTimeFormat = InitializeDateTimeFormat;
@@ -1,10 +0,0 @@
1
- import { ToLocalTimeImplDetails } from './ToLocalTime';
2
- import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
3
- import { IntlDateTimeFormatPart } from '../types/date-time';
4
- /**
5
- * https://tc39.es/ecma402/#sec-partitiondatetimepattern
6
- * @param dtf
7
- * @param x
8
- */
9
- export declare function PartitionDateTimePattern(dtf: Intl.DateTimeFormat, x: number, implDetails: ToLocalTimeImplDetails & FormatDateTimePatternImplDetails): IntlDateTimeFormatPart[];
10
- //# sourceMappingURL=PartitionDateTimePattern.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PartitionDateTimePattern.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/PartitionDateTimePattern.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAA;AACpD,OAAO,EAEL,gCAAgC,EACjC,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EACL,sBAAsB,EAEvB,MAAM,oBAAoB,CAAA;AAE3B;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,sBAAsB,GAAG,gCAAgC,GACrE,sBAAsB,EAAE,CAkB1B"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PartitionDateTimePattern = void 0;
4
- var _262_1 = require("../262");
5
- var FormatDateTimePattern_1 = require("./FormatDateTimePattern");
6
- var PartitionPattern_1 = require("../PartitionPattern");
7
- /**
8
- * https://tc39.es/ecma402/#sec-partitiondatetimepattern
9
- * @param dtf
10
- * @param x
11
- */
12
- function PartitionDateTimePattern(dtf, x, implDetails) {
13
- x = _262_1.TimeClip(x);
14
- if (isNaN(x)) {
15
- throw new RangeError('invalid time');
16
- }
17
- /** IMPL START */
18
- var getInternalSlots = implDetails.getInternalSlots;
19
- var internalSlots = getInternalSlots(dtf);
20
- /** IMPL END */
21
- var pattern = internalSlots.pattern;
22
- return FormatDateTimePattern_1.FormatDateTimePattern(dtf, PartitionPattern_1.PartitionPattern(pattern), x, implDetails);
23
- }
24
- exports.PartitionDateTimePattern = PartitionDateTimePattern;
@@ -1,5 +0,0 @@
1
- import { IntlDateTimeFormatPart } from '../types/date-time';
2
- import { ToLocalTimeImplDetails } from './ToLocalTime';
3
- import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
4
- export declare function PartitionDateTimeRangePattern(dtf: Intl.DateTimeFormat, x: number, y: number, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
5
- //# sourceMappingURL=PartitionDateTimeRangePattern.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PartitionDateTimeRangePattern.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/PartitionDateTimeRangePattern.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAIvB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAc,sBAAsB,EAAC,MAAM,eAAe,CAAA;AACjE,OAAO,EAEL,gCAAgC,EACjC,MAAM,yBAAyB,CAAA;AAehC,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,gCAAgC,GAAG,sBAAsB,4BAsHvE"}
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PartitionDateTimeRangePattern = void 0;
4
- var date_time_1 = require("../types/date-time");
5
- var _262_1 = require("../262");
6
- var ToLocalTime_1 = require("./ToLocalTime");
7
- var FormatDateTimePattern_1 = require("./FormatDateTimePattern");
8
- var PartitionPattern_1 = require("../PartitionPattern");
9
- var TABLE_2_FIELDS = [
10
- 'era',
11
- 'year',
12
- 'month',
13
- 'day',
14
- 'ampm',
15
- 'hour',
16
- 'minute',
17
- 'second',
18
- 'fractionalSecondDigits',
19
- ];
20
- function PartitionDateTimeRangePattern(dtf, x, y, implDetails) {
21
- x = _262_1.TimeClip(x);
22
- if (isNaN(x)) {
23
- throw new RangeError('Invalid start time');
24
- }
25
- y = _262_1.TimeClip(y);
26
- if (isNaN(y)) {
27
- throw new RangeError('Invalid end time');
28
- }
29
- /** IMPL START */
30
- var getInternalSlots = implDetails.getInternalSlots, tzData = implDetails.tzData;
31
- var internalSlots = getInternalSlots(dtf);
32
- /** IMPL END */
33
- var tm1 = ToLocalTime_1.ToLocalTime(x,
34
- // @ts-ignore
35
- internalSlots.calendar, internalSlots.timeZone, { tzData: tzData });
36
- var tm2 = ToLocalTime_1.ToLocalTime(y,
37
- // @ts-ignore
38
- internalSlots.calendar, internalSlots.timeZone, { tzData: tzData });
39
- var pattern = internalSlots.pattern, rangePatterns = internalSlots.rangePatterns;
40
- var rangePattern;
41
- var dateFieldsPracticallyEqual = true;
42
- var patternContainsLargerDateField = false;
43
- for (var _i = 0, TABLE_2_FIELDS_1 = TABLE_2_FIELDS; _i < TABLE_2_FIELDS_1.length; _i++) {
44
- var fieldName = TABLE_2_FIELDS_1[_i];
45
- if (dateFieldsPracticallyEqual && !patternContainsLargerDateField) {
46
- if (fieldName === 'ampm') {
47
- var rp = rangePatterns.ampm;
48
- if (rangePattern !== undefined && rp === undefined) {
49
- patternContainsLargerDateField = true;
50
- }
51
- else {
52
- var v1 = tm1.hour;
53
- var v2 = tm2.hour;
54
- if ((v1 > 11 && v2 < 11) || (v1 < 11 && v2 > 11)) {
55
- dateFieldsPracticallyEqual = false;
56
- }
57
- rangePattern = rp;
58
- }
59
- }
60
- else if (fieldName === 'fractionalSecondDigits') {
61
- var fractionalSecondDigits = internalSlots.fractionalSecondDigits;
62
- if (fractionalSecondDigits === undefined) {
63
- fractionalSecondDigits = 3;
64
- }
65
- var v1 = Math.floor(tm1.millisecond * Math.pow(10, (fractionalSecondDigits - 3)));
66
- var v2 = Math.floor(tm2.millisecond * Math.pow(10, (fractionalSecondDigits - 3)));
67
- if (v1 !== v2) {
68
- dateFieldsPracticallyEqual = false;
69
- }
70
- }
71
- else {
72
- var rp = rangePatterns[fieldName];
73
- if (rangePattern !== undefined && rp === undefined) {
74
- patternContainsLargerDateField = true;
75
- }
76
- else {
77
- var v1 = tm1[fieldName];
78
- var v2 = tm2[fieldName];
79
- if (!_262_1.SameValue(v1, v2)) {
80
- dateFieldsPracticallyEqual = false;
81
- }
82
- rangePattern = rp;
83
- }
84
- }
85
- }
86
- }
87
- if (dateFieldsPracticallyEqual) {
88
- var result_2 = FormatDateTimePattern_1.FormatDateTimePattern(dtf, PartitionPattern_1.PartitionPattern(pattern), x, implDetails);
89
- for (var _a = 0, result_1 = result_2; _a < result_1.length; _a++) {
90
- var r = result_1[_a];
91
- r.source = date_time_1.RangePatternType.shared;
92
- }
93
- return result_2;
94
- }
95
- var result = [];
96
- if (rangePattern === undefined) {
97
- rangePattern = rangePatterns.default;
98
- /** IMPL DETAILS */
99
- // Now we have to replace {0} & {1} with actual pattern
100
- for (var _b = 0, _c = rangePattern.patternParts; _b < _c.length; _b++) {
101
- var patternPart = _c[_b];
102
- if (patternPart.pattern === '{0}' || patternPart.pattern === '{1}') {
103
- patternPart.pattern = pattern;
104
- }
105
- }
106
- }
107
- for (var _d = 0, _e = rangePattern.patternParts; _d < _e.length; _d++) {
108
- var rangePatternPart = _e[_d];
109
- var source = rangePatternPart.source, pattern_1 = rangePatternPart.pattern;
110
- var z = void 0;
111
- if (source === date_time_1.RangePatternType.startRange ||
112
- source === date_time_1.RangePatternType.shared) {
113
- z = x;
114
- }
115
- else {
116
- z = y;
117
- }
118
- var patternParts = PartitionPattern_1.PartitionPattern(pattern_1);
119
- var partResult = FormatDateTimePattern_1.FormatDateTimePattern(dtf, patternParts, z, implDetails);
120
- for (var _f = 0, partResult_1 = partResult; _f < partResult_1.length; _f++) {
121
- var r = partResult_1[_f];
122
- r.source = source;
123
- }
124
- result = result.concat(partResult);
125
- }
126
- return result;
127
- }
128
- exports.PartitionDateTimeRangePattern = PartitionDateTimeRangePattern;
@@ -1,9 +0,0 @@
1
- import { DateTimeFormatOptions } from '../types/date-time';
2
- /**
3
- * https://tc39.es/ecma402/#sec-todatetimeoptions
4
- * @param options
5
- * @param required
6
- * @param defaults
7
- */
8
- export declare function ToDateTimeOptions(options?: DateTimeFormatOptions | null, required?: string, defaults?: string): DateTimeFormatOptions;
9
- //# sourceMappingURL=ToDateTimeOptions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ToDateTimeOptions.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/ToDateTimeOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAA;AAGxD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI,EACtC,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,GAChB,qBAAqB,CAkEvB"}
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToDateTimeOptions = void 0;
4
- var _262_1 = require("../262");
5
- /**
6
- * https://tc39.es/ecma402/#sec-todatetimeoptions
7
- * @param options
8
- * @param required
9
- * @param defaults
10
- */
11
- function ToDateTimeOptions(options, required, defaults) {
12
- if (options === undefined) {
13
- options = null;
14
- }
15
- else {
16
- options = _262_1.ToObject(options);
17
- }
18
- options = Object.create(options);
19
- var needDefaults = true;
20
- if (required === 'date' || required === 'any') {
21
- for (var _i = 0, _a = ['weekday', 'year', 'month', 'day']; _i < _a.length; _i++) {
22
- var prop = _a[_i];
23
- var value = options[prop];
24
- if (value !== undefined) {
25
- needDefaults = false;
26
- }
27
- }
28
- }
29
- if (required === 'time' || required === 'any') {
30
- for (var _b = 0, _c = [
31
- 'dayPeriod',
32
- 'hour',
33
- 'minute',
34
- 'second',
35
- 'fractionalSecondDigits',
36
- ]; _b < _c.length; _b++) {
37
- var prop = _c[_b];
38
- var value = options[prop];
39
- if (value !== undefined) {
40
- needDefaults = false;
41
- }
42
- }
43
- }
44
- if (options.dateStyle !== undefined || options.timeStyle !== undefined) {
45
- needDefaults = false;
46
- }
47
- if (required === 'date' && options.timeStyle) {
48
- throw new TypeError('Intl.DateTimeFormat date was required but timeStyle was included');
49
- }
50
- if (required === 'time' && options.dateStyle) {
51
- throw new TypeError('Intl.DateTimeFormat time was required but dateStyle was included');
52
- }
53
- if (needDefaults && (defaults === 'date' || defaults === 'all')) {
54
- for (var _d = 0, _e = ['year', 'month', 'day']; _d < _e.length; _d++) {
55
- var prop = _e[_d];
56
- options[prop] = 'numeric';
57
- }
58
- }
59
- if (needDefaults && (defaults === 'time' || defaults === 'all')) {
60
- for (var _f = 0, _g = ['hour', 'minute', 'second']; _f < _g.length; _f++) {
61
- var prop = _g[_f];
62
- options[prop] = 'numeric';
63
- }
64
- }
65
- return options;
66
- }
67
- exports.ToDateTimeOptions = ToDateTimeOptions;
@@ -1,26 +0,0 @@
1
- import { UnpackedZoneData } from '../types/date-time';
2
- export interface ToLocalTimeImplDetails {
3
- tzData: Record<string, UnpackedZoneData[]>;
4
- }
5
- /**
6
- * https://tc39.es/ecma402/#sec-tolocaltime
7
- * @param t
8
- * @param calendar
9
- * @param timeZone
10
- */
11
- export declare function ToLocalTime(t: number, calendar: string, timeZone: string, { tzData }: ToLocalTimeImplDetails): {
12
- weekday: number;
13
- era: string;
14
- year: number;
15
- relatedYear: undefined;
16
- yearName: undefined;
17
- month: number;
18
- day: number;
19
- hour: number;
20
- minute: number;
21
- second: number;
22
- millisecond: number;
23
- inDST: boolean;
24
- timeZoneOffset: number;
25
- };
26
- //# sourceMappingURL=ToLocalTime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ToLocalTime.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/ToLocalTime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAmCnD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAA;CAC3C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,EAAC,MAAM,EAAC,EAAE,sBAAsB,GAC/B;IACD,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,SAAS,CAAA;IACtB,QAAQ,EAAE,SAAS,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;CACvB,CA0BA"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToLocalTime = void 0;
4
- var utils_1 = require("../utils");
5
- var _262_1 = require("../262");
6
- function getApplicableZoneData(t, timeZone, tzData) {
7
- var _a;
8
- var zoneData = tzData[timeZone];
9
- // We don't have data for this so just say it's UTC
10
- if (!zoneData) {
11
- return [0, false];
12
- }
13
- var i = 0;
14
- var offset = 0;
15
- var dst = false;
16
- for (; i <= zoneData.length; i++) {
17
- if (i === zoneData.length || zoneData[i][0] * 1e3 > t) {
18
- ;
19
- _a = zoneData[i - 1], offset = _a[2], dst = _a[3];
20
- break;
21
- }
22
- }
23
- return [offset * 1e3, dst];
24
- }
25
- /**
26
- * https://tc39.es/ecma402/#sec-tolocaltime
27
- * @param t
28
- * @param calendar
29
- * @param timeZone
30
- */
31
- function ToLocalTime(t, calendar, timeZone, _a) {
32
- var tzData = _a.tzData;
33
- utils_1.invariant(_262_1.Type(t) === 'Number', 'invalid time');
34
- utils_1.invariant(calendar === 'gregory', 'We only support Gregory calendar right now');
35
- var _b = getApplicableZoneData(t, timeZone, tzData), timeZoneOffset = _b[0], inDST = _b[1];
36
- var tz = t + timeZoneOffset;
37
- var year = _262_1.YearFromTime(tz);
38
- return {
39
- weekday: _262_1.WeekDay(tz),
40
- era: year < 0 ? 'BC' : 'AD',
41
- year: year,
42
- relatedYear: undefined,
43
- yearName: undefined,
44
- month: _262_1.MonthFromTime(tz),
45
- day: _262_1.DateFromTime(tz),
46
- hour: _262_1.HourFromTime(tz),
47
- minute: _262_1.MinFromTime(tz),
48
- second: _262_1.SecFromTime(tz),
49
- millisecond: _262_1.msFromTime(tz),
50
- inDST: inDST,
51
- // IMPORTANT: Not in spec
52
- timeZoneOffset: timeZoneOffset,
53
- };
54
- }
55
- exports.ToLocalTime = ToLocalTime;
@@ -1,14 +0,0 @@
1
- import { DateTimeFormatOptions, Formats, RangePatternPart } from '../types/date-time';
2
- export declare function processDateTimePattern(pattern: string, result?: Pick<DateTimeFormatOptions, 'weekday' | 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'timeZoneName'> & {
3
- hour12?: boolean;
4
- }): [string, string];
5
- /**
6
- * Parse Date time skeleton into Intl.DateTimeFormatOptions
7
- * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
8
- * @public
9
- * @param skeleton skeleton string
10
- */
11
- export declare function parseDateTimeSkeleton(skeleton: string, rawPattern?: string, rangePatterns?: Record<string, string>, intervalFormatFallback?: string): Formats;
12
- export declare function splitFallbackRangePattern(pattern: string): Array<RangePatternPart>;
13
- export declare function splitRangePattern(pattern: string): Array<RangePatternPart>;
14
- //# sourceMappingURL=skeleton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/skeleton.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,gBAAgB,EAIjB,MAAM,oBAAoB,CAAA;AAkN3B,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,IAAI,CACX,qBAAqB,EACnB,SAAS,GACT,KAAK,GACL,MAAM,GACN,OAAO,GACP,KAAK,GACL,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,cAAc,CACjB,GAAG;IACF,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GACA,CAAC,MAAM,EAAE,MAAM,CAAC,CA8BlB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,UAAU,GAAE,MAAiB,EAC7B,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CA+CT;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,GACd,KAAK,CAAC,gBAAgB,CAAC,CAqBzB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAgC1E"}