@formatjs/ecma402-abstract 1.8.0 → 1.9.3

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 (167) 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/index.d.ts +1 -23
  5. package/index.d.ts.map +1 -1
  6. package/index.js +13 -38
  7. package/lib/IsValidTimeZoneName.d.ts +1 -1
  8. package/lib/IsValidTimeZoneName.d.ts.map +1 -1
  9. package/lib/IsValidTimeZoneName.js +6 -1
  10. package/lib/index.d.ts +1 -23
  11. package/lib/index.d.ts.map +1 -1
  12. package/lib/index.js +1 -23
  13. package/lib/types/date-time.d.ts +2 -1
  14. package/lib/types/date-time.d.ts.map +1 -1
  15. package/package.json +1 -1
  16. package/types/date-time.d.ts +2 -1
  17. package/types/date-time.d.ts.map +1 -1
  18. package/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
  19. package/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
  20. package/DateTimeFormat/BasicFormatMatcher.js +0 -61
  21. package/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
  22. package/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
  23. package/DateTimeFormat/BestFitFormatMatcher.js +0 -121
  24. package/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
  25. package/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
  26. package/DateTimeFormat/DateTimeStyleFormat.js +0 -54
  27. package/DateTimeFormat/FormatDateTime.d.ts +0 -8
  28. package/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
  29. package/DateTimeFormat/FormatDateTime.js +0 -19
  30. package/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
  31. package/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
  32. package/DateTimeFormat/FormatDateTimePattern.js +0 -182
  33. package/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
  34. package/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
  35. package/DateTimeFormat/FormatDateTimeRange.js +0 -14
  36. package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
  37. package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
  38. package/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -18
  39. package/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
  40. package/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
  41. package/DateTimeFormat/FormatDateTimeToParts.js +0 -25
  42. package/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
  43. package/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
  44. package/DateTimeFormat/InitializeDateTimeFormat.js +0 -188
  45. package/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
  46. package/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
  47. package/DateTimeFormat/PartitionDateTimePattern.js +0 -24
  48. package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
  49. package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
  50. package/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -128
  51. package/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
  52. package/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
  53. package/DateTimeFormat/ToDateTimeOptions.js +0 -67
  54. package/DateTimeFormat/ToLocalTime.d.ts +0 -26
  55. package/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
  56. package/DateTimeFormat/ToLocalTime.js +0 -55
  57. package/DateTimeFormat/skeleton.d.ts +0 -14
  58. package/DateTimeFormat/skeleton.d.ts.map +0 -1
  59. package/DateTimeFormat/skeleton.js +0 -301
  60. package/DateTimeFormat/utils.d.ts +0 -10
  61. package/DateTimeFormat/utils.d.ts.map +0 -1
  62. package/DateTimeFormat/utils.js +0 -21
  63. package/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
  64. package/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
  65. package/DisplayNames/CanonicalCodeForDisplayNames.js +0 -37
  66. package/PluralRules/GetOperands.d.ts +0 -32
  67. package/PluralRules/GetOperands.d.ts.map +0 -1
  68. package/PluralRules/GetOperands.js +0 -51
  69. package/PluralRules/InitializePluralRules.d.ts +0 -9
  70. package/PluralRules/InitializePluralRules.d.ts.map +0 -1
  71. package/PluralRules/InitializePluralRules.js +0 -24
  72. package/PluralRules/ResolvePlural.d.ts +0 -13
  73. package/PluralRules/ResolvePlural.d.ts.map +0 -1
  74. package/PluralRules/ResolvePlural.js +0 -29
  75. package/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
  76. package/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
  77. package/RelativeTimeFormat/FormatRelativeTime.js +0 -14
  78. package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
  79. package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
  80. package/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -22
  81. package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
  82. package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
  83. package/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -41
  84. package/RelativeTimeFormat/MakePartsList.d.ts +0 -2
  85. package/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
  86. package/RelativeTimeFormat/MakePartsList.js +0 -31
  87. package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
  88. package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
  89. package/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -58
  90. package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
  91. package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
  92. package/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -40
  93. package/lib/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
  94. package/lib/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
  95. package/lib/DateTimeFormat/BasicFormatMatcher.js +0 -57
  96. package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
  97. package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
  98. package/lib/DateTimeFormat/BestFitFormatMatcher.js +0 -116
  99. package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
  100. package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
  101. package/lib/DateTimeFormat/DateTimeStyleFormat.js +0 -50
  102. package/lib/DateTimeFormat/FormatDateTime.d.ts +0 -8
  103. package/lib/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
  104. package/lib/DateTimeFormat/FormatDateTime.js +0 -15
  105. package/lib/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
  106. package/lib/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
  107. package/lib/DateTimeFormat/FormatDateTimePattern.js +0 -178
  108. package/lib/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
  109. package/lib/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
  110. package/lib/DateTimeFormat/FormatDateTimeRange.js +0 -10
  111. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
  112. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
  113. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -14
  114. package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
  115. package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
  116. package/lib/DateTimeFormat/FormatDateTimeToParts.js +0 -21
  117. package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
  118. package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
  119. package/lib/DateTimeFormat/InitializeDateTimeFormat.js +0 -184
  120. package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
  121. package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
  122. package/lib/DateTimeFormat/PartitionDateTimePattern.js +0 -20
  123. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
  124. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
  125. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -124
  126. package/lib/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
  127. package/lib/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
  128. package/lib/DateTimeFormat/ToDateTimeOptions.js +0 -63
  129. package/lib/DateTimeFormat/ToLocalTime.d.ts +0 -26
  130. package/lib/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
  131. package/lib/DateTimeFormat/ToLocalTime.js +0 -51
  132. package/lib/DateTimeFormat/skeleton.d.ts +0 -14
  133. package/lib/DateTimeFormat/skeleton.d.ts.map +0 -1
  134. package/lib/DateTimeFormat/skeleton.js +0 -294
  135. package/lib/DateTimeFormat/utils.d.ts +0 -10
  136. package/lib/DateTimeFormat/utils.d.ts.map +0 -1
  137. package/lib/DateTimeFormat/utils.js +0 -18
  138. package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
  139. package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
  140. package/lib/DisplayNames/CanonicalCodeForDisplayNames.js +0 -33
  141. package/lib/PluralRules/GetOperands.d.ts +0 -32
  142. package/lib/PluralRules/GetOperands.d.ts.map +0 -1
  143. package/lib/PluralRules/GetOperands.js +0 -47
  144. package/lib/PluralRules/InitializePluralRules.d.ts +0 -9
  145. package/lib/PluralRules/InitializePluralRules.d.ts.map +0 -1
  146. package/lib/PluralRules/InitializePluralRules.js +0 -20
  147. package/lib/PluralRules/ResolvePlural.d.ts +0 -13
  148. package/lib/PluralRules/ResolvePlural.d.ts.map +0 -1
  149. package/lib/PluralRules/ResolvePlural.js +0 -25
  150. package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
  151. package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
  152. package/lib/RelativeTimeFormat/FormatRelativeTime.js +0 -10
  153. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
  154. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
  155. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -18
  156. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
  157. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
  158. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -37
  159. package/lib/RelativeTimeFormat/MakePartsList.d.ts +0 -2
  160. package/lib/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
  161. package/lib/RelativeTimeFormat/MakePartsList.js +0 -27
  162. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
  163. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
  164. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -54
  165. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
  166. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
  167. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -36
