@formatjs/intl-datetimeformat 7.2.1 → 7.2.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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-datetimeformat",
|
|
3
3
|
"description": "Intl.DateTimeFormat polyfill",
|
|
4
|
-
"version": "7.2.
|
|
4
|
+
"version": "7.2.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Long Ho <holevietlong@gmail.com>",
|
|
7
7
|
"type": "module",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"decimal.js": "^10.6.0",
|
|
20
20
|
"tslib": "^2.8.1",
|
|
21
|
-
"@formatjs/
|
|
22
|
-
"@formatjs/
|
|
21
|
+
"@formatjs/intl-localematcher": "0.8.1",
|
|
22
|
+
"@formatjs/ecma402-abstract": "3.1.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@formatjs/intl-getcanonicallocales": "3.2.1",
|
package/polyfill.iife.js
CHANGED
|
@@ -130,21 +130,27 @@ export function FormatDateTimePattern(dtf, patternParts, x, { getInternalSlots,
|
|
|
130
130
|
v = 12;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
// GH #4535: In h24 format, midnight
|
|
134
|
-
// However, in date ranges where dates differ (e.g., "May 3, 22:00 – May 4, 00:00"),
|
|
135
|
-
// showing "May 4, 24:00" is semantically incorrect because 24:00 of May 4 would
|
|
136
|
-
// actually be May 5, 00:00. In this case, keep midnight as 00:00 for clarity.
|
|
133
|
+
// GH #4535: In h24 format, midnight handling depends on context.
|
|
137
134
|
//
|
|
138
|
-
// LDML Spec (UTS #35):
|
|
139
|
-
//
|
|
135
|
+
// LDML Spec (UTS #35): The 'k' symbol (1-24) means 24:00 represents the END of day.
|
|
136
|
+
// "Tuesday 24:00 = Wednesday 00:00" - they represent the same instant.
|
|
140
137
|
// See: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
141
138
|
//
|
|
142
|
-
//
|
|
143
|
-
//
|
|
139
|
+
// However, in date ranges, showing 24:00 can be semantically confusing:
|
|
140
|
+
// - Different dates (May 3, 22:00 – May 4, 00:00): Show "00:00" on May 4
|
|
141
|
+
// because "May 4, 24:00" would actually mean May 5, 00:00
|
|
142
|
+
// - Same date ranges (May 3, 00:00 – 00:45): Show "00:00" for clarity
|
|
143
|
+
// because the times are at the START of the day, not the end
|
|
144
|
+
//
|
|
145
|
+
// Only convert 0→24 in non-range single-date formatting where 24:00
|
|
146
|
+
// conventionally means "end of day" (e.g., business closing time).
|
|
147
|
+
//
|
|
148
|
+
// Note: ICU4J's SimpleDateFormat always converts 0→24 for 'k' pattern.
|
|
149
|
+
// Our approach is more contextually appropriate for range formatting.
|
|
144
150
|
// See: https://github.com/unicode-org/icu/blob/main/icu4j/main/core/src/main/java/com/ibm/icu/text/SimpleDateFormat.java
|
|
145
151
|
if (p === "hour" && hourCycle === "h24") {
|
|
146
|
-
if (v === 0 && !rangeFormatOptions
|
|
147
|
-
// Only convert 0 to 24 when NOT
|
|
152
|
+
if (v === 0 && !rangeFormatOptions) {
|
|
153
|
+
// Only convert 0 to 24 when NOT formatting a range (rangeFormatOptions is undefined)
|
|
148
154
|
v = 24;
|
|
149
155
|
}
|
|
150
156
|
}
|