@formatjs/ecma402-abstract 1.9.1 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/index.d.ts +1 -23
  2. package/index.d.ts.map +1 -1
  3. package/index.js +13 -38
  4. package/lib/index.d.ts +1 -23
  5. package/lib/index.d.ts.map +1 -1
  6. package/lib/index.js +1 -23
  7. package/lib/types/date-time.d.ts +1 -0
  8. package/lib/types/date-time.d.ts.map +1 -1
  9. package/package.json +1 -1
  10. package/types/date-time.d.ts +1 -0
  11. package/types/date-time.d.ts.map +1 -1
  12. package/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
  13. package/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
  14. package/DateTimeFormat/BasicFormatMatcher.js +0 -61
  15. package/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
  16. package/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
  17. package/DateTimeFormat/BestFitFormatMatcher.js +0 -121
  18. package/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
  19. package/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
  20. package/DateTimeFormat/DateTimeStyleFormat.js +0 -54
  21. package/DateTimeFormat/FormatDateTime.d.ts +0 -8
  22. package/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
  23. package/DateTimeFormat/FormatDateTime.js +0 -19
  24. package/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
  25. package/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
  26. package/DateTimeFormat/FormatDateTimePattern.js +0 -182
  27. package/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
  28. package/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
  29. package/DateTimeFormat/FormatDateTimeRange.js +0 -14
  30. package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
  31. package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
  32. package/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -18
  33. package/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
  34. package/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
  35. package/DateTimeFormat/FormatDateTimeToParts.js +0 -25
  36. package/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
  37. package/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
  38. package/DateTimeFormat/InitializeDateTimeFormat.js +0 -188
  39. package/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
  40. package/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
  41. package/DateTimeFormat/PartitionDateTimePattern.js +0 -24
  42. package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
  43. package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
  44. package/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -125
  45. package/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
  46. package/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
  47. package/DateTimeFormat/ToDateTimeOptions.js +0 -67
  48. package/DateTimeFormat/ToLocalTime.d.ts +0 -26
  49. package/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
  50. package/DateTimeFormat/ToLocalTime.js +0 -55
  51. package/DateTimeFormat/skeleton.d.ts +0 -14
  52. package/DateTimeFormat/skeleton.d.ts.map +0 -1
  53. package/DateTimeFormat/skeleton.js +0 -301
  54. package/DateTimeFormat/utils.d.ts +0 -10
  55. package/DateTimeFormat/utils.d.ts.map +0 -1
  56. package/DateTimeFormat/utils.js +0 -21
  57. package/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
  58. package/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
  59. package/DisplayNames/CanonicalCodeForDisplayNames.js +0 -37
  60. package/PluralRules/GetOperands.d.ts +0 -32
  61. package/PluralRules/GetOperands.d.ts.map +0 -1
  62. package/PluralRules/GetOperands.js +0 -51
  63. package/PluralRules/InitializePluralRules.d.ts +0 -9
  64. package/PluralRules/InitializePluralRules.d.ts.map +0 -1
  65. package/PluralRules/InitializePluralRules.js +0 -24
  66. package/PluralRules/ResolvePlural.d.ts +0 -13
  67. package/PluralRules/ResolvePlural.d.ts.map +0 -1
  68. package/PluralRules/ResolvePlural.js +0 -29
  69. package/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
  70. package/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
  71. package/RelativeTimeFormat/FormatRelativeTime.js +0 -14
  72. package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
  73. package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
  74. package/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -22
  75. package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
  76. package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
  77. package/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -41
  78. package/RelativeTimeFormat/MakePartsList.d.ts +0 -2
  79. package/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
  80. package/RelativeTimeFormat/MakePartsList.js +0 -31
  81. package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
  82. package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
  83. package/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -58
  84. package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
  85. package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
  86. package/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -40
  87. package/lib/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
  88. package/lib/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
  89. package/lib/DateTimeFormat/BasicFormatMatcher.js +0 -57
  90. package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
  91. package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
  92. package/lib/DateTimeFormat/BestFitFormatMatcher.js +0 -116
  93. package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
  94. package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
  95. package/lib/DateTimeFormat/DateTimeStyleFormat.js +0 -50
  96. package/lib/DateTimeFormat/FormatDateTime.d.ts +0 -8
  97. package/lib/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
  98. package/lib/DateTimeFormat/FormatDateTime.js +0 -15
  99. package/lib/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
  100. package/lib/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
  101. package/lib/DateTimeFormat/FormatDateTimePattern.js +0 -178
  102. package/lib/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
  103. package/lib/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
  104. package/lib/DateTimeFormat/FormatDateTimeRange.js +0 -10
  105. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
  106. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
  107. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -14
  108. package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
  109. package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
  110. package/lib/DateTimeFormat/FormatDateTimeToParts.js +0 -21
  111. package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
  112. package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
  113. package/lib/DateTimeFormat/InitializeDateTimeFormat.js +0 -184
  114. package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
  115. package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
  116. package/lib/DateTimeFormat/PartitionDateTimePattern.js +0 -20
  117. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
  118. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
  119. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -121
  120. package/lib/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
  121. package/lib/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
  122. package/lib/DateTimeFormat/ToDateTimeOptions.js +0 -63
  123. package/lib/DateTimeFormat/ToLocalTime.d.ts +0 -26
  124. package/lib/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
  125. package/lib/DateTimeFormat/ToLocalTime.js +0 -51
  126. package/lib/DateTimeFormat/skeleton.d.ts +0 -14
  127. package/lib/DateTimeFormat/skeleton.d.ts.map +0 -1
  128. package/lib/DateTimeFormat/skeleton.js +0 -294
  129. package/lib/DateTimeFormat/utils.d.ts +0 -10
  130. package/lib/DateTimeFormat/utils.d.ts.map +0 -1
  131. package/lib/DateTimeFormat/utils.js +0 -18
  132. package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
  133. package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
  134. package/lib/DisplayNames/CanonicalCodeForDisplayNames.js +0 -33
  135. package/lib/PluralRules/GetOperands.d.ts +0 -32
  136. package/lib/PluralRules/GetOperands.d.ts.map +0 -1
  137. package/lib/PluralRules/GetOperands.js +0 -47
  138. package/lib/PluralRules/InitializePluralRules.d.ts +0 -9
  139. package/lib/PluralRules/InitializePluralRules.d.ts.map +0 -1
  140. package/lib/PluralRules/InitializePluralRules.js +0 -20
  141. package/lib/PluralRules/ResolvePlural.d.ts +0 -13
  142. package/lib/PluralRules/ResolvePlural.d.ts.map +0 -1
  143. package/lib/PluralRules/ResolvePlural.js +0 -25
  144. package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
  145. package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
  146. package/lib/RelativeTimeFormat/FormatRelativeTime.js +0 -10
  147. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
  148. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
  149. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -18
  150. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
  151. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
  152. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -37
  153. package/lib/RelativeTimeFormat/MakePartsList.d.ts +0 -2
  154. package/lib/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
  155. package/lib/RelativeTimeFormat/MakePartsList.js +0 -27
  156. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
  157. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
  158. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -54
  159. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
  160. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
  161. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -36