@@ -1,184 +0,0 @@
1
- import { CanonicalizeLocaleList } from '../CanonicalizeLocaleList';
2
- import { ToDateTimeOptions } from './ToDateTimeOptions';
3
- import { GetOption } from '../GetOption';
4
- import { ResolveLocale } from '../ResolveLocale';
5
- import { IsValidTimeZoneName } from '../IsValidTimeZoneName';
6
- import { CanonicalizeTimeZoneName } from '../CanonicalizeTimeZoneName';
7
- import { BasicFormatMatcher } from './BasicFormatMatcher';
8
- import { BestFitFormatMatcher } from './BestFitFormatMatcher';
9
- import { invariant } from '../utils';
10
- import { DATE_TIME_PROPS } from './utils';
11
- import { DateTimeStyleFormat } from './DateTimeStyleFormat';
12
- import { GetNumberOption } from '../GetNumberOption';
13
- function isTimeRelated(opt) {
14
- for (var _i = 0, _a = ['hour', 'minute', 'second']; _i < _a.length; _i++) {
15
- var prop = _a[_i];
16
- var value = opt[prop];
17
- if (value !== undefined) {
18
- return true;
19
- }
20
- }
21
- return false;
22
- }
23
- function resolveHourCycle(hc, hcDefault, hour12) {
24
- if (hc == null) {
25
- hc = hcDefault;
26
- }
27
- if (hour12 !== undefined) {
28
- if (hour12) {
29
- if (hcDefault === 'h11' || hcDefault === 'h23') {
30
- hc = 'h11';
31
- }
32
- else {
33
- hc = 'h12';
34
- }
35
- }
36
- else {
37
- invariant(!hour12, 'hour12 must not be set');
38
- if (hcDefault === 'h11' || hcDefault === 'h23') {
39
- hc = 'h23';
40
- }
41
- else {
42
- hc = 'h24';
43
- }
44
- }
45
- }
46
- return hc;
47
- }
48
- var TYPE_REGEX = /^[a-z0-9]{3,8}$/i;
49
- /**
50
- * https://tc39.es/ecma402/#sec-initializedatetimeformat
51
- * @param dtf DateTimeFormat
52
- * @param locales locales
53
- * @param opts options
54
- */
55
- export function InitializeDateTimeFormat(dtf, locales, opts, _a) {
56
- 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;
57
- // @ts-ignore
58
- var requestedLocales = CanonicalizeLocaleList(locales);
59
- var options = ToDateTimeOptions(opts, 'any', 'date');
60
- var opt = Object.create(null);
61
- var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
62
- opt.localeMatcher = matcher;
63
- var calendar = GetOption(options, 'calendar', 'string', undefined, undefined);
64
- if (calendar !== undefined && !TYPE_REGEX.test(calendar)) {
65
- throw new RangeError('Malformed calendar');
66
- }
67
- var internalSlots = getInternalSlots(dtf);
68
- opt.ca = calendar;
69
- var numberingSystem = GetOption(options, 'numberingSystem', 'string', undefined, undefined);
70
- if (numberingSystem !== undefined && !TYPE_REGEX.test(numberingSystem)) {
71
- throw new RangeError('Malformed numbering system');
72
- }
73
- opt.nu = numberingSystem;
74
- var hour12 = GetOption(options, 'hour12', 'boolean', undefined, undefined);
75
- var hourCycle = GetOption(options, 'hourCycle', 'string', ['h11', 'h12', 'h23', 'h24'], undefined);
76
- if (hour12 !== undefined) {
77
- // @ts-ignore
78
- hourCycle = null;
79
- }
80
- opt.hc = hourCycle;
81
- var r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
82
- internalSlots.locale = r.locale;
83
- calendar = r.ca;
84
- internalSlots.calendar = calendar;
85
- internalSlots.hourCycle = r.hc;
86
- internalSlots.numberingSystem = r.nu;
87
- var dataLocale = r.dataLocale;
88
- internalSlots.dataLocale = dataLocale;
89
- var timeZone = options.timeZone;
90
- if (timeZone !== undefined) {
91
- timeZone = String(timeZone);
92
- if (!IsValidTimeZoneName(timeZone, { tzData: tzData, uppercaseLinks: uppercaseLinks })) {
93
- throw new RangeError('Invalid timeZoneName');
94
- }
95
- timeZone = CanonicalizeTimeZoneName(timeZone, { tzData: tzData, uppercaseLinks: uppercaseLinks });
96
- }
97
- else {
98
- timeZone = getDefaultTimeZone();
99
- }
100
- internalSlots.timeZone = timeZone;
101
- opt = Object.create(null);
102
- opt.weekday = GetOption(options, 'weekday', 'string', ['narrow', 'short', 'long'], undefined);
103
- opt.era = GetOption(options, 'era', 'string', ['narrow', 'short', 'long'], undefined);
104
- opt.year = GetOption(options, 'year', 'string', ['2-digit', 'numeric'], undefined);
105
- opt.month = GetOption(options, 'month', 'string', ['2-digit', 'numeric', 'narrow', 'short', 'long'], undefined);
106
- opt.day = GetOption(options, 'day', 'string', ['2-digit', 'numeric'], undefined);
107
- opt.hour = GetOption(options, 'hour', 'string', ['2-digit', 'numeric'], undefined);
108
- opt.minute = GetOption(options, 'minute', 'string', ['2-digit', 'numeric'], undefined);
109
- opt.second = GetOption(options, 'second', 'string', ['2-digit', 'numeric'], undefined);
110
- opt.timeZoneName = GetOption(options, 'timeZoneName', 'string', ['short', 'long'], undefined);
111
- opt.fractionalSecondDigits = GetNumberOption(options, 'fractionalSecondDigits', 1, 3,
112
- // @ts-expect-error
113
- undefined);
114
- var dataLocaleData = localeData[dataLocale];
115
- invariant(!!dataLocaleData, "Missing locale data for " + dataLocale);
116
- var formats = dataLocaleData.formats[calendar];
117
- // UNSPECCED: IMPLEMENTATION DETAILS
118
- if (!formats) {
119
- throw new RangeError("Calendar \"" + calendar + "\" is not supported. Try setting \"calendar\" to 1 of the following: " + Object.keys(dataLocaleData.formats).join(', '));
120
- }
121
- var formatMatcher = GetOption(options, 'formatMatcher', 'string', ['basic', 'best fit'], 'best fit');
122
- var dateStyle = GetOption(options, 'dateStyle', 'string', ['full', 'long', 'medium', 'short'], undefined);
123
- internalSlots.dateStyle = dateStyle;
124
- var timeStyle = GetOption(options, 'timeStyle', 'string', ['full', 'long', 'medium', 'short'], undefined);
125
- internalSlots.timeStyle = timeStyle;
126
- var bestFormat;
127
- if (dateStyle === undefined && timeStyle === undefined) {
128
- if (formatMatcher === 'basic') {
129
- bestFormat = BasicFormatMatcher(opt, formats);
130
- }
131
- else {
132
- // IMPL DETAILS START
133
- if (isTimeRelated(opt)) {
134
- var hc = resolveHourCycle(internalSlots.hourCycle, dataLocaleData.hourCycle, hour12);
135
- opt.hour12 = hc === 'h11' || hc === 'h12';
136
- }
137
- // IMPL DETAILS END
138
- bestFormat = BestFitFormatMatcher(opt, formats);
139
- }
140
- }
141
- else {
142
- for (var _i = 0, DATE_TIME_PROPS_1 = DATE_TIME_PROPS; _i < DATE_TIME_PROPS_1.length; _i++) {
143
- var prop = DATE_TIME_PROPS_1[_i];
144
- var p = opt[prop];
145
- if (p !== undefined) {
146
- throw new TypeError("Intl.DateTimeFormat can't set option " + prop + " when " + (dateStyle ? 'dateStyle' : 'timeStyle') + " is used");
147
- }
148
- }
149
- bestFormat = DateTimeStyleFormat(dateStyle, timeStyle, dataLocaleData);
150
- }
151
- // IMPL DETAIL START
152
- // For debugging
153
- internalSlots.format = bestFormat;
154
- // IMPL DETAIL END
155
- for (var prop in opt) {
156
- var p = bestFormat[prop];
157
- if (p !== undefined) {
158
- internalSlots[prop] = p;
159
- }
160
- }
161
- var pattern;
162
- var rangePatterns;
163
- if (internalSlots.hour !== undefined) {
164
- var hc = resolveHourCycle(internalSlots.hourCycle, dataLocaleData.hourCycle, hour12);
165
- internalSlots.hourCycle = hc;
166
- if (hc === 'h11' || hc === 'h12') {
167
- pattern = bestFormat.pattern12;
168
- rangePatterns = bestFormat.rangePatterns12;
169
- }
170
- else {
171
- pattern = bestFormat.pattern;
172
- rangePatterns = bestFormat.rangePatterns;
173
- }
174
- }
175
- else {
176
- // @ts-ignore
177
- internalSlots.hourCycle = undefined;
178
- pattern = bestFormat.pattern;
179
- rangePatterns = bestFormat.rangePatterns;
180
- }
181
- internalSlots.pattern = pattern;
182
- internalSlots.rangePatterns = rangePatterns;
183
- return dtf;
184
- }
@@ -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,20 +0,0 @@
1
- import { TimeClip } from '../262';
2
- import { FormatDateTimePattern, } from './FormatDateTimePattern';
3
- import { PartitionPattern } from '../PartitionPattern';
4
- /**
5
- * https://tc39.es/ecma402/#sec-partitiondatetimepattern
6
- * @param dtf
7
- * @param x
8
- */
9
- export function PartitionDateTimePattern(dtf, x, implDetails) {
10
- x = TimeClip(x);
11
- if (isNaN(x)) {
12
- throw new RangeError('invalid time');
13
- }
14
- /** IMPL START */
15
- var getInternalSlots = implDetails.getInternalSlots;
16
- var internalSlots = getInternalSlots(dtf);
17
- /** IMPL END */
18
- var pattern = internalSlots.pattern;
19
- return FormatDateTimePattern(dtf, PartitionPattern(pattern), x, implDetails);
20
- }
@@ -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,124 +0,0 @@
1
- import { RangePatternType, } from '../types/date-time';
2
- import { SameValue, TimeClip } from '../262';
3
- import { ToLocalTime } from './ToLocalTime';
4
- import { FormatDateTimePattern, } from './FormatDateTimePattern';
5
- import { PartitionPattern } from '../PartitionPattern';
6
- var TABLE_2_FIELDS = [
7
- 'era',
8
- 'year',
9
- 'month',
10
- 'day',
11
- 'ampm',
12
- 'hour',
13
- 'minute',
14
- 'second',
15
- 'fractionalSecondDigits',
16
- ];
17
- export function PartitionDateTimeRangePattern(dtf, x, y, implDetails) {
18
- x = TimeClip(x);
19
- if (isNaN(x)) {
20
- throw new RangeError('Invalid start time');
21
- }
22
- y = TimeClip(y);
23
- if (isNaN(y)) {
24
- throw new RangeError('Invalid end time');
25
- }
26
- /** IMPL START */
27
- var getInternalSlots = implDetails.getInternalSlots, tzData = implDetails.tzData;
28
- var internalSlots = getInternalSlots(dtf);
29
- /** IMPL END */
30
- var tm1 = ToLocalTime(x,
31
- // @ts-ignore
32
- internalSlots.calendar, internalSlots.timeZone, { tzData: tzData });
33
- var tm2 = ToLocalTime(y,
34
- // @ts-ignore
35
- internalSlots.calendar, internalSlots.timeZone, { tzData: tzData });
36
- var pattern = internalSlots.pattern, rangePatterns = internalSlots.rangePatterns;
37
- var rangePattern;
38
- var dateFieldsPracticallyEqual = true;
39
- var patternContainsLargerDateField = false;
40
- for (var _i = 0, TABLE_2_FIELDS_1 = TABLE_2_FIELDS; _i < TABLE_2_FIELDS_1.length; _i++) {
41
- var fieldName = TABLE_2_FIELDS_1[_i];
42
- if (dateFieldsPracticallyEqual && !patternContainsLargerDateField) {
43
- if (fieldName === 'ampm') {
44
- var rp = rangePatterns.ampm;
45
- if (rangePattern !== undefined && rp === undefined) {
46
- patternContainsLargerDateField = true;
47
- }
48
- else {
49
- var v1 = tm1.hour;
50
- var v2 = tm2.hour;
51
- if ((v1 > 11 && v2 < 11) || (v1 < 11 && v2 > 11)) {
52
- dateFieldsPracticallyEqual = false;
53
- }
54
- rangePattern = rp;
55
- }
56
- }
57
- else if (fieldName === 'fractionalSecondDigits') {
58
- var fractionalSecondDigits = internalSlots.fractionalSecondDigits;
59
- if (fractionalSecondDigits === undefined) {
60
- fractionalSecondDigits = 3;
61
- }
62
- var v1 = Math.floor(tm1.millisecond * Math.pow(10, (fractionalSecondDigits - 3)));
63
- var v2 = Math.floor(tm2.millisecond * Math.pow(10, (fractionalSecondDigits - 3)));
64
- if (v1 !== v2) {
65
- dateFieldsPracticallyEqual = false;
66
- }
67
- }
68
- else {
69
- var rp = rangePatterns[fieldName];
70
- if (rangePattern !== undefined && rp === undefined) {
71
- patternContainsLargerDateField = true;
72
- }
73
- else {
74
- var v1 = tm1[fieldName];
75
- var v2 = tm2[fieldName];
76
- if (!SameValue(v1, v2)) {
77
- dateFieldsPracticallyEqual = false;
78
- }
79
- rangePattern = rp;
80
- }
81
- }
82
- }
83
- }
84
- if (dateFieldsPracticallyEqual) {
85
- var result_2 = FormatDateTimePattern(dtf, PartitionPattern(pattern), x, implDetails);
86
- for (var _a = 0, result_1 = result_2; _a < result_1.length; _a++) {
87
- var r = result_1[_a];
88
- r.source = RangePatternType.shared;
89
- }
90
- return result_2;
91
- }
92
- var result = [];
93
- if (rangePattern === undefined) {
94
- rangePattern = rangePatterns.default;
95
- /** IMPL DETAILS */
96
- // Now we have to replace {0} & {1} with actual pattern
97
- for (var _b = 0, _c = rangePattern.patternParts; _b < _c.length; _b++) {
98
- var patternPart = _c[_b];
99
- if (patternPart.pattern === '{0}' || patternPart.pattern === '{1}') {
100
- patternPart.pattern = pattern;
101
- }
102
- }
103
- }
104
- for (var _d = 0, _e = rangePattern.patternParts; _d < _e.length; _d++) {
105
- var rangePatternPart = _e[_d];
106
- var source = rangePatternPart.source, pattern_1 = rangePatternPart.pattern;
107
- var z = void 0;
108
- if (source === RangePatternType.startRange ||
109
- source === RangePatternType.shared) {
110
- z = x;
111
- }
112
- else {
113
- z = y;
114
- }
115
- var patternParts = PartitionPattern(pattern_1);
116
- var partResult = FormatDateTimePattern(dtf, patternParts, z, implDetails);
117
- for (var _f = 0, partResult_1 = partResult; _f < partResult_1.length; _f++) {
118
- var r = partResult_1[_f];
119
- r.source = source;
120
- }
121
- result = result.concat(partResult);
122
- }
123
- return result;
124
- }
@@ -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,63 +0,0 @@
1
- import { ToObject } from '../262';
2
- /**
3
- * https://tc39.es/ecma402/#sec-todatetimeoptions
4
- * @param options
5
- * @param required
6
- * @param defaults
7
- */
8
- export function ToDateTimeOptions(options, required, defaults) {
9
- if (options === undefined) {
10
- options = null;
11
- }
12
- else {
13
- options = ToObject(options);
14
- }
15
- options = Object.create(options);
16
- var needDefaults = true;
17
- if (required === 'date' || required === 'any') {
18
- for (var _i = 0, _a = ['weekday', 'year', 'month', 'day']; _i < _a.length; _i++) {
19
- var prop = _a[_i];
20
- var value = options[prop];
21
- if (value !== undefined) {
22
- needDefaults = false;
23
- }
24
- }
25
- }
26
- if (required === 'time' || required === 'any') {
27
- for (var _b = 0, _c = [
28
- 'dayPeriod',
29
- 'hour',
30
- 'minute',
31
- 'second',
32
- 'fractionalSecondDigits',
33
- ]; _b < _c.length; _b++) {
34
- var prop = _c[_b];
35
- var value = options[prop];
36
- if (value !== undefined) {
37
- needDefaults = false;
38
- }
39
- }
40
- }
41
- if (options.dateStyle !== undefined || options.timeStyle !== undefined) {
42
- needDefaults = false;
43
- }
44
- if (required === 'date' && options.timeStyle) {
45
- throw new TypeError('Intl.DateTimeFormat date was required but timeStyle was included');
46
- }
47
- if (required === 'time' && options.dateStyle) {
48
- throw new TypeError('Intl.DateTimeFormat time was required but dateStyle was included');
49
- }
50
- if (needDefaults && (defaults === 'date' || defaults === 'all')) {
51
- for (var _d = 0, _e = ['year', 'month', 'day']; _d < _e.length; _d++) {
52
- var prop = _e[_d];
53
- options[prop] = 'numeric';
54
- }
55
- }
56
- if (needDefaults && (defaults === 'time' || defaults === 'all')) {
57
- for (var _f = 0, _g = ['hour', 'minute', 'second']; _f < _g.length; _f++) {
58
- var prop = _g[_f];
59
- options[prop] = 'numeric';
60
- }
61
- }
62
- return options;
63
- }
@@ -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,51 +0,0 @@
1
- import { invariant } from '../utils';
2
- import { Type, YearFromTime, WeekDay, MonthFromTime, DateFromTime, HourFromTime, MinFromTime, SecFromTime, msFromTime, } from '../262';
3
- function getApplicableZoneData(t, timeZone, tzData) {
4
- var _a;
5
- var zoneData = tzData[timeZone];
6
- // We don't have data for this so just say it's UTC
7
- if (!zoneData) {
8
- return [0, false];
9
- }
10
- var i = 0;
11
- var offset = 0;
12
- var dst = false;
13
- for (; i <= zoneData.length; i++) {
14
- if (i === zoneData.length || zoneData[i][0] * 1e3 > t) {
15
- ;
16
- _a = zoneData[i - 1], offset = _a[2], dst = _a[3];
17
- break;
18
- }
19
- }
20
- return [offset * 1e3, dst];
21
- }
22
- /**
23
- * https://tc39.es/ecma402/#sec-tolocaltime
24
- * @param t
25
- * @param calendar
26
- * @param timeZone
27
- */
28
- export function ToLocalTime(t, calendar, timeZone, _a) {
29
- var tzData = _a.tzData;
30
- invariant(Type(t) === 'Number', 'invalid time');
31
- invariant(calendar === 'gregory', 'We only support Gregory calendar right now');
32
- var _b = getApplicableZoneData(t, timeZone, tzData), timeZoneOffset = _b[0], inDST = _b[1];
33
- var tz = t + timeZoneOffset;
34
- var year = YearFromTime(tz);
35
- return {
36
- weekday: WeekDay(tz),
37
- era: year < 0 ? 'BC' : 'AD',
38
- year: year,
39
- relatedYear: undefined,
40
- yearName: undefined,
41
- month: MonthFromTime(tz),
42
- day: DateFromTime(tz),
43
- hour: HourFromTime(tz),
44
- minute: MinFromTime(tz),
45
- second: SecFromTime(tz),
46
- millisecond: msFromTime(tz),
47
- inDST: inDST,
48
- // IMPORTANT: Not in spec
49
- timeZoneOffset: timeZoneOffset,
50
- };
51
- }
@@ -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"}