Skip to content

Commit 8f491b4

Browse files
committed
Polyfill: Fix handling of hour12/hourCycle to conform to spec
The strategy of caching the output of DTF resolvedOptions() failed in the case of hour12/hourCycle, because those options are silently dropped if the chosen format does not include an hour component. Manually add them to the cached resolvedOptions object if the user included them. See: #3065
1 parent 60ef439 commit 8f491b4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

polyfill/lib/intl.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ function createDateTimeFormat(dtf, locale, options) {
137137
for (const prop in clonedResolved) {
138138
if (!ES.HasOwnProperty(options, prop)) delete clonedResolved[prop];
139139
}
140+
// hour12/hourCycle don't show up in resolvedOptions() unless the chosen
141+
// format includes an hour component, so copy them explicitly in case they
142+
// would otherwise be lost
143+
clonedResolved.hour12 = options.hour12;
144+
clonedResolved.hourCycle = options.hourCycle;
140145
SetSlot(dtf, OPTIONS, clonedResolved);
141146
} else {
142147
SetSlot(dtf, OPTIONS, options);

0 commit comments

Comments
 (0)