Cannot set hourCycle with Services.intl.DateTimeFormat
Categories
(Core :: Internationalization, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox98 | --- | affected |
People
(Reporter: henry-x, Unassigned)
References
(Blocks 1 open bug)
Details
I'm working on thunderbird calendars, and I want to be able to display midnight as "24:00" (numerical end of the day) rather than "00:00" (numerical start of the day) in a locale-appropriate way. However, whilst I could do this with Intl.DateTimeFormat
, I can't do so with the recommended Services.intl.DateTimeFormat
.
Steps to Reproduce
formatter = new Services.intl.DateTimeFormat(undefined, { timeStyle: "short", hourCycle: "h24" })
Result
The given hourCycle
value is ignored, and is set to h23
instead in the returned formatter
object.
Expect
The given hourCycle
to be used.
Origin?
I think the hourCycle
value is ignored is because when timeStyle
is given, the MozDateTimeFormat
wrapper sets an explicit pattern
(to "HH:mm" in my case) https://searchfox.org/mozilla-central/rev/b3933df6e119bd6caf5d9e5868670348ec26dee3/toolkit/components/mozintl/mozIntl.jsm#1031
Comment 1•4 years ago
|
||
The easy fix here would to not use the OS's pattern when an hour cycle is specified. The harder fix would be to swap out the hour cycle for patterns that have the same coarse hour cycle, and then fall back to the ICU patterns when the coarse hour cycle is different. It's doable, but I think we'll need to add
I'm not sure what the use case is for Thunderbird, but for this bug I would say we should do the easy thing of ignoring the OS preferences when the hour cycle is specified, and file a follow-up if we feel like we should do the harder version.
Updated•4 years ago
|
Description
•