@formatjs/intl-datetimeformat 7.1.0 → 7.1.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.
Files changed (60) hide show
  1. package/add-all-tz.js +319 -318
  2. package/add-golden-tz.js +1 -1
  3. package/index.d.ts +1 -1
  4. package/index.js +1 -1
  5. package/package.json +5 -5
  6. package/polyfill-force.js +28 -44
  7. package/polyfill.iife.js +2803 -3046
  8. package/polyfill.js +29 -45
  9. package/should-polyfill.js +38 -50
  10. package/src/abstract/BasicFormatMatcher.d.ts +5 -5
  11. package/src/abstract/BasicFormatMatcher.js +87 -103
  12. package/src/abstract/BestFitFormatMatcher.d.ts +12 -12
  13. package/src/abstract/BestFitFormatMatcher.js +102 -108
  14. package/src/abstract/DateTimeStyleFormat.d.ts +2 -2
  15. package/src/abstract/DateTimeStyleFormat.js +47 -62
  16. package/src/abstract/FormatDateTime.d.ts +7 -7
  17. package/src/abstract/FormatDateTime.js +12 -12
  18. package/src/abstract/FormatDateTimePattern.d.ts +11 -11
  19. package/src/abstract/FormatDateTimePattern.js +185 -198
  20. package/src/abstract/FormatDateTimeRange.d.ts +3 -3
  21. package/src/abstract/FormatDateTimeRange.js +9 -8
  22. package/src/abstract/FormatDateTimeRangeToParts.d.ts +4 -4
  23. package/src/abstract/FormatDateTimeRangeToParts.js +14 -12
  24. package/src/abstract/FormatDateTimeToParts.d.ts +9 -9
  25. package/src/abstract/FormatDateTimeToParts.js +17 -18
  26. package/src/abstract/InitializeDateTimeFormat.d.ts +15 -15
  27. package/src/abstract/InitializeDateTimeFormat.js +206 -184
  28. package/src/abstract/PartitionDateTimePattern.d.ts +8 -8
  29. package/src/abstract/PartitionDateTimePattern.js +15 -14
  30. package/src/abstract/PartitionDateTimeRangePattern.d.ts +4 -4
  31. package/src/abstract/PartitionDateTimeRangePattern.js +168 -161
  32. package/src/abstract/ToDateTimeOptions.d.ts +5 -5
  33. package/src/abstract/ToDateTimeOptions.js +68 -60
  34. package/src/abstract/ToLocalTime.d.ts +21 -21
  35. package/src/abstract/ToLocalTime.js +116 -45
  36. package/src/abstract/skeleton.d.ts +8 -8
  37. package/src/abstract/skeleton.js +231 -280
  38. package/src/abstract/utils.d.ts +1 -1
  39. package/src/abstract/utils.js +21 -20
  40. package/src/core.d.ts +17 -17
  41. package/src/core.js +250 -286
  42. package/src/data/all-tz.generated.d.ts +8 -0
  43. package/src/data/all-tz.generated.js +462 -0
  44. package/src/data/links.generated.d.ts +261 -0
  45. package/src/data/links.generated.js +260 -0
  46. package/src/get_internal_slots.d.ts +3 -1
  47. package/src/get_internal_slots.js +8 -7
  48. package/src/packer.d.ts +2 -2
  49. package/src/packer.js +23 -35
  50. package/src/to_locale_string.d.ts +3 -3
  51. package/src/to_locale_string.js +11 -11
  52. package/src/types.d.ts +34 -39
  53. package/src/types.js +1 -1
  54. package/supported-locales.generated.js +573 -1
  55. package/test262-main.d.ts +4 -1
  56. package/test262-main.js +24600 -44193
  57. package/src/data/all-tz.d.ts +0 -6
  58. package/src/data/all-tz.js +0 -461
  59. package/src/data/links.d.ts +0 -259
  60. package/src/data/links.js +0 -260
