@formatjs/ecma402-abstract 1.8.0 → 1.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/IsValidTimeZoneName.d.ts +1 -1
- package/IsValidTimeZoneName.d.ts.map +1 -1
- package/IsValidTimeZoneName.js +6 -1
- package/index.d.ts +1 -23
- package/index.d.ts.map +1 -1
- package/index.js +13 -38
- package/lib/IsValidTimeZoneName.d.ts +1 -1
- package/lib/IsValidTimeZoneName.d.ts.map +1 -1
- package/lib/IsValidTimeZoneName.js +6 -1
- 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 +2 -1
- package/lib/types/date-time.d.ts.map +1 -1
- package/package.json +1 -1
- package/types/date-time.d.ts +2 -1
- 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 -128
- 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 -124
- 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,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateTimeStyleFormat = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
5
|
-
function DateTimeStyleFormat(dateStyle, timeStyle, dataLocaleData) {
|
|
6
|
-
var dateFormat, timeFormat;
|
|
7
|
-
if (timeStyle !== undefined) {
|
|
8
|
-
utils_1.invariant(timeStyle === 'full' ||
|
|
9
|
-
timeStyle === 'long' ||
|
|
10
|
-
timeStyle === 'medium' ||
|
|
11
|
-
timeStyle === 'short', 'invalid timeStyle');
|
|
12
|
-
timeFormat = dataLocaleData.timeFormat[timeStyle];
|
|
13
|
-
}
|
|
14
|
-
if (dateStyle !== undefined) {
|
|
15
|
-
utils_1.invariant(dateStyle === 'full' ||
|
|
16
|
-
dateStyle === 'long' ||
|
|
17
|
-
dateStyle === 'medium' ||
|
|
18
|
-
dateStyle === 'short', 'invalid dateStyle');
|
|
19
|
-
dateFormat = dataLocaleData.dateFormat[dateStyle];
|
|
20
|
-
}
|
|
21
|
-
if (dateStyle !== undefined && timeStyle !== undefined) {
|
|
22
|
-
var format = {};
|
|
23
|
-
for (var field in dateFormat) {
|
|
24
|
-
if (field !== 'pattern') {
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
format[field] = dateFormat[field];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
for (var field in timeFormat) {
|
|
30
|
-
if (field !== 'pattern' && field !== 'pattern12') {
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
format[field] = timeFormat[field];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
var connector = dataLocaleData.dateTimeFormat[dateStyle];
|
|
36
|
-
var pattern = connector
|
|
37
|
-
.replace('{0}', timeFormat.pattern)
|
|
38
|
-
.replace('{1}', dateFormat.pattern);
|
|
39
|
-
format.pattern = pattern;
|
|
40
|
-
if ('pattern12' in timeFormat) {
|
|
41
|
-
var pattern12 = connector
|
|
42
|
-
.replace('{0}', timeFormat.pattern12)
|
|
43
|
-
.replace('{1}', dateFormat.pattern);
|
|
44
|
-
format.pattern12 = pattern12;
|
|
45
|
-
}
|
|
46
|
-
return format;
|
|
47
|
-
}
|
|
48
|
-
if (timeStyle !== undefined) {
|
|
49
|
-
return timeFormat;
|
|
50
|
-
}
|
|
51
|
-
utils_1.invariant(dateStyle !== undefined, 'dateStyle should not be undefined');
|
|
52
|
-
return dateFormat;
|
|
53
|
-
}
|
|
54
|
-
exports.DateTimeStyleFormat = DateTimeStyleFormat;
|
|
@@ -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,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormatDateTime = void 0;
|
|
4
|
-
var PartitionDateTimePattern_1 = require("./PartitionDateTimePattern");
|
|
5
|
-
/**
|
|
6
|
-
* https://tc39.es/ecma402/#sec-formatdatetime
|
|
7
|
-
* @param dtf DateTimeFormat
|
|
8
|
-
* @param x
|
|
9
|
-
*/
|
|
10
|
-
function FormatDateTime(dtf, x, implDetails) {
|
|
11
|
-
var parts = PartitionDateTimePattern_1.PartitionDateTimePattern(dtf, x, implDetails);
|
|
12
|
-
var result = '';
|
|
13
|
-
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
|
14
|
-
var part = parts_1[_i];
|
|
15
|
-
result += part.value;
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
exports.FormatDateTime = FormatDateTime;
|
|
@@ -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;AAehC,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,gCAAgC,GAAG,sBAAsB,4BAsHvE"}
|