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