Closed Bug 1347069 Opened 5 years ago Closed 5 years ago

[DateTimeInput] (l10n) 12/24hr format for <input type=time> based on locale

Categories

(Core :: Layout: Form Controls, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: jessica, Assigned: jessica)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

No description provided.
Hi zibi, do you know which API should we use to know whether a locale uses 12 or 24hr clock? Thanks.
Flags: needinfo?(gandalf)
Yep, use `(new Intl.DateTimeFormat('pl', {hour: 'numeric'})).resolvedOptions().hour12`
Flags: needinfo?(gandalf)
(In reply to Zibi Braniecki [:gandalf][:zibi] from comment #2)
> Yep, use `(new Intl.DateTimeFormat('pl', {hour:
> 'numeric'})).resolvedOptions().hour12`

Cool! Thanks for the prompt reply.
Assignee: nobody → jjong
Comment on attachment 8847486 [details]
Bug 1347069 - [DateTimeInput] (l10n) 12/24hr format for <input type=time> based on locale.

https://reviewboard.mozilla.org/r/120470/#review123010

Stealing mconley's review.

Looks good but I'd like to see this again before landing.

::: toolkit/content/widgets/datetimebox.xml:672
(Diff revision 1)
>            return { amString, pmString };
>          ]]>
>          </body>
>        </method>
>  
> +      <method name="getHourFormatForLocale">

The method name here implies it returns some kind of format information when really it just returns true or false. Let's name it "is12HourTime" unless you have other suggestions?

::: toolkit/content/widgets/datetimebox.xml:676
(Diff revision 1)
>  
> +      <method name="getHourFormatForLocale">
> +        <parameter name="aLocales"/>
> +          <body>
> +          <![CDATA[
> +            this.log("getHourFormatForLocale: " + aLocales);

Remove the logging before landing please
Attachment #8847486 - Flags: review-
Comment on attachment 8847486 [details]
Bug 1347069 - [DateTimeInput] (l10n) 12/24hr format for <input type=time> based on locale.

https://reviewboard.mozilla.org/r/120470/#review123010

> The method name here implies it returns some kind of format information when really it just returns true or false. Let's name it "is12HourTime" unless you have other suggestions?

`is12HourTime` is good, thanks.

> Remove the logging before landing please

I have a debug flag, so the logging is not enabled by default. Do I still need to remove it?
Attachment #8847486 - Flags: review?(mconley)
Clearing review flags, as Mossop has graciously stepped in to review this stuff (not only to help clear my review queue, but also to spread the knowledge of how the DateTime stuff works around!).
Thanks to Mike and Mossop! And ni? for comment 6.
Flags: needinfo?(dtownsend)
Comment on attachment 8847486 [details]
Bug 1347069 - [DateTimeInput] (l10n) 12/24hr format for <input type=time> based on locale.

https://reviewboard.mozilla.org/r/120470/#review123010

> I have a debug flag, so the logging is not enabled by default. Do I still need to remove it?

That's fine then, leave it in if you like.
Flags: needinfo?(dtownsend)
Comment on attachment 8847486 [details]
Bug 1347069 - [DateTimeInput] (l10n) 12/24hr format for <input type=time> based on locale.

https://reviewboard.mozilla.org/r/120470/#review124496

Looks good, thanks!
Attachment #8847486 - Flags: review?(dtownsend) → review+
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/c8e3f323a687
[DateTimeInput] (l10n) 12/24hr format for <input type=time> based on locale. r=mossop
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/c8e3f323a687
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55

Firefox 68.0.2. When i scroll time up, when hours are changing from 12 to 01 or back AM-PM stays the same. Also when minutes are changed 59<>01 hours does not change, but this is ok.
Also, in region where i live people does not understand what "AM" and "PM" mean, but Firefox for some reason is set to 12 hour format.

(In reply to Andrej from comment #15)

Firefox 68.0.2. When i scroll time up, when hours are changing from 12 to 01 or back AM-PM stays the same. Also when minutes are changed 59<>01 hours does not change, but this is ok.
Also, in region where i live people does not understand what "AM" and "PM" mean, but Firefox for some reason is set to 12 hour format.

Please file new bugs for issues you're seeing.

You need to log in before you can comment on or make changes to this bug.