@formatjs/intl-datetimeformat 7.1.1 → 7.2.0
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 -1
- package/index.js +1 -1
- package/locale-data/yue-Hant.js +997 -997
- package/locale-data/yue.js +997 -997
- package/locale-data/zh-Hant-HK.js +1943 -1935
- package/locale-data/zh-Hant-MO.js +1943 -1935
- package/locale-data/zh-Hant.js +1943 -1935
- package/package.json +7 -7
- package/polyfill-force.js +28 -44
- package/polyfill.iife.js +2305 -3066
- package/polyfill.js +29 -45
- package/should-polyfill.js +38 -50
- package/src/abstract/BasicFormatMatcher.d.ts +5 -5
- package/src/abstract/BasicFormatMatcher.js +87 -103
- package/src/abstract/BestFitFormatMatcher.d.ts +12 -12
- package/src/abstract/BestFitFormatMatcher.js +102 -108
- package/src/abstract/DateTimeStyleFormat.d.ts +2 -2
- package/src/abstract/DateTimeStyleFormat.js +47 -62
- package/src/abstract/FormatDateTime.d.ts +7 -7
- package/src/abstract/FormatDateTime.js +12 -12
- package/src/abstract/FormatDateTimePattern.d.ts +11 -11
- package/src/abstract/FormatDateTimePattern.js +185 -209
- package/src/abstract/FormatDateTimeRange.d.ts +3 -3
- package/src/abstract/FormatDateTimeRange.js +9 -8
- package/src/abstract/FormatDateTimeRangeToParts.d.ts +4 -4
- package/src/abstract/FormatDateTimeRangeToParts.js +14 -12
- package/src/abstract/FormatDateTimeToParts.d.ts +9 -9
- package/src/abstract/FormatDateTimeToParts.js +17 -18
- package/src/abstract/InitializeDateTimeFormat.d.ts +15 -15
- package/src/abstract/InitializeDateTimeFormat.js +206 -184
- package/src/abstract/PartitionDateTimePattern.d.ts +8 -8
- package/src/abstract/PartitionDateTimePattern.js +15 -14
- package/src/abstract/PartitionDateTimeRangePattern.d.ts +4 -4
- package/src/abstract/PartitionDateTimeRangePattern.js +168 -161
- package/src/abstract/ToDateTimeOptions.d.ts +5 -5
- package/src/abstract/ToDateTimeOptions.js +68 -60
- package/src/abstract/ToLocalTime.d.ts +21 -21
- package/src/abstract/ToLocalTime.js +108 -111
- package/src/abstract/skeleton.d.ts +8 -8
- package/src/abstract/skeleton.js +231 -280
- package/src/abstract/utils.d.ts +1 -1
- package/src/abstract/utils.js +21 -20
- package/src/core.d.ts +17 -17
- package/src/core.js +250 -286
- package/src/data/all-tz.generated.d.ts +3 -3
- package/src/data/all-tz.generated.js +458 -458
- package/src/data/links.generated.d.ts +256 -256
- package/src/data/links.generated.js +256 -256
- package/src/get_internal_slots.d.ts +1 -1
- package/src/get_internal_slots.js +8 -7
- package/src/packer.d.ts +2 -2
- package/src/packer.js +23 -35
- package/src/to_locale_string.d.ts +3 -3
- package/src/to_locale_string.js +11 -11
- package/src/types.d.ts +34 -39
- package/src/types.js +1 -1
- package/supported-locales.generated.js +572 -572
- package/test262-main.d.ts +2 -1
- package/test262-main.js +24608 -33141
package/src/packer.js
CHANGED
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./types.js";
|
|
2
|
+
import "@formatjs/ecma402-abstract";
|
|
2
3
|
export function pack(data) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var ts = _a[0], others = _a.slice(1);
|
|
11
|
-
return __spreadArray([ts === '' ? '' : ts.toString(36)], others, true).join(',');
|
|
12
|
-
}), true).join('|');
|
|
13
|
-
}),
|
|
14
|
-
abbrvs: data.abbrvs.join('|'),
|
|
15
|
-
offsets: data.offsets.map(function (o) { return o.toString(36); }).join('|'),
|
|
16
|
-
};
|
|
4
|
+
const zoneNames = Object.keys(data.zones);
|
|
5
|
+
zoneNames.sort();
|
|
6
|
+
return {
|
|
7
|
+
zones: zoneNames.map((zone) => [zone, ...data.zones[zone].map(([ts, ...others]) => [ts === "" ? "" : ts.toString(36), ...others].join(","))].join("|")),
|
|
8
|
+
abbrvs: data.abbrvs.join("|"),
|
|
9
|
+
offsets: data.offsets.map((o) => o.toString(36)).join("|")
|
|
10
|
+
};
|
|
17
11
|
}
|
|
18
12
|
export function unpack(data) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
offsets[+offsetIndex],
|
|
34
|
-
dst === '1',
|
|
35
|
-
];
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return zones;
|
|
13
|
+
const abbrvs = data.abbrvs.split("|");
|
|
14
|
+
const offsets = data.offsets.split("|").map((n) => parseInt(n, 36));
|
|
15
|
+
const packedZones = data.zones;
|
|
16
|
+
const zones = {};
|
|
17
|
+
for (const d of packedZones) {
|
|
18
|
+
const [zone, ...zoneData] = d.split("|");
|
|
19
|
+
zones[zone] = zoneData.map((z) => z.split(",")).map(([ts, abbrvIndex, offsetIndex, dst]) => [
|
|
20
|
+
ts === "" ? -Infinity : parseInt(ts, 36),
|
|
21
|
+
abbrvs[+abbrvIndex],
|
|
22
|
+
offsets[+offsetIndex],
|
|
23
|
+
dst === "1"
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
return zones;
|
|
39
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* Number.prototype.toLocaleString ponyfill
|
|
3
|
+
* https://tc39.es/ecma402/#sup-number.prototype.tolocalestring
|
|
4
|
+
*/
|
|
5
5
|
export declare function toLocaleString(x?: Date | number, locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
|
6
6
|
export declare function toLocaleDateString(x?: Date | number, locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
|
7
7
|
export declare function toLocaleTimeString(x?: Date | number, locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
package/src/to_locale_string.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-cycle
|
|
2
|
-
import { DateTimeFormat } from
|
|
3
|
-
import { ToDateTimeOptions } from
|
|
2
|
+
import { DateTimeFormat } from "./core.js";
|
|
3
|
+
import { ToDateTimeOptions } from "./abstract/ToDateTimeOptions.js";
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
* Number.prototype.toLocaleString ponyfill
|
|
6
|
+
* https://tc39.es/ecma402/#sup-number.prototype.tolocalestring
|
|
7
|
+
*/
|
|
8
8
|
export function toLocaleString(x, locales, options) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const dtf = new DateTimeFormat(locales, options);
|
|
10
|
+
return dtf.format(x);
|
|
11
11
|
}
|
|
12
12
|
export function toLocaleDateString(x, locales, options) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const dtf = new DateTimeFormat(locales, ToDateTimeOptions(options, "date", "date"));
|
|
14
|
+
return dtf.format(x);
|
|
15
15
|
}
|
|
16
16
|
export function toLocaleTimeString(x, locales, options) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const dtf = new DateTimeFormat(locales, ToDateTimeOptions(options, "time", "time"));
|
|
18
|
+
return dtf.format(x);
|
|
19
19
|
}
|
package/src/types.d.ts
CHANGED
|
@@ -1,47 +1,42 @@
|
|
|
1
|
-
import { LocaleData, DateTimeFormatLocaleInternalData, IntervalFormatsData } from
|
|
1
|
+
import { type LocaleData, type DateTimeFormatLocaleInternalData, type IntervalFormatsData } from "@formatjs/ecma402-abstract";
|
|
2
2
|
export interface PackedData {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
zones: string[];
|
|
4
|
+
abbrvs: string;
|
|
5
|
+
offsets: string;
|
|
6
6
|
}
|
|
7
7
|
export interface UnpackedData {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
zones: Record<string, ZoneData[]>;
|
|
9
|
+
abbrvs: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Offset in seconds, base 36
|
|
12
|
+
*/
|
|
13
|
+
offsets: number[];
|
|
14
14
|
}
|
|
15
|
-
export type ZoneData = [
|
|
16
|
-
number | string,
|
|
17
|
-
number,
|
|
18
|
-
number,
|
|
19
|
-
number
|
|
20
|
-
];
|
|
15
|
+
export type ZoneData = [number | string, number, number, number];
|
|
21
16
|
export type RawDateTimeLocaleData = LocaleData<RawDateTimeLocaleInternalData>;
|
|
22
|
-
export type RawDateTimeLocaleInternalData = Omit<DateTimeFormatLocaleInternalData,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
17
|
+
export type RawDateTimeLocaleInternalData = Omit<DateTimeFormatLocaleInternalData, "dateFormat" | "timeFormat" | "dateTimeFormat" | "formats" | "intervalFormats"> & {
|
|
18
|
+
formats: Record<string, Record<string, string>>;
|
|
19
|
+
dateFormat: {
|
|
20
|
+
full: string;
|
|
21
|
+
long: string;
|
|
22
|
+
medium: string;
|
|
23
|
+
short: string;
|
|
24
|
+
};
|
|
25
|
+
timeFormat: {
|
|
26
|
+
full: string;
|
|
27
|
+
long: string;
|
|
28
|
+
medium: string;
|
|
29
|
+
short: string;
|
|
30
|
+
};
|
|
31
|
+
intervalFormats: IntervalFormatsData;
|
|
32
|
+
dateTimeFormat: {
|
|
33
|
+
full: string;
|
|
34
|
+
long: string;
|
|
35
|
+
medium: string;
|
|
36
|
+
short: string;
|
|
37
|
+
};
|
|
43
38
|
};
|
|
44
39
|
export type TimeZoneNameData = Record<string, {
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
long?: [string, string];
|
|
41
|
+
short?: [string, string];
|
|
47
42
|
}>;
|
package/src/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import "@formatjs/ecma402-abstract";
|