@@ -1,2 +1,2 @@
1
- import { DateTimeFormatLocaleInternalData, Formats } from '@formatjs/ecma402-abstract';
2
- export declare function DateTimeStyleFormat(dateStyle: Intl.DateTimeFormatOptions['dateStyle'], timeStyle: Intl.DateTimeFormatOptions['timeStyle'], dataLocaleData: DateTimeFormatLocaleInternalData): Formats;
1
+ import { type DateTimeFormatLocaleInternalData, type Formats } from "@formatjs/ecma402-abstract";
2
+ export declare function DateTimeStyleFormat(dateStyle: Intl.DateTimeFormatOptions["dateStyle"], timeStyle: Intl.DateTimeFormatOptions["timeStyle"], dataLocaleData: DateTimeFormatLocaleInternalData): Formats;
@@ -1,64 +1,49 @@
1
- import { invariant, } from '@formatjs/ecma402-abstract';
1
+ import { invariant } from "@formatjs/ecma402-abstract";
2
2
  export function DateTimeStyleFormat(dateStyle, timeStyle, dataLocaleData) {
3
- var dateFormat, timeFormat;
4
- if (timeStyle !== undefined) {
5
- invariant(timeStyle === 'full' ||
6
- timeStyle === 'long' ||
7
- timeStyle === 'medium' ||
8
- timeStyle === 'short', 'invalid timeStyle');
9
- timeFormat = dataLocaleData.timeFormat[timeStyle];
10
- }
11
- if (dateStyle !== undefined) {
12
- invariant(dateStyle === 'full' ||
13
- dateStyle === 'long' ||
14
- dateStyle === 'medium' ||
15
- dateStyle === 'short', 'invalid dateStyle');
16
- dateFormat = dataLocaleData.dateFormat[dateStyle];
17
- }
18
- if (dateStyle !== undefined && timeStyle !== undefined) {
19
- var format = {};
20
- for (var field in dateFormat) {
21
- if (field !== 'pattern' &&
22
- field !== 'rangePatterns' &&
23
- field !== 'rangePatterns12') {
24
- // @ts-ignore
25
- format[field] = dateFormat[field];
26
- }
27
- }
28
- for (var field in timeFormat) {
29
- if (field !== 'pattern' &&
30
- field !== 'pattern12' &&
31
- field !== 'rangePatterns' &&
32
- field !== 'rangePatterns12') {
33
- // @ts-ignore
34
- format[field] = timeFormat[field];
35
- }
36
- }
37
- var connector = dataLocaleData.dateTimeFormat[dateStyle];
38
- var pattern = connector
39
- .replace('{0}', timeFormat.pattern)
40
- .replace('{1}', dateFormat.pattern);
41
- format.pattern = pattern;
42
- if ('pattern12' in timeFormat) {
43
- var pattern12 = connector
44
- .replace('{0}', timeFormat.pattern12)
45
- .replace('{1}', dateFormat.pattern);
46
- format.pattern12 = pattern12;
47
- }
48
- // Merge rangePatterns from timeFormat (for time-related differences)
49
- // This is needed for formatRange to work with dateStyle/timeStyle
50
- // See: https://github.com/formatjs/formatjs/issues/4168
51
- if (timeFormat.rangePatterns) {
52
- format.rangePatterns = timeFormat.rangePatterns;
53
- }
54
- if (timeFormat.rangePatterns12) {
55
- format.rangePatterns12 = timeFormat.rangePatterns12;
56
- }
57
- return format;
58
- }
59
- if (timeStyle !== undefined) {
60
- return timeFormat;
61
- }
62
- invariant(dateStyle !== undefined, 'dateStyle should not be undefined');
63
- return dateFormat;
3
+ let dateFormat, timeFormat;
4
+ if (timeStyle !== undefined) {
5
+ invariant(timeStyle === "full" || timeStyle === "long" || timeStyle === "medium" || timeStyle === "short", "invalid timeStyle");
6
+ timeFormat = dataLocaleData.timeFormat[timeStyle];
7
+ }
8
+ if (dateStyle !== undefined) {
9
+ invariant(dateStyle === "full" || dateStyle === "long" || dateStyle === "medium" || dateStyle === "short", "invalid dateStyle");
10
+ dateFormat = dataLocaleData.dateFormat[dateStyle];
11
+ }
12
+ if (dateStyle !== undefined && timeStyle !== undefined) {
13
+ const format = {};
14
+ for (const field in dateFormat) {
15
+ if (field !== "pattern" && field !== "rangePatterns" && field !== "rangePatterns12") {
16
+ // @ts-ignore
17
+ format[field] = dateFormat[field];
18
+ }
19
+ }
20
+ for (const field in timeFormat) {
21
+ if (field !== "pattern" && field !== "pattern12" && field !== "rangePatterns" && field !== "rangePatterns12") {
22
+ // @ts-ignore
23
+ format[field] = timeFormat[field];
24
+ }
25
+ }
26
+ const connector = dataLocaleData.dateTimeFormat[dateStyle];
27
+ const pattern = connector.replace("{0}", timeFormat.pattern).replace("{1}", dateFormat.pattern);
28
+ format.pattern = pattern;
29
+ if ("pattern12" in timeFormat) {
30
+ const pattern12 = connector.replace("{0}", timeFormat.pattern12).replace("{1}", dateFormat.pattern);
31
+ format.pattern12 = pattern12;
32
+ }
33
+ // Merge rangePatterns from timeFormat (for time-related differences)
34
+ // This is needed for formatRange to work with dateStyle/timeStyle
35
+ // See: https://github.com/formatjs/formatjs/issues/4168
36
+ if (timeFormat.rangePatterns) {
37
+ format.rangePatterns = timeFormat.rangePatterns;
38
+ }
39
+ if (timeFormat.rangePatterns12) {
40
+ format.rangePatterns12 = timeFormat.rangePatterns12;
41
+ }
42
+ return format;
43
+ }
44
+ if (timeStyle !== undefined) {
45
+ return timeFormat;
46
+ }
47
+ invariant(dateStyle !== undefined, "dateStyle should not be undefined");
48
+ return dateFormat;
64
49
  }
