Closed Bug 1370859 Opened 2 years ago Closed 6 months ago

<input type="date"> datepicker doesn't follow system "First day of week"

Categories

(Core :: DOM: Core & HTML, defect, P3)

x86
All
defect

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: jeroen.pulles, Assigned: mkmelin)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

The datepicker widget starts the week on Sunday, but the Language & Region settings panel on my Mac has "First day of week" set to "Monday".

Also, why render Saturday and Sunday in red? Why differentiate between "work days" and "weekend", and more importantly, why use a signalling color such as red here? 

Firefox Nightly, Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0
Priority: -- → P3
The picker follows app's locale, not system locale.

See bug 1366134 for details on when we look into OS regional preferences for date patterns.

> Also, why render Saturday and Sunday in red? Why differentiate between "work days" and "weekend"

Most cultures differentiate weekend days. See CLDR's https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json

Actually, this is still wrong even though I set intl.regional_prefs.use_os_locales true.
It's always using the Sunday as first day of week.

Assignee: nobody → mkmelin+mozilla
OS: macOS → All
Attached patch bug1370859_datepicker_week.patch (obsolete) — Splinter Review
Attachment #9043828 - Flags: review?(gandalf)
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Comment on attachment 9043828 [details] [diff] [review]
bug1370859_datepicker_week.patch

Review of attachment 9043828 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/modules/DateTimePickerPanel.jsm
@@ +12,5 @@
>  
>  var DateTimePickerPanel = class {
>    constructor(element) {
>      this.element = element;
> +    this.locales = element.ownerDocument.defaultView.getRegionalPrefsLocales();

No need to cache this. Just call it from the `initPicker`. LocaleService is caching and invalidating cache on locale changes. We don't want to duplicate it here.
Attached patch bug1370859_datepicker_week.patch (obsolete) — Splinter Review
Attachment #9043828 - Attachment is obsolete: true
Attachment #9043828 - Flags: review?(gandalf)
Attachment #9045171 - Flags: review?(gandalf)
Comment on attachment 9045171 [details] [diff] [review]
bug1370859_datepicker_week.patch

Review of attachment 9045171 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/modules/DateTimePickerPanel.jsm
@@ +98,5 @@
>  
>    initPicker(detail) {
>      // TODO: When bug 1376616 lands, replace this.setGregorian with
>      //       mozIntl.Locale for setting calendar to Gregorian
> +    const locales = this.element.ownerDocument.defaultView.getRegionalPrefsLocales();

what's the reason of not using `Services.locale.regionalPrefsLocales` here? If there's a strong reason, maybe add a comment?
Attachment #9045171 - Flags: review?(gandalf) → review+
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/integration/mozilla-inbound/rev/8130341d3ec8
for <input type="date"> respect intl.regional_prefs.use_os_locales when selecting "First day of week". r=gandalf
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67

This may be "fixed" in terms of Mozilla believing their code is correct, but the issue itself is not fixed. People want to be able to change the first day of the week; Mozilla does not let them. I have Monday set as the first day of the week in my OS, I have intl.regional_prefs.use_os_locales set to true, OS locale set to Australia, app locale as UK because it's the closest, yet still the date picker puts Sunday first. This religious hangover has no relevance to many people; ISO 8601 deems Monday to be the first day of the week. I don't understand the insistence on perpetuating this outdated format.

@Roy - can you provide the output of your about:support section for Intl&L10n?

Internationalisation & Localisation
Application Settings  
Requested Locales ["en-GB"]
Available Locales ["en-GB","en-US"]
App Locales ["en-GB","en-US"]
Regional Preferences ["en-AU"]
Default Locale "en-GB"
Operating System  
System Locales ["en-GB"]
Regional Preferences ["en-AU"]

Seems like Gecko accurately picks your regional preferences locale as en-AU.

The source of your problem is that CLDR picks Sunday as the first day of the week for region AU [0] and Gecko platform nor products have API/UI to manually set regional preferences such as this.

I'm open to extend Gecko to support such overrides (hour cycle, first day, maybe several basic date/time styles), but it's a major project and I won't have time to work on that.

If you're interested, file a bug and I'll mentor you.

[0] https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json#L73

Yes and no. The real source of the issue is that CLDR is treated as canonical over retrieving the setting via GetLocaleInfoEx on Windows, locale -k LC_TIME on Linux, etc.

Ah, that's a good point!

We even have infra for that [0]! We currently take firstDay straight from CLDR [1], but for some items like date/time patterns and hourcycle, we allow OSPreferences to provide an OS-specific overlay.

We could add OSPreferences::GetFirstDayOfTheWeek which would return -1-6 where -1` means "no override" and then take it from CLDR, otherwise use the OS info.

[0] https://searchfox.org/mozilla-central/source/intl/locale/OSPreferences.h
[1] https://searchfox.org/mozilla-central/rev/40ef22080910c2e2c27d9e2120642376b1d8b8b2/js/src/builtin/intl/IntlObject.cpp#75

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