@formatjs/ecma402-abstract 1.9.1 → 1.9.5

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 (221) 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/InitializeNumberFormat.js +2 -2
  7. package/NumberFormat/digit-mapping.generated.d.ts +2 -0
  8. package/NumberFormat/digit-mapping.generated.d.ts.map +1 -0
  9. package/NumberFormat/digit-mapping.generated.js +4 -0
  10. package/NumberFormat/format_to_parts.js +2 -3
  11. package/SupportedLocales.js +3 -3
  12. package/index.d.ts +1 -24
  13. package/index.d.ts.map +1 -1
  14. package/index.js +13 -39
  15. package/lib/IsValidTimeZoneName.d.ts +1 -1
  16. package/lib/IsValidTimeZoneName.d.ts.map +1 -1
  17. package/lib/IsValidTimeZoneName.js +6 -1
  18. package/lib/NumberFormat/InitializeNumberFormat.d.ts +2 -2
  19. package/lib/NumberFormat/InitializeNumberFormat.d.ts.map +1 -1
  20. package/lib/NumberFormat/InitializeNumberFormat.js +1 -1
  21. package/lib/NumberFormat/digit-mapping.generated.d.ts +2 -0
  22. package/lib/NumberFormat/digit-mapping.generated.d.ts.map +1 -0
  23. package/lib/NumberFormat/digit-mapping.generated.js +1 -0
  24. package/lib/NumberFormat/format_to_parts.js +1 -1
  25. package/lib/SupportedLocales.js +1 -1
  26. package/lib/index.d.ts +1 -24
  27. package/lib/index.d.ts.map +1 -1
  28. package/lib/index.js +1 -24
  29. package/lib/types/date-time.d.ts +1 -0
  30. package/lib/types/date-time.d.ts.map +1 -1
  31. package/package.json +2 -1
  32. package/types/date-time.d.ts +1 -0
  33. package/types/date-time.d.ts.map +1 -1
  34. package/BestAvailableLocale.d.ts +0 -7
  35. package/BestAvailableLocale.d.ts.map +0 -1
  36. package/BestAvailableLocale.js +0 -25
  37. package/BestFitMatcher.d.ts +0 -9
  38. package/BestFitMatcher.d.ts.map +0 -1
  39. package/BestFitMatcher.js +0 -52
  40. package/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
  41. package/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
  42. package/DateTimeFormat/BasicFormatMatcher.js +0 -61
  43. package/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
  44. package/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
  45. package/DateTimeFormat/BestFitFormatMatcher.js +0 -121
  46. package/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
  47. package/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
  48. package/DateTimeFormat/DateTimeStyleFormat.js +0 -54
  49. package/DateTimeFormat/FormatDateTime.d.ts +0 -8
  50. package/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
  51. package/DateTimeFormat/FormatDateTime.js +0 -19
  52. package/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
  53. package/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
  54. package/DateTimeFormat/FormatDateTimePattern.js +0 -182
  55. package/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
  56. package/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
  57. package/DateTimeFormat/FormatDateTimeRange.js +0 -14
  58. package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
  59. package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
  60. package/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -18
  61. package/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
  62. package/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
  63. package/DateTimeFormat/FormatDateTimeToParts.js +0 -25
  64. package/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
  65. package/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
  66. package/DateTimeFormat/InitializeDateTimeFormat.js +0 -188
  67. package/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
  68. package/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
  69. package/DateTimeFormat/PartitionDateTimePattern.js +0 -24
  70. package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
  71. package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
  72. package/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -125
  73. package/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
  74. package/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
  75. package/DateTimeFormat/ToDateTimeOptions.js +0 -67
  76. package/DateTimeFormat/ToLocalTime.d.ts +0 -26
  77. package/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
  78. package/DateTimeFormat/ToLocalTime.js +0 -55
  79. package/DateTimeFormat/skeleton.d.ts +0 -14
  80. package/DateTimeFormat/skeleton.d.ts.map +0 -1
  81. package/DateTimeFormat/skeleton.js +0 -301
  82. package/DateTimeFormat/utils.d.ts +0 -10
  83. package/DateTimeFormat/utils.d.ts.map +0 -1
  84. package/DateTimeFormat/utils.js +0 -21
  85. package/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
  86. package/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
  87. package/DisplayNames/CanonicalCodeForDisplayNames.js +0 -37
  88. package/LookupMatcher.d.ts +0 -9
  89. package/LookupMatcher.d.ts.map +0 -1
  90. package/LookupMatcher.js +0 -29
  91. package/LookupSupportedLocales.d.ts +0 -7
  92. package/LookupSupportedLocales.d.ts.map +0 -1
  93. package/LookupSupportedLocales.js +0 -23
  94. package/NumberFormat/digit-mapping.json +0 -1
  95. package/PluralRules/GetOperands.d.ts +0 -32
  96. package/PluralRules/GetOperands.d.ts.map +0 -1
  97. package/PluralRules/GetOperands.js +0 -51
  98. package/PluralRules/InitializePluralRules.d.ts +0 -9
  99. package/PluralRules/InitializePluralRules.d.ts.map +0 -1
  100. package/PluralRules/InitializePluralRules.js +0 -24
  101. package/PluralRules/ResolvePlural.d.ts +0 -13
  102. package/PluralRules/ResolvePlural.d.ts.map +0 -1
  103. package/PluralRules/ResolvePlural.js +0 -29
  104. package/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
  105. package/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
  106. package/RelativeTimeFormat/FormatRelativeTime.js +0 -14
  107. package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
  108. package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
  109. package/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -22
  110. package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
  111. package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
  112. package/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -41
  113. package/RelativeTimeFormat/MakePartsList.d.ts +0 -2
  114. package/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
  115. package/RelativeTimeFormat/MakePartsList.js +0 -31
  116. package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
  117. package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
  118. package/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -58
  119. package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
  120. package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
  121. package/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -40
  122. package/ResolveLocale.d.ts +0 -15
  123. package/ResolveLocale.d.ts.map +0 -1
  124. package/ResolveLocale.js +0 -78
  125. package/UnicodeExtensionValue.d.ts +0 -7
  126. package/UnicodeExtensionValue.d.ts.map +0 -1
  127. package/UnicodeExtensionValue.js +0 -50
  128. package/lib/BestAvailableLocale.d.ts +0 -7
  129. package/lib/BestAvailableLocale.d.ts.map +0 -1
  130. package/lib/BestAvailableLocale.js +0 -21
  131. package/lib/BestFitMatcher.d.ts +0 -9
  132. package/lib/BestFitMatcher.d.ts.map +0 -1
  133. package/lib/BestFitMatcher.js +0 -48
  134. package/lib/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
  135. package/lib/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
  136. package/lib/DateTimeFormat/BasicFormatMatcher.js +0 -57
  137. package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
  138. package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
  139. package/lib/DateTimeFormat/BestFitFormatMatcher.js +0 -116
  140. package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
  141. package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
  142. package/lib/DateTimeFormat/DateTimeStyleFormat.js +0 -50
  143. package/lib/DateTimeFormat/FormatDateTime.d.ts +0 -8
  144. package/lib/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
  145. package/lib/DateTimeFormat/FormatDateTime.js +0 -15
  146. package/lib/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
  147. package/lib/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
  148. package/lib/DateTimeFormat/FormatDateTimePattern.js +0 -178
  149. package/lib/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
  150. package/lib/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
  151. package/lib/DateTimeFormat/FormatDateTimeRange.js +0 -10
  152. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
  153. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
  154. package/lib/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -14
  155. package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
  156. package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
  157. package/lib/DateTimeFormat/FormatDateTimeToParts.js +0 -21
  158. package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
  159. package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
  160. package/lib/DateTimeFormat/InitializeDateTimeFormat.js +0 -184
  161. package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
  162. package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
  163. package/lib/DateTimeFormat/PartitionDateTimePattern.js +0 -20
  164. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
  165. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
  166. package/lib/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -121
  167. package/lib/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
  168. package/lib/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
  169. package/lib/DateTimeFormat/ToDateTimeOptions.js +0 -63
  170. package/lib/DateTimeFormat/ToLocalTime.d.ts +0 -26
  171. package/lib/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
  172. package/lib/DateTimeFormat/ToLocalTime.js +0 -51
  173. package/lib/DateTimeFormat/skeleton.d.ts +0 -14
  174. package/lib/DateTimeFormat/skeleton.d.ts.map +0 -1
  175. package/lib/DateTimeFormat/skeleton.js +0 -294
  176. package/lib/DateTimeFormat/utils.d.ts +0 -10
  177. package/lib/DateTimeFormat/utils.d.ts.map +0 -1
  178. package/lib/DateTimeFormat/utils.js +0 -18
  179. package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
  180. package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
  181. package/lib/DisplayNames/CanonicalCodeForDisplayNames.js +0 -33
  182. package/lib/LookupMatcher.d.ts +0 -9
  183. package/lib/LookupMatcher.d.ts.map +0 -1
  184. package/lib/LookupMatcher.js +0 -25
  185. package/lib/LookupSupportedLocales.d.ts +0 -7
  186. package/lib/LookupSupportedLocales.d.ts.map +0 -1
  187. package/lib/LookupSupportedLocales.js +0 -19
  188. package/lib/NumberFormat/digit-mapping.json +0 -1
  189. package/lib/PluralRules/GetOperands.d.ts +0 -32
  190. package/lib/PluralRules/GetOperands.d.ts.map +0 -1
  191. package/lib/PluralRules/GetOperands.js +0 -47
  192. package/lib/PluralRules/InitializePluralRules.d.ts +0 -9
  193. package/lib/PluralRules/InitializePluralRules.d.ts.map +0 -1
  194. package/lib/PluralRules/InitializePluralRules.js +0 -20
  195. package/lib/PluralRules/ResolvePlural.d.ts +0 -13
  196. package/lib/PluralRules/ResolvePlural.d.ts.map +0 -1
  197. package/lib/PluralRules/ResolvePlural.js +0 -25
  198. package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
  199. package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
  200. package/lib/RelativeTimeFormat/FormatRelativeTime.js +0 -10
  201. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
  202. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
  203. package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -18
  204. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
  205. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
  206. package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -37
  207. package/lib/RelativeTimeFormat/MakePartsList.d.ts +0 -2
  208. package/lib/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
  209. package/lib/RelativeTimeFormat/MakePartsList.js +0 -27
  210. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
  211. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
  212. package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -54
  213. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
  214. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
  215. package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -36
  216. package/lib/ResolveLocale.d.ts +0 -15
  217. package/lib/ResolveLocale.d.ts.map +0 -1
  218. package/lib/ResolveLocale.js +0 -74
  219. package/lib/UnicodeExtensionValue.d.ts +0 -7
  220. package/lib/UnicodeExtensionValue.d.ts.map +0 -1
  221. package/lib/UnicodeExtensionValue.js +0 -46