@@ -1,9 +1,9 @@
1
- import { DateTimeFormat } from '@formatjs/ecma402-abstract';
2
- import Decimal from 'decimal.js';
3
- import { PartitionDateTimePattern } from './PartitionDateTimePattern.js';
1
+ import { type DateTimeFormat } from "@formatjs/ecma402-abstract";
2
+ import type Decimal from "decimal.js";
3
+ import { PartitionDateTimePattern } from "./PartitionDateTimePattern.js";
4
4
  /**
5
- * https://tc39.es/ecma402/#sec-formatdatetime
6
- * @param dtf DateTimeFormat
7
- * @param x
8
- */
5
+ * https://tc39.es/ecma402/#sec-formatdatetime
6
+ * @param dtf DateTimeFormat
7
+ * @param x
8
+ */
9
9
  export declare function FormatDateTime(dtf: Intl.DateTimeFormat | DateTimeFormat, x: Decimal, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): string;
@@ -1,15 +1,15 @@
1
- import { PartitionDateTimePattern } from './PartitionDateTimePattern.js';
1
+ import "@formatjs/ecma402-abstract";
2
+ import { PartitionDateTimePattern } from "./PartitionDateTimePattern.js";
2
3
  /**
3
- * https://tc39.es/ecma402/#sec-formatdatetime
4
- * @param dtf DateTimeFormat
5
- * @param x
6
- */
4
+ * https://tc39.es/ecma402/#sec-formatdatetime
5
+ * @param dtf DateTimeFormat
6
+ * @param x
7
+ */
7
8
  export function FormatDateTime(dtf, x, implDetails) {
8
- var parts = PartitionDateTimePattern(dtf, x, implDetails);
9
- var result = '';
10
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
11
- var part = parts_1[_i];
12
- result += part.value;
13
- }
14
- return result;
9
+ const parts = PartitionDateTimePattern(dtf, x, implDetails);
10
+ let result = "";
11
+ for (const part of parts) {
12
+ result += part.value;
13
+ }
14
+ return result;
15
15
  }
