@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.
- package/index.d.ts +1 -23
- package/index.d.ts.map +1 -1
- package/index.js +13 -38
- package/lib/index.d.ts +1 -23
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -23
- package/lib/types/date-time.d.ts +1 -0
- package/lib/types/date-time.d.ts.map +1 -1
- package/package.json +1 -1
- package/types/date-time.d.ts +1 -0
- package/types/date-time.d.ts.map +1 -1
- package/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
- package/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
- package/DateTimeFormat/BasicFormatMatcher.js +0 -61
- package/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
- package/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
- package/DateTimeFormat/BestFitFormatMatcher.js +0 -121
- package/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
- package/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
- package/DateTimeFormat/DateTimeStyleFormat.js +0 -54
- package/DateTimeFormat/FormatDateTime.d.ts +0 -8
- package/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
- package/DateTimeFormat/FormatDateTime.js +0 -19
- package/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
- package/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
- package/DateTimeFormat/FormatDateTimePattern.js +0 -182
- package/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
- package/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
- package/DateTimeFormat/FormatDateTimeRange.js +0 -14
- package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
- package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
- package/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -18
- package/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
- package/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
- package/DateTimeFormat/FormatDateTimeToParts.js +0 -25
- package/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
- package/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
- package/DateTimeFormat/InitializeDateTimeFormat.js +0 -188
- package/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
- package/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
- package/DateTimeFormat/PartitionDateTimePattern.js +0 -24
- package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
- package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
- package/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -125
- package/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
- package/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
- package/DateTimeFormat/ToDateTimeOptions.js +0 -67
- package/DateTimeFormat/ToLocalTime.d.ts +0 -26
- package/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
- package/DateTimeFormat/ToLocalTime.js +0 -55
- package/DateTimeFormat/skeleton.d.ts +0 -14
- package/DateTimeFormat/skeleton.d.ts.map +0 -1
- package/DateTimeFormat/skeleton.js +0 -301
- package/DateTimeFormat/utils.d.ts +0 -10
- package/DateTimeFormat/utils.d.ts.map +0 -1
- package/DateTimeFormat/utils.js +0 -21
- package/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
- package/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
- package/DisplayNames/CanonicalCodeForDisplayNames.js +0 -37
- package/PluralRules/GetOperands.d.ts +0 -32
- package/PluralRules/GetOperands.d.ts.map +0 -1
- package/PluralRules/GetOperands.js +0 -51
- package/PluralRules/InitializePluralRules.d.ts +0 -9
- package/PluralRules/InitializePluralRules.d.ts.map +0 -1
- package/PluralRules/InitializePluralRules.js +0 -24
- package/PluralRules/ResolvePlural.d.ts +0 -13
- package/PluralRules/ResolvePlural.d.ts.map +0 -1
- package/PluralRules/ResolvePlural.js +0 -29
- package/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
- package/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
- package/RelativeTimeFormat/FormatRelativeTime.js +0 -14
- package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
- package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
- package/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -22
- package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
- package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
- package/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -41
- package/RelativeTimeFormat/MakePartsList.d.ts +0 -2
- package/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
- package/RelativeTimeFormat/MakePartsList.js +0 -31
- package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
- package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
- package/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -58
- package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
- package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
- package/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -40
- package/lib/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
- package/lib/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
- package/lib/DateTimeFormat/BasicFormatMatcher.js +0 -57
- package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
- package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
- package/lib/DateTimeFormat/BestFitFormatMatcher.js +0 -116
- package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
- package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
- package/lib/DateTimeFormat/DateTimeStyleFormat.js +0 -50
- package/lib/DateTimeFormat/FormatDateTime.d.ts +0 -8
- package/lib/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
- package/lib/DateTimeFormat/FormatDateTime.js +0 -15
- package/lib/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
- package/lib/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
- package/lib/DateTimeFormat/FormatDateTimePattern.js +0 -178
- package/lib/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
- package/lib/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
- package/lib/DateTimeFormat/FormatDateTimeRange.js +0 -10
- package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
- package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
- package/lib/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -14
- package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
- package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
- package/lib/DateTimeFormat/FormatDateTimeToParts.js +0 -21
- package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
- package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
- package/lib/DateTimeFormat/InitializeDateTimeFormat.js +0 -184
- package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
- package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
- package/lib/DateTimeFormat/PartitionDateTimePattern.js +0 -20
- package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
- package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
- package/lib/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -121
- package/lib/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
- package/lib/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
- package/lib/DateTimeFormat/ToDateTimeOptions.js +0 -63
- package/lib/DateTimeFormat/ToLocalTime.d.ts +0 -26
- package/lib/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
- package/lib/DateTimeFormat/ToLocalTime.js +0 -51
- package/lib/DateTimeFormat/skeleton.d.ts +0 -14
- package/lib/DateTimeFormat/skeleton.d.ts.map +0 -1
- package/lib/DateTimeFormat/skeleton.js +0 -294
- package/lib/DateTimeFormat/utils.d.ts +0 -10
- package/lib/DateTimeFormat/utils.d.ts.map +0 -1
- package/lib/DateTimeFormat/utils.js +0 -18
- package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
- package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
- package/lib/DisplayNames/CanonicalCodeForDisplayNames.js +0 -33
- package/lib/PluralRules/GetOperands.d.ts +0 -32
- package/lib/PluralRules/GetOperands.d.ts.map +0 -1
- package/lib/PluralRules/GetOperands.js +0 -47
- package/lib/PluralRules/InitializePluralRules.d.ts +0 -9
- package/lib/PluralRules/InitializePluralRules.d.ts.map +0 -1
- package/lib/PluralRules/InitializePluralRules.js +0 -20
- package/lib/PluralRules/ResolvePlural.d.ts +0 -13
- package/lib/PluralRules/ResolvePlural.d.ts.map +0 -1
- package/lib/PluralRules/ResolvePlural.js +0 -25
- package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
- package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/FormatRelativeTime.js +0 -10
- package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
- package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -18
- package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
- package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -37
- package/lib/RelativeTimeFormat/MakePartsList.d.ts +0 -2
- package/lib/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/MakePartsList.js +0 -27
- package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
- package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -54
- package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
- package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -36
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PartitionDateTimeRangePattern = void 0;
|
|
4
|
-
var date_time_1 = require("../types/date-time");
|
|
5
|
-
var _262_1 = require("../262");
|
|
6
|
-
var ToLocalTime_1 = require("./ToLocalTime");
|
|
7
|
-
var FormatDateTimePattern_1 = require("./FormatDateTimePattern");
|
|
8
|
-
var PartitionPattern_1 = require("../PartitionPattern");
|
|
9
|
-
var TABLE_2_FIELDS = [
|
|
10
|
-
'era',
|
|
11
|
-
'year',
|
|
12
|
-
'month',
|
|
13
|
-
'day',
|
|
14
|
-
'dayPeriod',
|
|
15
|
-
'ampm',
|
|
16
|
-
'hour',
|
|
17
|
-
'minute',
|
|
18
|
-
'second',
|
|
19
|
-
'fractionalSecondDigits',
|
|
20
|
-
];
|
|
21
|
-
function PartitionDateTimeRangePattern(dtf, x, y, implDetails) {
|
|
22
|
-
x = _262_1.TimeClip(x);
|
|
23
|
-
if (isNaN(x)) {
|
|
24
|
-
throw new RangeError('Invalid start time');
|
|
25
|
-
}
|
|
26
|
-
y = _262_1.TimeClip(y);
|
|
27
|
-
if (isNaN(y)) {
|
|
28
|
-
throw new RangeError('Invalid end time');
|
|
29
|
-
}
|
|
30
|
-
/** IMPL START */
|
|
31
|
-
var getInternalSlots = implDetails.getInternalSlots, tzData = implDetails.tzData;
|
|
32
|
-
var internalSlots = getInternalSlots(dtf);
|
|
33
|
-
/** IMPL END */
|
|
34
|
-
var tm1 = ToLocalTime_1.ToLocalTime(x,
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
internalSlots.calendar, internalSlots.timeZone, { tzData: tzData });
|
|
37
|
-
var tm2 = ToLocalTime_1.ToLocalTime(y,
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
internalSlots.calendar, internalSlots.timeZone, { tzData: tzData });
|
|
40
|
-
var pattern = internalSlots.pattern, rangePatterns = internalSlots.rangePatterns;
|
|
41
|
-
var rangePattern;
|
|
42
|
-
var dateFieldsPracticallyEqual = true;
|
|
43
|
-
var patternContainsLargerDateField = false;
|
|
44
|
-
for (var _i = 0, TABLE_2_FIELDS_1 = TABLE_2_FIELDS; _i < TABLE_2_FIELDS_1.length; _i++) {
|
|
45
|
-
var fieldName = TABLE_2_FIELDS_1[_i];
|
|
46
|
-
if (dateFieldsPracticallyEqual && !patternContainsLargerDateField) {
|
|
47
|
-
var rp = fieldName in rangePatterns ? rangePatterns[fieldName] : undefined;
|
|
48
|
-
if (rangePattern !== undefined && rp === undefined) {
|
|
49
|
-
patternContainsLargerDateField = true;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
rangePattern = rp;
|
|
53
|
-
if (fieldName === 'ampm') {
|
|
54
|
-
var v1 = tm1.hour;
|
|
55
|
-
var v2 = tm2.hour;
|
|
56
|
-
if ((v1 > 11 && v2 < 11) || (v1 < 11 && v2 > 11)) {
|
|
57
|
-
dateFieldsPracticallyEqual = false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
else if (fieldName === 'dayPeriod') {
|
|
61
|
-
// TODO
|
|
62
|
-
}
|
|
63
|
-
else if (fieldName === 'fractionalSecondDigits') {
|
|
64
|
-
var fractionalSecondDigits = internalSlots.fractionalSecondDigits;
|
|
65
|
-
if (fractionalSecondDigits === undefined) {
|
|
66
|
-
fractionalSecondDigits = 3;
|
|
67
|
-
}
|
|
68
|
-
var v1 = Math.floor(tm1.millisecond * Math.pow(10, (fractionalSecondDigits - 3)));
|
|
69
|
-
var v2 = Math.floor(tm2.millisecond * Math.pow(10, (fractionalSecondDigits - 3)));
|
|
70
|
-
if (!_262_1.SameValue(v1, v2)) {
|
|
71
|
-
dateFieldsPracticallyEqual = false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
var v1 = tm1[fieldName];
|
|
76
|
-
var v2 = tm2[fieldName];
|
|
77
|
-
if (!_262_1.SameValue(v1, v2)) {
|
|
78
|
-
dateFieldsPracticallyEqual = false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (dateFieldsPracticallyEqual) {
|
|
85
|
-
var result_2 = FormatDateTimePattern_1.FormatDateTimePattern(dtf, PartitionPattern_1.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 = date_time_1.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 === date_time_1.RangePatternType.startRange ||
|
|
109
|
-
source === date_time_1.RangePatternType.shared) {
|
|
110
|
-
z = x;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
z = y;
|
|
114
|
-
}
|
|
115
|
-
var patternParts = PartitionPattern_1.PartitionPattern(pattern_1);
|
|
116
|
-
var partResult = FormatDateTimePattern_1.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
|
-
}
|
|
125
|
-
exports.PartitionDateTimeRangePattern = PartitionDateTimeRangePattern;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DateTimeFormatOptions } from '../types/date-time';
|
|
2
|
-
/**
|
|
3
|
-
* https://tc39.es/ecma402/#sec-todatetimeoptions
|
|
4
|
-
* @param options
|
|
5
|
-
* @param required
|
|
6
|
-
* @param defaults
|
|
7
|
-
*/
|
|
8
|
-
export declare function ToDateTimeOptions(options?: DateTimeFormatOptions | null, required?: string, defaults?: string): DateTimeFormatOptions;
|
|
9
|
-
//# sourceMappingURL=ToDateTimeOptions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToDateTimeOptions.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/ToDateTimeOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAA;AAGxD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI,EACtC,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,GAChB,qBAAqB,CAkEvB"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ToDateTimeOptions = void 0;
|
|
4
|
-
var _262_1 = require("../262");
|
|
5
|
-
/**
|
|
6
|
-
* https://tc39.es/ecma402/#sec-todatetimeoptions
|
|
7
|
-
* @param options
|
|
8
|
-
* @param required
|
|
9
|
-
* @param defaults
|
|
10
|
-
*/
|
|
11
|
-
function ToDateTimeOptions(options, required, defaults) {
|
|
12
|
-
if (options === undefined) {
|
|
13
|
-
options = null;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
options = _262_1.ToObject(options);
|
|
17
|
-
}
|
|
18
|
-
options = Object.create(options);
|
|
19
|
-
var needDefaults = true;
|
|
20
|
-
if (required === 'date' || required === 'any') {
|
|
21
|
-
for (var _i = 0, _a = ['weekday', 'year', 'month', 'day']; _i < _a.length; _i++) {
|
|
22
|
-
var prop = _a[_i];
|
|
23
|
-
var value = options[prop];
|
|
24
|
-
if (value !== undefined) {
|
|
25
|
-
needDefaults = false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (required === 'time' || required === 'any') {
|
|
30
|
-
for (var _b = 0, _c = [
|
|
31
|
-
'dayPeriod',
|
|
32
|
-
'hour',
|
|
33
|
-
'minute',
|
|
34
|
-
'second',
|
|
35
|
-
'fractionalSecondDigits',
|
|
36
|
-
]; _b < _c.length; _b++) {
|
|
37
|
-
var prop = _c[_b];
|
|
38
|
-
var value = options[prop];
|
|
39
|
-
if (value !== undefined) {
|
|
40
|
-
needDefaults = false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (options.dateStyle !== undefined || options.timeStyle !== undefined) {
|
|
45
|
-
needDefaults = false;
|
|
46
|
-
}
|
|
47
|
-
if (required === 'date' && options.timeStyle) {
|
|
48
|
-
throw new TypeError('Intl.DateTimeFormat date was required but timeStyle was included');
|
|
49
|
-
}
|
|
50
|
-
if (required === 'time' && options.dateStyle) {
|
|
51
|
-
throw new TypeError('Intl.DateTimeFormat time was required but dateStyle was included');
|
|
52
|
-
}
|
|
53
|
-
if (needDefaults && (defaults === 'date' || defaults === 'all')) {
|
|
54
|
-
for (var _d = 0, _e = ['year', 'month', 'day']; _d < _e.length; _d++) {
|
|
55
|
-
var prop = _e[_d];
|
|
56
|
-
options[prop] = 'numeric';
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (needDefaults && (defaults === 'time' || defaults === 'all')) {
|
|
60
|
-
for (var _f = 0, _g = ['hour', 'minute', 'second']; _f < _g.length; _f++) {
|
|
61
|
-
var prop = _g[_f];
|
|
62
|
-
options[prop] = 'numeric';
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return options;
|
|
66
|
-
}
|
|
67
|
-
exports.ToDateTimeOptions = ToDateTimeOptions;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { UnpackedZoneData } from '../types/date-time';
|
|
2
|
-
export interface ToLocalTimeImplDetails {
|
|
3
|
-
tzData: Record<string, UnpackedZoneData[]>;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* https://tc39.es/ecma402/#sec-tolocaltime
|
|
7
|
-
* @param t
|
|
8
|
-
* @param calendar
|
|
9
|
-
* @param timeZone
|
|
10
|
-
*/
|
|
11
|
-
export declare function ToLocalTime(t: number, calendar: string, timeZone: string, { tzData }: ToLocalTimeImplDetails): {
|
|
12
|
-
weekday: number;
|
|
13
|
-
era: string;
|
|
14
|
-
year: number;
|
|
15
|
-
relatedYear: undefined;
|
|
16
|
-
yearName: undefined;
|
|
17
|
-
month: number;
|
|
18
|
-
day: number;
|
|
19
|
-
hour: number;
|
|
20
|
-
minute: number;
|
|
21
|
-
second: number;
|
|
22
|
-
millisecond: number;
|
|
23
|
-
inDST: boolean;
|
|
24
|
-
timeZoneOffset: number;
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=ToLocalTime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToLocalTime.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/ToLocalTime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAmCnD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAA;CAC3C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,EAAC,MAAM,EAAC,EAAE,sBAAsB,GAC/B;IACD,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,SAAS,CAAA;IACtB,QAAQ,EAAE,SAAS,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;CACvB,CA0BA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ToLocalTime = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
5
|
-
var _262_1 = require("../262");
|
|
6
|
-
function getApplicableZoneData(t, timeZone, tzData) {
|
|
7
|
-
var _a;
|
|
8
|
-
var zoneData = tzData[timeZone];
|
|
9
|
-
// We don't have data for this so just say it's UTC
|
|
10
|
-
if (!zoneData) {
|
|
11
|
-
return [0, false];
|
|
12
|
-
}
|
|
13
|
-
var i = 0;
|
|
14
|
-
var offset = 0;
|
|
15
|
-
var dst = false;
|
|
16
|
-
for (; i <= zoneData.length; i++) {
|
|
17
|
-
if (i === zoneData.length || zoneData[i][0] * 1e3 > t) {
|
|
18
|
-
;
|
|
19
|
-
_a = zoneData[i - 1], offset = _a[2], dst = _a[3];
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return [offset * 1e3, dst];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* https://tc39.es/ecma402/#sec-tolocaltime
|
|
27
|
-
* @param t
|
|
28
|
-
* @param calendar
|
|
29
|
-
* @param timeZone
|
|
30
|
-
*/
|
|
31
|
-
function ToLocalTime(t, calendar, timeZone, _a) {
|
|
32
|
-
var tzData = _a.tzData;
|
|
33
|
-
utils_1.invariant(_262_1.Type(t) === 'Number', 'invalid time');
|
|
34
|
-
utils_1.invariant(calendar === 'gregory', 'We only support Gregory calendar right now');
|
|
35
|
-
var _b = getApplicableZoneData(t, timeZone, tzData), timeZoneOffset = _b[0], inDST = _b[1];
|
|
36
|
-
var tz = t + timeZoneOffset;
|
|
37
|
-
var year = _262_1.YearFromTime(tz);
|
|
38
|
-
return {
|
|
39
|
-
weekday: _262_1.WeekDay(tz),
|
|
40
|
-
era: year < 0 ? 'BC' : 'AD',
|
|
41
|
-
year: year,
|
|
42
|
-
relatedYear: undefined,
|
|
43
|
-
yearName: undefined,
|
|
44
|
-
month: _262_1.MonthFromTime(tz),
|
|
45
|
-
day: _262_1.DateFromTime(tz),
|
|
46
|
-
hour: _262_1.HourFromTime(tz),
|
|
47
|
-
minute: _262_1.MinFromTime(tz),
|
|
48
|
-
second: _262_1.SecFromTime(tz),
|
|
49
|
-
millisecond: _262_1.msFromTime(tz),
|
|
50
|
-
inDST: inDST,
|
|
51
|
-
// IMPORTANT: Not in spec
|
|
52
|
-
timeZoneOffset: timeZoneOffset,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
exports.ToLocalTime = ToLocalTime;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DateTimeFormatOptions, Formats, RangePatternPart } from '../types/date-time';
|
|
2
|
-
export declare function processDateTimePattern(pattern: string, result?: Pick<DateTimeFormatOptions, 'weekday' | 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'timeZoneName'> & {
|
|
3
|
-
hour12?: boolean;
|
|
4
|
-
}): [string, string];
|
|
5
|
-
/**
|
|
6
|
-
* Parse Date time skeleton into Intl.DateTimeFormatOptions
|
|
7
|
-
* Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
8
|
-
* @public
|
|
9
|
-
* @param skeleton skeleton string
|
|
10
|
-
*/
|
|
11
|
-
export declare function parseDateTimeSkeleton(skeleton: string, rawPattern?: string, rangePatterns?: Record<string, string>, intervalFormatFallback?: string): Formats;
|
|
12
|
-
export declare function splitFallbackRangePattern(pattern: string): Array<RangePatternPart>;
|
|
13
|
-
export declare function splitRangePattern(pattern: string): Array<RangePatternPart>;
|
|
14
|
-
//# sourceMappingURL=skeleton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/skeleton.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,gBAAgB,EAIjB,MAAM,oBAAoB,CAAA;AAkN3B,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,IAAI,CACX,qBAAqB,EACnB,SAAS,GACT,KAAK,GACL,MAAM,GACN,OAAO,GACP,KAAK,GACL,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,cAAc,CACjB,GAAG;IACF,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GACA,CAAC,MAAM,EAAE,MAAM,CAAC,CA8BlB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,UAAU,GAAE,MAAiB,EAC7B,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAgDT;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"}
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.splitRangePattern = exports.splitFallbackRangePattern = exports.parseDateTimeSkeleton = exports.processDateTimePattern = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var date_time_1 = require("../types/date-time");
|
|
6
|
-
/**
|
|
7
|
-
* https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
8
|
-
* Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js
|
|
9
|
-
* with some tweaks
|
|
10
|
-
*/
|
|
11
|
-
var DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
|
|
12
|
-
// trim patterns after transformations
|
|
13
|
-
var expPatternTrimmer = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
|
|
14
|
-
function matchSkeletonPattern(match, result) {
|
|
15
|
-
var len = match.length;
|
|
16
|
-
switch (match[0]) {
|
|
17
|
-
// Era
|
|
18
|
-
case 'G':
|
|
19
|
-
result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
|
|
20
|
-
return '{era}';
|
|
21
|
-
// Year
|
|
22
|
-
case 'y':
|
|
23
|
-
case 'Y':
|
|
24
|
-
case 'u':
|
|
25
|
-
case 'U':
|
|
26
|
-
case 'r':
|
|
27
|
-
result.year = len === 2 ? '2-digit' : 'numeric';
|
|
28
|
-
return '{year}';
|
|
29
|
-
// Quarter
|
|
30
|
-
case 'q':
|
|
31
|
-
case 'Q':
|
|
32
|
-
throw new RangeError('`w/Q` (quarter) patterns are not supported');
|
|
33
|
-
// Month
|
|
34
|
-
case 'M':
|
|
35
|
-
case 'L':
|
|
36
|
-
result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1];
|
|
37
|
-
return '{month}';
|
|
38
|
-
// Week
|
|
39
|
-
case 'w':
|
|
40
|
-
case 'W':
|
|
41
|
-
throw new RangeError('`w/W` (week of year) patterns are not supported');
|
|
42
|
-
case 'd':
|
|
43
|
-
result.day = ['numeric', '2-digit'][len - 1];
|
|
44
|
-
return '{day}';
|
|
45
|
-
case 'D':
|
|
46
|
-
case 'F':
|
|
47
|
-
case 'g':
|
|
48
|
-
result.day = 'numeric';
|
|
49
|
-
return '{day}';
|
|
50
|
-
// Weekday
|
|
51
|
-
case 'E':
|
|
52
|
-
result.weekday = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
|
|
53
|
-
return '{weekday}';
|
|
54
|
-
case 'e':
|
|
55
|
-
result.weekday = [
|
|
56
|
-
undefined,
|
|
57
|
-
undefined,
|
|
58
|
-
'short',
|
|
59
|
-
'long',
|
|
60
|
-
'narrow',
|
|
61
|
-
'short',
|
|
62
|
-
][len - 1];
|
|
63
|
-
return '{weekday}';
|
|
64
|
-
case 'c':
|
|
65
|
-
result.weekday = [
|
|
66
|
-
undefined,
|
|
67
|
-
undefined,
|
|
68
|
-
'short',
|
|
69
|
-
'long',
|
|
70
|
-
'narrow',
|
|
71
|
-
'short',
|
|
72
|
-
][len - 1];
|
|
73
|
-
return '{weekday}';
|
|
74
|
-
// Period
|
|
75
|
-
case 'a': // AM, PM
|
|
76
|
-
case 'b': // am, pm, noon, midnight
|
|
77
|
-
case 'B': // flexible day periods
|
|
78
|
-
result.hour12 = true;
|
|
79
|
-
return '{ampm}';
|
|
80
|
-
// Hour
|
|
81
|
-
case 'h':
|
|
82
|
-
result.hour = ['numeric', '2-digit'][len - 1];
|
|
83
|
-
result.hour12 = true;
|
|
84
|
-
return '{hour}';
|
|
85
|
-
case 'H':
|
|
86
|
-
result.hour = ['numeric', '2-digit'][len - 1];
|
|
87
|
-
return '{hour}';
|
|
88
|
-
case 'K':
|
|
89
|
-
result.hour = ['numeric', '2-digit'][len - 1];
|
|
90
|
-
result.hour12 = true;
|
|
91
|
-
return '{hour}';
|
|
92
|
-
case 'k':
|
|
93
|
-
result.hour = ['numeric', '2-digit'][len - 1];
|
|
94
|
-
return '{hour}';
|
|
95
|
-
case 'j':
|
|
96
|
-
case 'J':
|
|
97
|
-
case 'C':
|
|
98
|
-
throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead');
|
|
99
|
-
// Minute
|
|
100
|
-
case 'm':
|
|
101
|
-
result.minute = ['numeric', '2-digit'][len - 1];
|
|
102
|
-
return '{minute}';
|
|
103
|
-
// Second
|
|
104
|
-
case 's':
|
|
105
|
-
result.second = ['numeric', '2-digit'][len - 1];
|
|
106
|
-
return '{second}';
|
|
107
|
-
case 'S':
|
|
108
|
-
case 'A':
|
|
109
|
-
result.second = 'numeric';
|
|
110
|
-
return '{second}';
|
|
111
|
-
// Zone
|
|
112
|
-
case 'z': // 1..3, 4: specific non-location format
|
|
113
|
-
case 'Z': // 1..3, 4, 5: The ISO8601 varios formats
|
|
114
|
-
case 'O': // 1, 4: miliseconds in day short, long
|
|
115
|
-
case 'v': // 1, 4: generic non-location format
|
|
116
|
-
case 'V': // 1, 2, 3, 4: time zone ID or city
|
|
117
|
-
case 'X': // 1, 2, 3, 4: The ISO8601 varios formats
|
|
118
|
-
case 'x': // 1, 2, 3, 4: The ISO8601 varios formats
|
|
119
|
-
result.timeZoneName = len < 4 ? 'short' : 'long';
|
|
120
|
-
return '{timeZoneName}';
|
|
121
|
-
}
|
|
122
|
-
return '';
|
|
123
|
-
}
|
|
124
|
-
function skeletonTokenToTable2(c) {
|
|
125
|
-
switch (c) {
|
|
126
|
-
// Era
|
|
127
|
-
case 'G':
|
|
128
|
-
return 'era';
|
|
129
|
-
// Year
|
|
130
|
-
case 'y':
|
|
131
|
-
case 'Y':
|
|
132
|
-
case 'u':
|
|
133
|
-
case 'U':
|
|
134
|
-
case 'r':
|
|
135
|
-
return 'year';
|
|
136
|
-
// Month
|
|
137
|
-
case 'M':
|
|
138
|
-
case 'L':
|
|
139
|
-
return 'month';
|
|
140
|
-
// Day
|
|
141
|
-
case 'd':
|
|
142
|
-
case 'D':
|
|
143
|
-
case 'F':
|
|
144
|
-
case 'g':
|
|
145
|
-
return 'day';
|
|
146
|
-
// Period
|
|
147
|
-
case 'a': // AM, PM
|
|
148
|
-
case 'b': // am, pm, noon, midnight
|
|
149
|
-
case 'B': // flexible day periods
|
|
150
|
-
return 'ampm';
|
|
151
|
-
// Hour
|
|
152
|
-
case 'h':
|
|
153
|
-
case 'H':
|
|
154
|
-
case 'K':
|
|
155
|
-
case 'k':
|
|
156
|
-
return 'hour';
|
|
157
|
-
// Minute
|
|
158
|
-
case 'm':
|
|
159
|
-
return 'minute';
|
|
160
|
-
// Second
|
|
161
|
-
case 's':
|
|
162
|
-
case 'S':
|
|
163
|
-
case 'A':
|
|
164
|
-
return 'second';
|
|
165
|
-
default:
|
|
166
|
-
throw new RangeError('Invalid range pattern token');
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function processDateTimePattern(pattern, result) {
|
|
170
|
-
var literals = [];
|
|
171
|
-
// Use skeleton to populate result, but use mapped pattern to populate pattern
|
|
172
|
-
var pattern12 = pattern
|
|
173
|
-
// Double apostrophe
|
|
174
|
-
.replace(/'{2}/g, '{apostrophe}')
|
|
175
|
-
// Apostrophe-escaped
|
|
176
|
-
.replace(/'(.*?)'/g, function (_, literal) {
|
|
177
|
-
literals.push(literal);
|
|
178
|
-
return "$$" + (literals.length - 1) + "$$";
|
|
179
|
-
})
|
|
180
|
-
.replace(DATE_TIME_REGEX, function (m) { return matchSkeletonPattern(m, result || {}); });
|
|
181
|
-
//Restore literals
|
|
182
|
-
if (literals.length) {
|
|
183
|
-
pattern12 = pattern12
|
|
184
|
-
.replace(/\$\$(\d+)\$\$/g, function (_, i) {
|
|
185
|
-
return literals[+i];
|
|
186
|
-
})
|
|
187
|
-
.replace(/\{apostrophe\}/g, "'");
|
|
188
|
-
}
|
|
189
|
-
// Handle apostrophe-escaped things
|
|
190
|
-
return [
|
|
191
|
-
pattern12
|
|
192
|
-
.replace(/([\s\uFEFF\xA0])\{ampm\}([\s\uFEFF\xA0])/, '$1')
|
|
193
|
-
.replace('{ampm}', '')
|
|
194
|
-
.replace(expPatternTrimmer, ''),
|
|
195
|
-
pattern12,
|
|
196
|
-
];
|
|
197
|
-
}
|
|
198
|
-
exports.processDateTimePattern = processDateTimePattern;
|
|
199
|
-
/**
|
|
200
|
-
* Parse Date time skeleton into Intl.DateTimeFormatOptions
|
|
201
|
-
* Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
202
|
-
* @public
|
|
203
|
-
* @param skeleton skeleton string
|
|
204
|
-
*/
|
|
205
|
-
function parseDateTimeSkeleton(skeleton, rawPattern, rangePatterns, intervalFormatFallback) {
|
|
206
|
-
if (rawPattern === void 0) { rawPattern = skeleton; }
|
|
207
|
-
var result = {
|
|
208
|
-
pattern: '',
|
|
209
|
-
pattern12: '',
|
|
210
|
-
skeleton: skeleton,
|
|
211
|
-
rawPattern: rawPattern,
|
|
212
|
-
rangePatterns: {},
|
|
213
|
-
rangePatterns12: {},
|
|
214
|
-
};
|
|
215
|
-
if (rangePatterns) {
|
|
216
|
-
for (var k in rangePatterns) {
|
|
217
|
-
var key = skeletonTokenToTable2(k);
|
|
218
|
-
var rawPattern_1 = rangePatterns[k];
|
|
219
|
-
var intervalResult = {
|
|
220
|
-
patternParts: [],
|
|
221
|
-
};
|
|
222
|
-
var _a = processDateTimePattern(rawPattern_1, intervalResult), pattern_1 = _a[0], pattern12_1 = _a[1];
|
|
223
|
-
result.rangePatterns[key] = tslib_1.__assign(tslib_1.__assign({}, intervalResult), { patternParts: splitRangePattern(pattern_1) });
|
|
224
|
-
result.rangePatterns12[key] = tslib_1.__assign(tslib_1.__assign({}, intervalResult), { patternParts: splitRangePattern(pattern12_1) });
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (intervalFormatFallback) {
|
|
228
|
-
var patternParts = splitFallbackRangePattern(intervalFormatFallback);
|
|
229
|
-
result.rangePatterns.default = {
|
|
230
|
-
patternParts: patternParts,
|
|
231
|
-
};
|
|
232
|
-
result.rangePatterns12.default = {
|
|
233
|
-
patternParts: patternParts,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
// Process skeleton
|
|
237
|
-
skeleton.replace(DATE_TIME_REGEX, function (m) { return matchSkeletonPattern(m, result); });
|
|
238
|
-
var _b = processDateTimePattern(rawPattern), pattern = _b[0], pattern12 = _b[1];
|
|
239
|
-
result.pattern = pattern;
|
|
240
|
-
result.pattern12 = pattern12;
|
|
241
|
-
return result;
|
|
242
|
-
}
|
|
243
|
-
exports.parseDateTimeSkeleton = parseDateTimeSkeleton;
|
|
244
|
-
function splitFallbackRangePattern(pattern) {
|
|
245
|
-
var parts = pattern.split(/(\{[0|1]\})/g).filter(Boolean);
|
|
246
|
-
return parts.map(function (pattern) {
|
|
247
|
-
switch (pattern) {
|
|
248
|
-
case '{0}':
|
|
249
|
-
return {
|
|
250
|
-
source: date_time_1.RangePatternType.startRange,
|
|
251
|
-
pattern: pattern,
|
|
252
|
-
};
|
|
253
|
-
case '{1}':
|
|
254
|
-
return {
|
|
255
|
-
source: date_time_1.RangePatternType.endRange,
|
|
256
|
-
pattern: pattern,
|
|
257
|
-
};
|
|
258
|
-
default:
|
|
259
|
-
return {
|
|
260
|
-
source: date_time_1.RangePatternType.shared,
|
|
261
|
-
pattern: pattern,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
exports.splitFallbackRangePattern = splitFallbackRangePattern;
|
|
267
|
-
function splitRangePattern(pattern) {
|
|
268
|
-
var PART_REGEX = /\{(.*?)\}/g;
|
|
269
|
-
// Map of part and index within the string
|
|
270
|
-
var parts = {};
|
|
271
|
-
var match;
|
|
272
|
-
var splitIndex = 0;
|
|
273
|
-
while ((match = PART_REGEX.exec(pattern))) {
|
|
274
|
-
if (!(match[0] in parts)) {
|
|
275
|
-
parts[match[0]] = match.index;
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
splitIndex = match.index;
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
if (!splitIndex) {
|
|
283
|
-
return [
|
|
284
|
-
{
|
|
285
|
-
source: date_time_1.RangePatternType.startRange,
|
|
286
|
-
pattern: pattern,
|
|
287
|
-
},
|
|
288
|
-
];
|
|
289
|
-
}
|
|
290
|
-
return [
|
|
291
|
-
{
|
|
292
|
-
source: date_time_1.RangePatternType.startRange,
|
|
293
|
-
pattern: pattern.slice(0, splitIndex),
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
source: date_time_1.RangePatternType.endRange,
|
|
297
|
-
pattern: pattern.slice(splitIndex),
|
|
298
|
-
},
|
|
299
|
-
];
|
|
300
|
-
}
|
|
301
|
-
exports.splitRangePattern = splitRangePattern;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { IntlDateTimeFormatInternal, TABLE_6 } from '../types/date-time';
|
|
2
|
-
export declare const DATE_TIME_PROPS: Array<keyof Pick<IntlDateTimeFormatInternal, TABLE_6>>;
|
|
3
|
-
export declare const removalPenalty = 120;
|
|
4
|
-
export declare const additionPenalty = 20;
|
|
5
|
-
export declare const differentNumericTypePenalty = 15;
|
|
6
|
-
export declare const longLessPenalty = 8;
|
|
7
|
-
export declare const longMorePenalty = 6;
|
|
8
|
-
export declare const shortLessPenalty = 6;
|
|
9
|
-
export declare const shortMorePenalty = 3;
|
|
10
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DateTimeFormat/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAE,OAAO,EAAC,MAAM,oBAAoB,CAAA;AAEtE,eAAO,MAAM,eAAe,EAAE,KAAK,CACjC,MAAM,IAAI,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAWhD,CAAA;AAED,eAAO,MAAM,cAAc,MAAM,CAAA;AACjC,eAAO,MAAM,eAAe,KAAK,CAAA;AACjC,eAAO,MAAM,2BAA2B,KAAK,CAAA;AAC7C,eAAO,MAAM,eAAe,IAAI,CAAA;AAChC,eAAO,MAAM,eAAe,IAAI,CAAA;AAChC,eAAO,MAAM,gBAAgB,IAAI,CAAA;AACjC,eAAO,MAAM,gBAAgB,IAAI,CAAA"}
|
package/DateTimeFormat/utils.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shortMorePenalty = exports.shortLessPenalty = exports.longMorePenalty = exports.longLessPenalty = exports.differentNumericTypePenalty = exports.additionPenalty = exports.removalPenalty = exports.DATE_TIME_PROPS = void 0;
|
|
4
|
-
exports.DATE_TIME_PROPS = [
|
|
5
|
-
'weekday',
|
|
6
|
-
'era',
|
|
7
|
-
'year',
|
|
8
|
-
'month',
|
|
9
|
-
'day',
|
|
10
|
-
'hour',
|
|
11
|
-
'minute',
|
|
12
|
-
'second',
|
|
13
|
-
'timeZoneName',
|
|
14
|
-
];
|
|
15
|
-
exports.removalPenalty = 120;
|
|
16
|
-
exports.additionPenalty = 20;
|
|
17
|
-
exports.differentNumericTypePenalty = 15;
|
|
18
|
-
exports.longLessPenalty = 8;
|
|
19
|
-
exports.longMorePenalty = 6;
|
|
20
|
-
exports.shortLessPenalty = 6;
|
|
21
|
-
exports.shortMorePenalty = 3;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CanonicalCodeForDisplayNames.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/DisplayNames/CanonicalCodeForDisplayNames.ts"],"names":[],"mappings":"AAcA,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,EACnD,IAAI,EAAE,MAAM,GACX,MAAM,CAqBR"}
|