@@ -1,17 +0,0 @@
1
- import { DateTimeFormatOptions, Formats } from '../types/date-time';
2
- /**
3
- * Credit: https://github.com/andyearnshaw/Intl.js/blob/0958dc1ad8153f1056653ea22b8208f0df289a4e/src/12.datetimeformat.js#L611
4
- * with some modifications
5
- * @param options
6
- * @param format
7
- */
8
- export declare function bestFitFormatMatcherScore(options: DateTimeFormatOptions, format: Formats): number;
9
- /**
10
- * https://tc39.es/ecma402/#sec-bestfitformatmatcher
11
- * Just alias to basic for now
12
- * @param options
13
- * @param formats
14
- * @param implDetails Implementation details
15
- */
16
- export declare function BestFitFormatMatcher(options: DateTimeFormatOptions, formats: Formats[]): Formats;
17
- //# sourceMappingURL=BestFitFormatMatcher.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BestFitFormatMatcher.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/DateTimeFormat/BestFitFormatMatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAE,OAAO,EAAU,MAAM,oBAAoB,CAAA;AAoB1E;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,OAAO,GACd,MAAM,CA0CR;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,OAAO,EAAE,WAsDnB"}
@@ -1,116 +0,0 @@
1
- import { __assign } from "tslib";
2
- import { invariant } from '../utils';
3
- import { DATE_TIME_PROPS, removalPenalty, additionPenalty, differentNumericTypePenalty, longMorePenalty, shortMorePenalty, shortLessPenalty, longLessPenalty, } from './utils';
4
- import { processDateTimePattern } from './skeleton';
5
- function isNumericType(t) {
6
- return t === 'numeric' || t === '2-digit';
7
- }
8
- /**
9
- * Credit: https://github.com/andyearnshaw/Intl.js/blob/0958dc1ad8153f1056653ea22b8208f0df289a4e/src/12.datetimeformat.js#L611
10
- * with some modifications
11
- * @param options
12
- * @param format
13
- */
14
- export function bestFitFormatMatcherScore(options, format) {
15
- var score = 0;
16
- if (options.hour12 && !format.hour12) {
17
- score -= removalPenalty;
18
- }
19
- else if (!options.hour12 && format.hour12) {
20
- score -= additionPenalty;
21
- }
22
- for (var _i = 0, DATE_TIME_PROPS_1 = DATE_TIME_PROPS; _i < DATE_TIME_PROPS_1.length; _i++) {
23
- var prop = DATE_TIME_PROPS_1[_i];
24
- var optionsProp = options[prop];
25
- var formatProp = format[prop];
26
- if (optionsProp === undefined && formatProp !== undefined) {
27
- score -= additionPenalty;
28
- }
29
- else if (optionsProp !== undefined && formatProp === undefined) {
30
- score -= removalPenalty;
31
- }
32
- else if (optionsProp !== formatProp) {
33
- // extra penalty for numeric vs non-numeric
34
- if (isNumericType(optionsProp) !==
35
- isNumericType(formatProp)) {
36
- score -= differentNumericTypePenalty;
37
- }
38
- else {
39
- var values = ['2-digit', 'numeric', 'narrow', 'short', 'long'];
40
- var optionsPropIndex = values.indexOf(optionsProp);
41
- var formatPropIndex = values.indexOf(formatProp);
42
- var delta = Math.max(-2, Math.min(formatPropIndex - optionsPropIndex, 2));
43
- if (delta === 2) {
44
- score -= longMorePenalty;
45
- }
46
- else if (delta === 1) {
47
- score -= shortMorePenalty;
48
- }
49
- else if (delta === -1) {
50
- score -= shortLessPenalty;
51
- }
52
- else if (delta === -2) {
53
- score -= longLessPenalty;
54
- }
55
- }
56
- }
57
- }
58
- return score;
59
- }
60
- /**
61
- * https://tc39.es/ecma402/#sec-bestfitformatmatcher
62
- * Just alias to basic for now
63
- * @param options
64
- * @param formats
65
- * @param implDetails Implementation details
66
- */
67
- export function BestFitFormatMatcher(options, formats) {
68
- var bestScore = -Infinity;
69
- var bestFormat = formats[0];
70
- invariant(Array.isArray(formats), 'formats should be a list of things');
71
- for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
72
- var format = formats_1[_i];
73
- var score = bestFitFormatMatcherScore(options, format);
74
- if (score > bestScore) {
75
- bestScore = score;
76
- bestFormat = format;
77
- }
78
- }
79
- var skeletonFormat = __assign({}, bestFormat);
80
- var patternFormat = { rawPattern: bestFormat.rawPattern };
81
- processDateTimePattern(bestFormat.rawPattern, patternFormat);
82
- // Kinda following https://github.com/unicode-org/icu/blob/dd50e38f459d84e9bf1b0c618be8483d318458ad/icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java
83
- // Method adjustFieldTypes
84
- for (var prop in skeletonFormat) {
85
- var skeletonValue = skeletonFormat[prop];
86
- var patternValue = patternFormat[prop];
87
- var requestedValue = options[prop];
88
- // Don't mess with minute/second or we can get in the situation of
89
- // 7:0:0 which is weird
90
- if (prop === 'minute' || prop === 'second') {
91
- continue;
92
- }
93
- // Nothing to do here
94
- if (!requestedValue) {
95
- continue;
96
- }
97
- // https://unicode.org/reports/tr35/tr35-dates.html#Matching_Skeletons
98
- // Looks like we should not convert numeric to alphabetic but the other way
99
- // around is ok
100
- if (isNumericType(patternValue) &&
101
- !isNumericType(requestedValue)) {
102
- continue;
103
- }
104
- if (skeletonValue === requestedValue) {
105
- continue;
106
- }
107
- patternFormat[prop] = requestedValue;
108
- }
109
- // Copy those over
110
- patternFormat.pattern = skeletonFormat.pattern;
111
- patternFormat.pattern12 = skeletonFormat.pattern12;
112
- patternFormat.skeleton = skeletonFormat.skeleton;
113
- patternFormat.rangePatterns = skeletonFormat.rangePatterns;
114
- patternFormat.rangePatterns12 = skeletonFormat.rangePatterns12;
115
- return patternFormat;
116
- }
@@ -1,3 +0,0 @@
1
- import { DateTimeFormatOptions, DateTimeFormatLocaleInternalData, Formats } from '../types/date-time';
2
- export declare function DateTimeStyleFormat(dateStyle: DateTimeFormatOptions['dateStyle'], timeStyle: DateTimeFormatOptions['timeStyle'], dataLocaleData: DateTimeFormatLocaleInternalData): Formats;
3
- //# sourceMappingURL=DateTimeStyleFormat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DateTimeStyleFormat.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/DateTimeFormat/DateTimeStyleFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,gCAAgC,EAChC,OAAO,EACR,MAAM,oBAAoB,CAAA;AAG3B,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC,EAC7C,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC,EAC7C,cAAc,EAAE,gCAAgC,GAC/C,OAAO,CAuDT"}
@@ -1,50 +0,0 @@
1
- import { invariant } from '../utils';
2
- export function DateTimeStyleFormat(dateStyle, timeStyle, dataLocaleData) {
3
- var dateFormat, timeFormat;
4
- if (timeStyle !== undefined) {
5
- invariant(timeStyle === 'full' ||
6
- timeStyle === 'long' ||
7
- timeStyle === 'medium' ||
8
- timeStyle === 'short', 'invalid timeStyle');
9
- timeFormat = dataLocaleData.timeFormat[timeStyle];
10
- }
11
- if (dateStyle !== undefined) {
12
- invariant(dateStyle === 'full' ||
13
- dateStyle === 'long' ||
14
- dateStyle === 'medium' ||
15
- dateStyle === 'short', 'invalid dateStyle');
16
- dateFormat = dataLocaleData.dateFormat[dateStyle];
17
- }
18
- if (dateStyle !== undefined && timeStyle !== undefined) {
19
- var format = {};
20
- for (var field in dateFormat) {
21
- if (field !== 'pattern') {
22
- // @ts-ignore
23
- format[field] = dateFormat[field];
24
- }
25
- }
26
- for (var field in timeFormat) {
27
- if (field !== 'pattern' && field !== 'pattern12') {
28
- // @ts-ignore
29
- format[field] = timeFormat[field];
30
- }
31
- }
32
- var connector = dataLocaleData.dateTimeFormat[dateStyle];
33
- var pattern = connector
34
- .replace('{0}', timeFormat.pattern)
35
- .replace('{1}', dateFormat.pattern);
36
- format.pattern = pattern;
37
- if ('pattern12' in timeFormat) {
38
- var pattern12 = connector
39
- .replace('{0}', timeFormat.pattern12)
40
- .replace('{1}', dateFormat.pattern);
41
- format.pattern12 = pattern12;
42
- }
43
- return format;
44
- }
45
- if (timeStyle !== undefined) {
46
- return timeFormat;
47
- }
48
- invariant(dateStyle !== undefined, 'dateStyle should not be undefined');
49
- return dateFormat;
50
- }
@@ -1,8 +0,0 @@
1
- import { PartitionDateTimePattern } from './PartitionDateTimePattern';
2
- /**
3
- * https://tc39.es/ecma402/#sec-formatdatetime
4
- * @param dtf DateTimeFormat
5
- * @param x
6
- */
7
- export declare function FormatDateTime(dtf: Intl.DateTimeFormat, x: number, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): string;
8
- //# sourceMappingURL=FormatDateTime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormatDateTime.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/DateTimeFormat/FormatDateTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAA;AAEnE;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,UAQ5D"}
@@ -1,15 +0,0 @@
1
- import { PartitionDateTimePattern } from './PartitionDateTimePattern';
2
- /**
3
- * https://tc39.es/ecma402/#sec-formatdatetime
4
- * @param dtf DateTimeFormat
5
- * @param x
6
- */
7
- export function FormatDateTime(dtf, x, implDetails) {
8
- var parts = PartitionDateTimePattern(dtf, x, implDetails);
9
- var result = '';
10
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
11
- var part = parts_1[_i];
12
- result += part.value;
13
- }
14
- return result;
15
- }
@@ -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,178 +0,0 @@
1
- import { DATE_TIME_PROPS } from './utils';
2
- import { ToLocalTime } from './ToLocalTime';
3
- import { TimeClip } from '../262';
4
- function pad(n) {
5
- if (n < 10) {
6
- return "0" + n;
7
- }
8
- return String(n);
9
- }
10
- function offsetToGmtString(gmtFormat, hourFormat, offsetInMs, style) {
11
- var offsetInMinutes = Math.floor(offsetInMs / 60000);
12
- var mins = Math.abs(offsetInMinutes) % 60;
13
- var hours = Math.floor(Math.abs(offsetInMinutes) / 60);
14
- var _a = hourFormat.split(';'), positivePattern = _a[0], negativePattern = _a[1];
15
- var offsetStr = '';
16
- var pattern = offsetInMs < 0 ? negativePattern : positivePattern;
17
- if (style === 'long') {
18
- offsetStr = pattern
19
- .replace('HH', pad(hours))
20
- .replace('H', String(hours))
21
- .replace('mm', pad(mins))
22
- .replace('m', String(mins));
23
- }
24
- else if (mins || hours) {
25
- if (!mins) {
26
- pattern = pattern.replace(/:?m+/, '');
27
- }
28
- offsetStr = pattern.replace(/H+/, String(hours)).replace(/m+/, String(mins));
29
- }
30
- return gmtFormat.replace('{0}', offsetStr);
31
- }
32
- /**
33
- * https://tc39.es/ecma402/#sec-partitiondatetimepattern
34
- * @param dtf
35
- * @param x
36
- */
37
- export function FormatDateTimePattern(dtf, patternParts, x, _a) {
38
- var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, getDefaultTimeZone = _a.getDefaultTimeZone, tzData = _a.tzData;
39
- x = TimeClip(x);
40
- /** IMPL START */
41
- var internalSlots = getInternalSlots(dtf);
42
- var dataLocale = internalSlots.dataLocale;
43
- var dataLocaleData = localeData[dataLocale];
44
- /** IMPL END */
45
- var locale = internalSlots.locale;
46
- var nfOptions = Object.create(null);
47
- nfOptions.useGrouping = false;
48
- var nf = new Intl.NumberFormat(locale, nfOptions);
49
- var nf2Options = Object.create(null);
50
- nf2Options.minimumIntegerDigits = 2;
51
- nf2Options.useGrouping = false;
52
- var nf2 = new Intl.NumberFormat(locale, nf2Options);
53
- var fractionalSecondDigits = internalSlots.fractionalSecondDigits;
54
- var nf3;
55
- if (fractionalSecondDigits !== undefined) {
56
- var nf3Options = Object.create(null);
57
- nf3Options.minimumIntegerDigits = fractionalSecondDigits;
58
- nf3Options.useGrouping = false;
59
- nf3 = new Intl.NumberFormat(locale, nf3Options);
60
- }
61
- var tm = ToLocalTime(x,
62
- // @ts-ignore
63
- internalSlots.calendar, internalSlots.timeZone, { tzData: tzData });
64
- var result = [];
65
- for (var _i = 0, patternParts_1 = patternParts; _i < patternParts_1.length; _i++) {
66
- var patternPart = patternParts_1[_i];
67
- var p = patternPart.type;
68
- if (p === 'literal') {
69
- result.push({
70
- type: 'literal',
71
- value: patternPart.value,
72
- });
73
- }
74
- else if (p === 'fractionalSecondDigits') {
75
- var v = Math.floor(tm.millisecond * Math.pow(10, ((fractionalSecondDigits || 0) - 3)));
76
- result.push({
77
- // @ts-expect-error Spec is not there yet
78
- type: 'fractionalSecond',
79
- value: nf3.format(v),
80
- });
81
- }
82
- else if (DATE_TIME_PROPS.indexOf(p) > -1) {
83
- var fv = '';
84
- var f = internalSlots[p];
85
- // @ts-ignore
86
- var v = tm[p];
87
- if (p === 'year' && v <= 0) {
88
- v = 1 - v;
89
- }
90
- if (p === 'month') {
91
- v++;
92
- }
93
- var hourCycle = internalSlots.hourCycle;
94
- if (p === 'hour' && (hourCycle === 'h11' || hourCycle === 'h12')) {
95
- v = v % 12;
96
- if (v === 0 && hourCycle === 'h12') {
97
- v = 12;
98
- }
99
- }
100
- if (p === 'hour' && hourCycle === 'h24') {
101
- if (v === 0) {
102
- v = 24;
103
- }
104
- }
105
- if (f === 'numeric') {
106
- fv = nf.format(v);
107
- }
108
- else if (f === '2-digit') {
109
- fv = nf2.format(v);
110
- if (fv.length > 2) {
111
- fv = fv.slice(fv.length - 2, fv.length);
112
- }
113
- }
114
- else if (f === 'narrow' || f === 'short' || f === 'long') {
115
- if (p === 'era') {
116
- fv = dataLocaleData[p][f][v];
117
- }
118
- else if (p === 'timeZoneName') {
119
- var timeZoneName = dataLocaleData.timeZoneName, gmtFormat = dataLocaleData.gmtFormat, hourFormat = dataLocaleData.hourFormat;
120
- var timeZone = internalSlots.timeZone || getDefaultTimeZone();
121
- var timeZoneData = timeZoneName[timeZone];
122
- if (timeZoneData && timeZoneData[f]) {
123
- fv = timeZoneData[f][+tm.inDST];
124
- }
125
- else {
126
- // Fallback to gmtFormat
127
- fv = offsetToGmtString(gmtFormat, hourFormat, tm.timeZoneOffset, f);
128
- }
129
- }
130
- else if (p === 'month') {
131
- fv = dataLocaleData.month[f][v - 1];
132
- }
133
- else {
134
- fv = dataLocaleData[p][f][v];
135
- }
136
- }
137
- result.push({
138
- type: p,
139
- value: fv,
140
- });
141
- }
142
- else if (p === 'ampm') {
143
- var v = tm.hour;
144
- var fv = void 0;
145
- if (v > 11) {
146
- fv = dataLocaleData.pm;
147
- }
148
- else {
149
- fv = dataLocaleData.am;
150
- }
151
- result.push({
152
- type: 'dayPeriod',
153
- value: fv,
154
- });
155
- }
156
- else if (p === 'relatedYear') {
157
- var v = tm.relatedYear;
158
- // @ts-ignore
159
- var fv = nf.format(v);
160
- result.push({
161
- // @ts-ignore TODO: Fix TS type
162
- type: 'relatedYear',
163
- value: fv,
164
- });
165
- }
166
- else if (p === 'yearName') {
167
- var v = tm.yearName;
168
- // @ts-ignore
169
- var fv = nf.format(v);
170
- result.push({
171
- // @ts-ignore TODO: Fix TS type
172
- type: 'yearName',
173
- value: fv,
174
- });
175
- }
176
- }
177
- return result;
178
- }
@@ -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,10 +0,0 @@
1
- import { PartitionDateTimeRangePattern } from './PartitionDateTimeRangePattern';
2
- export function FormatDateTimeRange(dtf, x, y, implDetails) {
3
- var parts = PartitionDateTimeRangePattern(dtf, x, y, implDetails);
4
- var result = '';
5
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
6
- var part = parts_1[_i];
7
- result += part.value;
8
- }
9
- return result;
10
- }
@@ -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,14 +0,0 @@
1
- import { PartitionDateTimeRangePattern } from './PartitionDateTimeRangePattern';
2
- export function FormatDateTimeRangeToParts(dtf, x, y, implDetails) {
3
- var parts = PartitionDateTimeRangePattern(dtf, x, y, implDetails);
4
- var result = new Array(0);
5
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
6
- var part = parts_1[_i];
7
- result.push({
8
- type: part.type,
9
- value: part.value,
10
- source: part.source,
11
- });
12
- }
13
- return result;
14
- }
@@ -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,21 +0,0 @@
1
- import { PartitionDateTimePattern } from './PartitionDateTimePattern';
2
- import { ArrayCreate } from '../262';
3
- /**
4
- * https://tc39.es/ecma402/#sec-formatdatetimetoparts
5
- *
6
- * @param dtf
7
- * @param x
8
- * @param implDetails
9
- */
10
- export function FormatDateTimeToParts(dtf, x, implDetails) {
11
- var parts = PartitionDateTimePattern(dtf, x, implDetails);
12
- var result = ArrayCreate(0);
13
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
14
- var part = parts_1[_i];
15
- result.push({
16
- type: part.type,
17
- value: part.value,
18
- });
19
- }
20
- return result;
21
- }
@@ -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"}