@@ -1,14 +1,14 @@
1
- import { DateTimeFormat, DateTimeFormatLocaleInternalData, IntlDateTimeFormatInternal, IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
- import Decimal from 'decimal.js';
3
- import { ToLocalTimeImplDetails } from './ToLocalTime.js';
1
+ import { type DateTimeFormat, type DateTimeFormatLocaleInternalData, type IntlDateTimeFormatInternal, type IntlDateTimeFormatPart } from "@formatjs/ecma402-abstract";
2
+ import Decimal from "decimal.js";
3
+ import { type ToLocalTimeImplDetails } from "./ToLocalTime.js";
4
4
  export interface FormatDateTimePatternImplDetails {
5
- getInternalSlots(dtf: Intl.DateTimeFormat | DateTimeFormat): IntlDateTimeFormatInternal;
6
- localeData: Record<string, DateTimeFormatLocaleInternalData>;
7
- getDefaultTimeZone(): string;
5
+ getInternalSlots(dtf: Intl.DateTimeFormat | DateTimeFormat): IntlDateTimeFormatInternal;
6
+ localeData: Record<string, DateTimeFormatLocaleInternalData>;
7
+ getDefaultTimeZone(): string;
8
8
  }
9
9
  /**
10
- * https://tc39.es/ecma402/#sec-partitiondatetimepattern
11
- * @param dtf
12
- * @param x
13
- */
14
- export declare function FormatDateTimePattern(dtf: Intl.DateTimeFormat | DateTimeFormat, patternParts: IntlDateTimeFormatPart[], x: Decimal, { getInternalSlots, localeData, getDefaultTimeZone, tzData, }: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
10
+ * https://tc39.es/ecma402/#sec-partitiondatetimepattern
11
+ * @param dtf
12
+ * @param x
13
+ */
14
+ export declare function FormatDateTimePattern(dtf: Intl.DateTimeFormat | DateTimeFormat, patternParts: IntlDateTimeFormatPart[], x: Decimal, { getInternalSlots, localeData, getDefaultTimeZone, tzData }: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
@@ -1,204 +1,191 @@
1
- import { TimeClip, createMemoizedNumberFormat, } from '@formatjs/ecma402-abstract';
2
- import Decimal from 'decimal.js';
3
- import { ToLocalTime } from './ToLocalTime.js';
4
- import { DATE_TIME_PROPS } from './utils.js';
1
+ import { TimeClip, createMemoizedNumberFormat } from "@formatjs/ecma402-abstract";
2
+ import Decimal from "decimal.js";
3
+ import { ToLocalTime } from "./ToLocalTime.js";
4
+ import { DATE_TIME_PROPS } from "./utils.js";
5
5
  function pad(n) {
6
- if (n < 10) {
7
- return "0".concat(n);
8
- }
9
- return String(n);
6
+ if (n < 10) {
7
+ return `0${n}`;
8
+ }
9
+ return String(n);
10
10
  }
11
11
  function offsetToGmtString(gmtFormat, hourFormat, offsetInMs, style) {
12
- var offsetInMinutes = Math.floor(offsetInMs / 60000);
13
- var mins = Math.abs(offsetInMinutes) % 60;
14
- var hours = Math.floor(Math.abs(offsetInMinutes) / 60);
15
- var _a = hourFormat.split(';'), positivePattern = _a[0], negativePattern = _a[1];
16
- var offsetStr = '';
17
- var pattern = offsetInMs < 0 ? negativePattern : positivePattern;
18
- if (style === 'long') {
19
- offsetStr = pattern
20
- .replace('HH', pad(hours))
21
- .replace('H', String(hours))
22
- .replace('mm', pad(mins))
23
- .replace('m', String(mins));
24
- }
25
- else if (mins || hours) {
26
- if (!mins) {
27
- pattern = pattern.replace(/:?m+/, '');
28
- }
29
- offsetStr = pattern.replace(/H+/, String(hours)).replace(/m+/, String(mins));
30
- }
31
- return gmtFormat.replace('{0}', offsetStr);
12
+ const offsetInMinutes = Math.floor(offsetInMs / 6e4);
13
+ const mins = Math.abs(offsetInMinutes) % 60;
14
+ const hours = Math.floor(Math.abs(offsetInMinutes) / 60);
15
+ const [positivePattern, negativePattern] = hourFormat.split(";");
16
+ let offsetStr = "";
17
+ let pattern = offsetInMs < 0 ? negativePattern : positivePattern;
18
+ if (style === "long") {
19
+ offsetStr = pattern.replace("HH", pad(hours)).replace("H", String(hours)).replace("mm", pad(mins)).replace("m", String(mins));
20
+ } else if (mins || hours) {
21
+ if (!mins) {
22
+ pattern = pattern.replace(/:?m+/, "");
23
+ }
24
+ offsetStr = pattern.replace(/H+/, String(hours)).replace(/m+/, String(mins));
25
+ }
26
+ return gmtFormat.replace("{0}", offsetStr);
32
27
  }
33
28
  /**
34
- * https://tc39.es/ecma402/#sec-partitiondatetimepattern
35
- * @param dtf
36
- * @param x
37
- */
38
- export function FormatDateTimePattern(dtf, patternParts, x, _a) {
39
- var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, getDefaultTimeZone = _a.getDefaultTimeZone, tzData = _a.tzData;
40
- x = TimeClip(x);
41
- /** IMPL START */
42
- var internalSlots = getInternalSlots(dtf);
43
- var dataLocale = internalSlots.dataLocale;
44
- var dataLocaleData = localeData[dataLocale];
45
- /** IMPL END */
46
- var locale = internalSlots.locale;
47
- var nfOptions = Object.create(null);
48
- nfOptions.useGrouping = false;
49
- var nf = createMemoizedNumberFormat(locale, nfOptions);
50
- var nf2Options = Object.create(null);
51
- nf2Options.minimumIntegerDigits = 2;
52
- nf2Options.useGrouping = false;
53
- var nf2 = createMemoizedNumberFormat(locale, nf2Options);
54
- var fractionalSecondDigits = internalSlots.fractionalSecondDigits;
55
- var nf3;
56
- if (fractionalSecondDigits !== undefined) {
57
- var nf3Options = Object.create(null);
58
- nf3Options.minimumIntegerDigits = fractionalSecondDigits;
59
- nf3Options.useGrouping = false;
60
- nf3 = createMemoizedNumberFormat(locale, nf3Options);
61
- }
62
- var tm = ToLocalTime(x,
63
- // @ts-ignore
64
- internalSlots.calendar, internalSlots.timeZone, { tzData: tzData });
65
- var result = [];
66
- // Check if month is stand-alone (no other date fields like day, year, weekday)
67
- var hasMonth = patternParts.some(function (part) { return part.type === 'month'; });
68
- var hasOtherDateFields = patternParts.some(function (part) {
69
- return part.type === 'day' ||
70
- part.type === 'year' ||
71
- part.type === 'weekday' ||
72
- part.type === 'era';
73
- });
74
- var isMonthStandalone = hasMonth && !hasOtherDateFields;
75
- for (var _i = 0, patternParts_1 = patternParts; _i < patternParts_1.length; _i++) {
76
- var patternPart = patternParts_1[_i];
77
- var p = patternPart.type;
78
- if (p === 'literal') {
79
- result.push({
80
- type: 'literal',
81
- value: patternPart.value,
82
- });
83
- }
84
- else if (p === 'fractionalSecondDigits') {
85
- var v = new Decimal(tm.millisecond)
86
- .times(10)
87
- .pow((fractionalSecondDigits || 0) - 3)
88
- .floor()
89
- .toNumber();
90
- result.push({
91
- type: 'fractionalSecond',
92
- value: nf3.format(v),
93
- });
94
- }
95
- else if (p === 'dayPeriod') {
96
- var f = internalSlots.dayPeriod;
97
- // @ts-ignore
98
- var fv = tm[f];
99
- result.push({ type: p, value: fv });
100
- }
101
- else if (p === 'timeZoneName') {
102
- var f = internalSlots.timeZoneName;
103
- var fv = void 0;
104
- var timeZoneName = dataLocaleData.timeZoneName, gmtFormat = dataLocaleData.gmtFormat, hourFormat = dataLocaleData.hourFormat;
105
- var timeZone = internalSlots.timeZone || getDefaultTimeZone();
106
- var timeZoneData = timeZoneName[timeZone];
107
- if (timeZoneData && timeZoneData[f]) {
108
- fv = timeZoneData[f][+tm.inDST];
109
- }
110
- else {
111
- // Fallback to gmtFormat
112
- fv = offsetToGmtString(gmtFormat, hourFormat, tm.timeZoneOffset, f);
113
- }
114
- result.push({ type: p, value: fv });
115
- }
116
- else if (DATE_TIME_PROPS.indexOf(p) > -1) {
117
- var fv = '';
118
- var f = internalSlots[p];
119
- // @ts-ignore
120
- var v = tm[p];
121
- if (p === 'year' && v <= 0) {
122
- v = 1 - v;
123
- }
124
- if (p === 'month') {
125
- v++;
126
- }
127
- var hourCycle = internalSlots.hourCycle;
128
- if (p === 'hour' && (hourCycle === 'h11' || hourCycle === 'h12')) {
129
- v = v % 12;
130
- if (v === 0 && hourCycle === 'h12') {
131
- v = 12;
132
- }
133
- }
134
- if (p === 'hour' && hourCycle === 'h24') {
135
- if (v === 0) {
136
- v = 24;
137
- }
138
- }
139
- if (f === 'numeric') {
140
- fv = nf.format(v);
141
- }
142
- else if (f === '2-digit') {
143
- fv = nf2.format(v);
144
- if (fv.length > 2) {
145
- fv = fv.slice(fv.length - 2, fv.length);
146
- }
147
- }
148
- else if (f === 'narrow' || f === 'short' || f === 'long') {
149
- if (p === 'era') {
150
- fv = dataLocaleData[p][f][v];
151
- }
152
- else if (p === 'month') {
153
- // Use stand-alone month form if available and month is displayed alone
154
- var monthData = isMonthStandalone && dataLocaleData.monthStandalone
155
- ? dataLocaleData.monthStandalone
156
- : dataLocaleData.month;
157
- fv = monthData[f][v - 1];
158
- }
159
- else {
160
- fv = dataLocaleData[p][f][v];
161
- }
162
- }
163
- result.push({
164
- type: p,
165
- value: fv,
166
- });
167
- }
168
- else if (p === 'ampm') {
169
- var v = tm.hour;
170
- var fv = void 0;
171
- if (v > 11) {
172
- fv = dataLocaleData.pm;
173
- }
174
- else {
175
- fv = dataLocaleData.am;
176
- }
177
- result.push({
178
- type: 'dayPeriod',
179
- value: fv,
180
- });
181
- }
182
- else if (p === 'relatedYear') {
183
- var v = tm.relatedYear;
184
- // @ts-ignore
185
- var fv = nf.format(v);
186
- result.push({
187
- // @ts-ignore TODO: Fix TS type
188
- type: 'relatedYear',
189
- value: fv,
190
- });
191
- }
192
- else if (p === 'yearName') {
193
- var v = tm.yearName;
194
- // @ts-ignore
195
- var fv = nf.format(v);
196
- result.push({
197
- // @ts-ignore TODO: Fix TS type
198
- type: 'yearName',
199
- value: fv,
200
- });
201
- }
202
- }
203
- return result;
29
+ * https://tc39.es/ecma402/#sec-partitiondatetimepattern
30
+ * @param dtf
31
+ * @param x
32
+ */
33
+ export function FormatDateTimePattern(dtf, patternParts, x, { getInternalSlots, localeData, getDefaultTimeZone, tzData }) {
34
+ x = TimeClip(x);
35
+ /** IMPL START */
36
+ const internalSlots = getInternalSlots(dtf);
37
+ const dataLocale = internalSlots.dataLocale;
38
+ const dataLocaleData = localeData[dataLocale];
39
+ /** IMPL END */
40
+ const locale = internalSlots.locale;
41
+ const nfOptions = Object.create(null);
42
+ nfOptions.useGrouping = false;
43
+ const nf = createMemoizedNumberFormat(locale, nfOptions);
44
+ const nf2Options = Object.create(null);
45
+ nf2Options.minimumIntegerDigits = 2;
46
+ nf2Options.useGrouping = false;
47
+ const nf2 = createMemoizedNumberFormat(locale, nf2Options);
48
+ const fractionalSecondDigits = internalSlots.fractionalSecondDigits;
49
+ let nf3;
50
+ if (fractionalSecondDigits !== undefined) {
51
+ const nf3Options = Object.create(null);
52
+ nf3Options.minimumIntegerDigits = fractionalSecondDigits;
53
+ nf3Options.useGrouping = false;
54
+ nf3 = createMemoizedNumberFormat(locale, nf3Options);
55
+ }
56
+ const tm = ToLocalTime(
57
+ x,
58
+ // @ts-ignore
59
+ internalSlots.calendar,
60
+ internalSlots.timeZone,
61
+ { tzData }
62
+ );
63
+ const result = [];
64
+ // Check if month is stand-alone (no other date fields like day, year, weekday)
65
+ const hasMonth = patternParts.some((part) => part.type === "month");
66
+ const hasOtherDateFields = patternParts.some((part) => part.type === "day" || part.type === "year" || part.type === "weekday" || part.type === "era");
67
+ const isMonthStandalone = hasMonth && !hasOtherDateFields;
68
+ for (const patternPart of patternParts) {
69
+ const p = patternPart.type;
70
+ if (p === "literal") {
71
+ result.push({
72
+ type: "literal",
73
+ value: patternPart.value
74
+ });
75
+ } else if (p === "fractionalSecondDigits") {
76
+ const v = new Decimal(tm.millisecond).times(10).pow((fractionalSecondDigits || 0) - 3).floor().toNumber();
77
+ result.push({
78
+ type: "fractionalSecond",
79
+ value: nf3.format(v)
80
+ });
81
+ } else if (p === "dayPeriod") {
82
+ const f = internalSlots.dayPeriod;
83
+ // @ts-ignore
84
+ const fv = tm[f];
85
+ result.push({
86
+ type: p,
87
+ value: fv
88
+ });
89
+ } else if (p === "timeZoneName") {
90
+ const f = internalSlots.timeZoneName;
91
+ let fv;
92
+ const { timeZoneName, gmtFormat, hourFormat } = dataLocaleData;
93
+ const timeZone = internalSlots.timeZone || getDefaultTimeZone();
94
+ const timeZoneData = timeZoneName[timeZone];
95
+ if (timeZoneData && timeZoneData[f]) {
96
+ const names = timeZoneData[f];
97
+ // GH #5114: If in DST and both standard/daylight names are the same,
98
+ // fall back to GMT offset format (matches native browser behavior).
99
+ // This handles locales where CLDR doesn't provide a daylight name.
100
+ // NOTE: This is a formatjs implementation detail - ECMA-402 doesn't
101
+ // explicitly specify behavior for missing DST names in locale data.
102
+ if (tm.inDST && names.length >= 2 && names[0] === names[1]) {
103
+ fv = offsetToGmtString(gmtFormat, hourFormat, tm.timeZoneOffset, f);
104
+ } else {
105
+ fv = names[+tm.inDST];
106
+ }
107
+ } else {
108
+ // Fallback to gmtFormat
109
+ fv = offsetToGmtString(gmtFormat, hourFormat, tm.timeZoneOffset, f);
110
+ }
111
+ result.push({
112
+ type: p,
113
+ value: fv
114
+ });
115
+ } else if (DATE_TIME_PROPS.indexOf(p) > -1) {
116
+ let fv = "";
117
+ const f = internalSlots[p];
118
+ // @ts-ignore
119
+ let v = tm[p];
120
+ if (p === "year" && v <= 0) {
121
+ v = 1 - v;
122
+ }
123
+ if (p === "month") {
124
+ v++;
125
+ }
126
+ const hourCycle = internalSlots.hourCycle;
127
+ if (p === "hour" && (hourCycle === "h11" || hourCycle === "h12")) {
128
+ v = v % 12;
129
+ if (v === 0 && hourCycle === "h12") {
130
+ v = 12;
131
+ }
132
+ }
133
+ if (p === "hour" && hourCycle === "h24") {
134
+ if (v === 0) {
135
+ v = 24;
136
+ }
137
+ }
138
+ if (f === "numeric") {
139
+ fv = nf.format(v);
140
+ } else if (f === "2-digit") {
141
+ fv = nf2.format(v);
142
+ if (fv.length > 2) {
143
+ fv = fv.slice(fv.length - 2, fv.length);
144
+ }
145
+ } else if (f === "narrow" || f === "short" || f === "long") {
146
+ if (p === "era") {
147
+ fv = dataLocaleData[p][f][v];
148
+ } else if (p === "month") {
149
+ // Use stand-alone month form if available and month is displayed alone
150
+ const monthData = isMonthStandalone && dataLocaleData.monthStandalone ? dataLocaleData.monthStandalone : dataLocaleData.month;
151
+ fv = monthData[f][v - 1];
152
+ } else {
153
+ fv = dataLocaleData[p][f][v];
154
+ }
155
+ }
156
+ result.push({
157
+ type: p,
158
+ value: fv
159
+ });
160
+ } else if (p === "ampm") {
161
+ const v = tm.hour;
162
+ let fv;
163
+ if (v > 11) {
164
+ fv = dataLocaleData.pm;
165
+ } else {
166
+ fv = dataLocaleData.am;
167
+ }
168
+ result.push({
169
+ type: "dayPeriod",
170
+ value: fv
171
+ });
172
+ } else if (p === "relatedYear") {
173
+ const v = tm.relatedYear;
174
+ // @ts-ignore
175
+ const fv = nf.format(v);
176
+ result.push({
177
+ type: "relatedYear",
178
+ value: fv
179
+ });
180
+ } else if (p === "yearName") {
181
+ const v = tm.yearName;
182
+ // @ts-ignore
183
+ const fv = nf.format(v);
184
+ result.push({
185
+ type: "yearName",
186
+ value: fv
187
+ });
188
+ }
189
+ }
190
+ return result;
204
191
  }
@@ -1,4 +1,4 @@
1
- import Decimal from 'decimal.js';
2
- import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern.js';
3
- import { ToLocalTimeImplDetails } from './ToLocalTime.js';
1
+ import type Decimal from "decimal.js";
2
+ import { type FormatDateTimePatternImplDetails } from "./FormatDateTimePattern.js";
3
+ import { type ToLocalTimeImplDetails } from "./ToLocalTime.js";
4
4
  export declare function FormatDateTimeRange(dtf: Intl.DateTimeFormat, x: Decimal, y: Decimal, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): string;
@@ -1,10 +1,11 @@
1
- import { PartitionDateTimeRangePattern } from './PartitionDateTimeRangePattern.js';
1
+ import "./FormatDateTimePattern.js";
2
+ import { PartitionDateTimeRangePattern } from "./PartitionDateTimeRangePattern.js";
3
+ import "./ToLocalTime.js";
2
4
  export function FormatDateTimeRange(dtf, x, y, implDetails) {
3
- var parts = PartitionDateTimeRangePattern(dtf, x, y, implDetails);
4
- var result = '';
5
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
6
- var part = parts_1[_i];
7
- result += part.value;
8
- }
9
- return result;
5
+ const parts = PartitionDateTimeRangePattern(dtf, x, y, implDetails);
6
+ let result = "";
7
+ for (const part of parts) {
8
+ result += part.value;
9
+ }
10
+ return result;
10
11
  }
@@ -1,5 +1,5 @@
1
- import { IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
- import { Decimal } from 'decimal.js';
3
- import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern.js';
4
- import { ToLocalTimeImplDetails } from './ToLocalTime.js';
1
+ import { type IntlDateTimeFormatPart } from "@formatjs/ecma402-abstract";
2
+ import type { Decimal } from "decimal.js";
3
+ import { type FormatDateTimePatternImplDetails } from "./FormatDateTimePattern.js";
4
+ import { type ToLocalTimeImplDetails } from "./ToLocalTime.js";
5
5
  export declare function FormatDateTimeRangeToParts(dtf: Intl.DateTimeFormat, x: Decimal, y: Decimal, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];