@@ -1,14 +0,0 @@
1
- import { IntlDateTimeFormatInternal, DateTimeFormatLocaleInternalData, IntlDateTimeFormatPart } from '../types/date-time';
2
- import { ToLocalTimeImplDetails } from './ToLocalTime';
3
- export interface FormatDateTimePatternImplDetails {
4
- getInternalSlots(dtf: Intl.DateTimeFormat): IntlDateTimeFormatInternal;
5
- localeData: Record<string, DateTimeFormatLocaleInternalData>;
6
- getDefaultTimeZone(): string;
7
- }
8
- /**
9
- * https://tc39.es/ecma402/#sec-partitiondatetimepattern
10
- * @param dtf
11
- * @param x
12
- */
13
- export declare function FormatDateTimePattern(dtf: Intl.DateTimeFormat, patternParts: IntlDateTimeFormatPart[], x: number, { getInternalSlots, localeData, getDefaultTimeZone, tzData, }: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
14
- //# sourceMappingURL=FormatDateTimePattern.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormatDateTimePattern.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/FormatDateTimePattern.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,sBAAsB,EACvB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAc,sBAAsB,EAAC,MAAM,eAAe,CAAA;AAuCjE,MAAM,WAAW,gCAAgC;IAC/C,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,GAAG,0BAA0B,CAAA;IACtE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gCAAgC,CAAC,CAAA;IAC5D,kBAAkB,IAAI,MAAM,CAAA;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,YAAY,EAAE,sBAAsB,EAAE,EACtC,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,MAAM,GACP,EAAE,gCAAgC,GAAG,sBAAsB,GAC3D,sBAAsB,EAAE,CAkJ1B"}
@@ -1,182 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatDateTimePattern = void 0;
4
- var utils_1 = require("./utils");
5
- var ToLocalTime_1 = require("./ToLocalTime");
6
- var _262_1 = require("../262");
7
- function pad(n) {
8
- if (n < 10) {
9
- return "0" + n;
10
- }
11
- return String(n);
12
- }
13
- function offsetToGmtString(gmtFormat, hourFormat, offsetInMs, style) {
14
- var offsetInMinutes = Math.floor(offsetInMs / 60000);
15
- var mins = Math.abs(offsetInMinutes) % 60;
16
- var hours = Math.floor(Math.abs(offsetInMinutes) / 60);
17
- var _a = hourFormat.split(';'), positivePattern = _a[0], negativePattern = _a[1];
18
- var offsetStr = '';
19
- var pattern = offsetInMs < 0 ? negativePattern : positivePattern;
20
- if (style === 'long') {
21
- offsetStr = pattern
22
- .replace('HH', pad(hours))
23
- .replace('H', String(hours))
24
- .replace('mm', pad(mins))
25
- .replace('m', String(mins));
26
- }
27
- else if (mins || hours) {
28
- if (!mins) {
29
- pattern = pattern.replace(/:?m+/, '');
30
- }
31
- offsetStr = pattern.replace(/H+/, String(hours)).replace(/m+/, String(mins));
32
- }
33
- return gmtFormat.replace('{0}', offsetStr);
34
- }
35
- /**
36
- * https://tc39.es/ecma402/#sec-partitiondatetimepattern
37
- * @param dtf
38
- * @param x
39
- */
40
- function FormatDateTimePattern(dtf, patternParts, x, _a) {
41
- var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, getDefaultTimeZone = _a.getDefaultTimeZone, tzData = _a.tzData;
42
- x = _262_1.TimeClip(x);
43
- /** IMPL START */
44
- var internalSlots = getInternalSlots(dtf);
45
- var dataLocale = internalSlots.dataLocale;
46
- var dataLocaleData = localeData[dataLocale];
47
- /** IMPL END */
48
- var locale = internalSlots.locale;
49
- var nfOptions = Object.create(null);
50
- nfOptions.useGrouping = false;
51
- var nf = new Intl.NumberFormat(locale, nfOptions);
52
- var nf2Options = Object.create(null);
53
- nf2Options.minimumIntegerDigits = 2;
54
- nf2Options.useGrouping = false;
55
- var nf2 = new Intl.NumberFormat(locale, nf2Options);
56
- var fractionalSecondDigits = internalSlots.fractionalSecondDigits;
57
- var nf3;
58
- if (fractionalSecondDigits !== undefined) {
59
- var nf3Options = Object.create(null);
60
- nf3Options.minimumIntegerDigits = fractionalSecondDigits;
61
- nf3Options.useGrouping = false;
62
- nf3 = new Intl.NumberFormat(locale, nf3Options);
63
- }
64
- var tm = ToLocalTime_1.ToLocalTime(x,
65
- // @ts-ignore
66
- internalSlots.calendar, internalSlots.timeZone, { tzData: tzData });
67
- var result = [];
68
- for (var _i = 0, patternParts_1 = patternParts; _i < patternParts_1.length; _i++) {
69
- var patternPart = patternParts_1[_i];
70
- var p = patternPart.type;
71
- if (p === 'literal') {
72
- result.push({
73
- type: 'literal',
74
- value: patternPart.value,
75
- });
76
- }
77
- else if (p === 'fractionalSecondDigits') {
78
- var v = Math.floor(tm.millisecond * Math.pow(10, ((fractionalSecondDigits || 0) - 3)));
79
- result.push({
80
- // @ts-expect-error Spec is not there yet
81
- type: 'fractionalSecond',
82
- value: nf3.format(v),
83
- });
84
- }
85
- else if (utils_1.DATE_TIME_PROPS.indexOf(p) > -1) {
86
- var fv = '';
87
- var f = internalSlots[p];
88
- // @ts-ignore
89
- var v = tm[p];
90
- if (p === 'year' && v <= 0) {
91
- v = 1 - v;
92
- }
93
- if (p === 'month') {
94
- v++;
95
- }
96
- var hourCycle = internalSlots.hourCycle;
97
- if (p === 'hour' && (hourCycle === 'h11' || hourCycle === 'h12')) {
98
- v = v % 12;
99
- if (v === 0 && hourCycle === 'h12') {
100
- v = 12;
101
- }
102
- }
103
- if (p === 'hour' && hourCycle === 'h24') {
104
- if (v === 0) {
105
- v = 24;
106
- }
107
- }
108
- if (f === 'numeric') {
109
- fv = nf.format(v);
110
- }
111
- else if (f === '2-digit') {
112
- fv = nf2.format(v);
113
- if (fv.length > 2) {
114
- fv = fv.slice(fv.length - 2, fv.length);
115
- }
116
- }
117
- else if (f === 'narrow' || f === 'short' || f === 'long') {
118
- if (p === 'era') {
119
- fv = dataLocaleData[p][f][v];
120
- }
121
- else if (p === 'timeZoneName') {
122
- var timeZoneName = dataLocaleData.timeZoneName, gmtFormat = dataLocaleData.gmtFormat, hourFormat = dataLocaleData.hourFormat;
123
- var timeZone = internalSlots.timeZone || getDefaultTimeZone();
124
- var timeZoneData = timeZoneName[timeZone];
125
- if (timeZoneData && timeZoneData[f]) {
126
- fv = timeZoneData[f][+tm.inDST];
127
- }
128
- else {
129
- // Fallback to gmtFormat
130
- fv = offsetToGmtString(gmtFormat, hourFormat, tm.timeZoneOffset, f);
131
- }
132
- }
133
- else if (p === 'month') {
134
- fv = dataLocaleData.month[f][v - 1];
135
- }
136
- else {
137
- fv = dataLocaleData[p][f][v];
138
- }
139
- }
140
- result.push({
141
- type: p,
142
- value: fv,
143
- });
144
- }
145
- else if (p === 'ampm') {
146
- var v = tm.hour;
147
- var fv = void 0;
148
- if (v > 11) {
149
- fv = dataLocaleData.pm;
150
- }
151
- else {
152
- fv = dataLocaleData.am;
153
- }
154
- result.push({
155
- type: 'dayPeriod',
156
- value: fv,
157
- });
158
- }
159
- else if (p === 'relatedYear') {
160
- var v = tm.relatedYear;
161
- // @ts-ignore
162
- var fv = nf.format(v);
163
- result.push({
164
- // @ts-ignore TODO: Fix TS type
165
- type: 'relatedYear',
166
- value: fv,
167
- });
168
- }
169
- else if (p === 'yearName') {
170
- var v = tm.yearName;
171
- // @ts-ignore
172
- var fv = nf.format(v);
173
- result.push({
174
- // @ts-ignore TODO: Fix TS type
175
- type: 'yearName',
176
- value: fv,
177
- });
178
- }
179
- }
180
- return result;
181
- }
182
- exports.FormatDateTimePattern = FormatDateTimePattern;
@@ -1,4 +0,0 @@
1
- import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
2
- import { ToLocalTimeImplDetails } from './ToLocalTime';
3
- export declare function FormatDateTimeRange(dtf: Intl.DateTimeFormat, x: number, y: number, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): string;
4
- //# sourceMappingURL=FormatDateTimeRange.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormatDateTimeRange.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/FormatDateTimeRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gCAAgC,EAAC,MAAM,yBAAyB,CAAA;AAExE,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAA;AAEpD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,gCAAgC,GAAG,sBAAsB,UAQvE"}
@@ -1,14 +0,0 @@
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 = PartitionDateTimeRangePattern_1.PartitionDateTimeRangePattern(dtf, x, y, implDetails);
7
- var result = '';
8
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
9
- var part = parts_1[_i];
10
- result += part.value;
11
- }
12
- return result;
13
- }
14
- exports.FormatDateTimeRange = FormatDateTimeRange;
@@ -1,4 +0,0 @@
1
- import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
2
- import { ToLocalTimeImplDetails } from './ToLocalTime';
3
- export declare function FormatDateTimeRangeToParts(dtf: Intl.DateTimeFormat, x: number, y: number, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): any[];
4
- //# sourceMappingURL=FormatDateTimeRangeToParts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormatDateTimeRangeToParts.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/FormatDateTimeRangeToParts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gCAAgC,EAAC,MAAM,yBAAyB,CAAA;AAExE,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAA;AAEpD,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,gCAAgC,GAAG,sBAAsB,SAYvE"}
@@ -1,18 +0,0 @@
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 = PartitionDateTimeRangePattern_1.PartitionDateTimeRangePattern(dtf, x, y, implDetails);
7
- var result = new Array(0);
8
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
9
- var part = parts_1[_i];
10
- result.push({
11
- type: part.type,
12
- value: part.value,
13
- source: part.source,
14
- });
15
- }
16
- return result;
17
- }
18
- exports.FormatDateTimeRangeToParts = FormatDateTimeRangeToParts;
@@ -1,11 +0,0 @@
1
- import { PartitionDateTimePattern } from './PartitionDateTimePattern';
2
- import { IntlDateTimeFormatPart } from '../types/date-time';
3
- /**
4
- * https://tc39.es/ecma402/#sec-formatdatetimetoparts
5
- *
6
- * @param dtf
7
- * @param x
8
- * @param implDetails
9
- */
10
- export declare function FormatDateTimeToParts(dtf: Intl.DateTimeFormat, x: number, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): IntlDateTimeFormatPart[];
11
- //# sourceMappingURL=FormatDateTimeToParts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormatDateTimeToParts.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/FormatDateTimeToParts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAA;AAEnE,OAAO,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAA;AAEzD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,GAC1D,sBAAsB,EAAE,CAU1B"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatDateTimeToParts = void 0;
4
- var PartitionDateTimePattern_1 = require("./PartitionDateTimePattern");
5
- var _262_1 = require("../262");
6
- /**
7
- * https://tc39.es/ecma402/#sec-formatdatetimetoparts
8
- *
9
- * @param dtf
10
- * @param x
11
- * @param implDetails
12
- */
13
- function FormatDateTimeToParts(dtf, x, implDetails) {
14
- var parts = PartitionDateTimePattern_1.PartitionDateTimePattern(dtf, x, implDetails);
15
- var result = _262_1.ArrayCreate(0);
16
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
17
- var part = parts_1[_i];
18
- result.push({
19
- type: part.type,
20
- value: part.value,
21
- });
22
- }
23
- return result;
24
- }
25
- exports.FormatDateTimeToParts = FormatDateTimeToParts;
@@ -1,18 +0,0 @@
1
- import { DateTimeFormatOptions, IntlDateTimeFormatInternal, DateTimeFormatLocaleInternalData } from '../types/date-time';
2
- /**
3
- * https://tc39.es/ecma402/#sec-initializedatetimeformat
4
- * @param dtf DateTimeFormat
5
- * @param locales locales
6
- * @param opts options
7
- */
8
- export declare function InitializeDateTimeFormat(dtf: Intl.DateTimeFormat, locales: string | string[] | undefined, opts: DateTimeFormatOptions | undefined, { getInternalSlots, availableLocales, localeData, getDefaultLocale, getDefaultTimeZone, relevantExtensionKeys, tzData, uppercaseLinks, }: {
9
- getInternalSlots(dtf: Intl.DateTimeFormat): IntlDateTimeFormatInternal;
10
- availableLocales: Set<string>;
11
- getDefaultLocale(): string;
12
- getDefaultTimeZone(): string;
13
- relevantExtensionKeys: string[];
14
- localeData: Record<string, DateTimeFormatLocaleInternalData | undefined>;
15
- tzData: Record<string, unknown>;
16
- uppercaseLinks: Record<string, string>;
17
- }): Intl.DateTimeFormat;
18
- //# sourceMappingURL=InitializeDateTimeFormat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InitializeDateTimeFormat.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/InitializeDateTimeFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAErB,0BAA0B,EAC1B,gCAAgC,EACjC,MAAM,oBAAoB,CAAA;AAwD3B;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,IAAI,EAAE,qBAAqB,GAAG,SAAS,EACvC,EACE,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,MAAM,EACN,cAAc,GACf,EAAE;IACD,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,GAAG,0BAA0B,CAAA;IACtE,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,gBAAgB,IAAI,MAAM,CAAA;IAC1B,kBAAkB,IAAI,MAAM,CAAA;IAC5B,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gCAAgC,GAAG,SAAS,CAAC,CAAA;IACxE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACvC,GACA,IAAI,CAAC,cAAc,CAoPrB"}
@@ -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;AAgBhC,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,gCAAgC,GAAG,sBAAsB,4BAkHvE"}