Remove Date.prototype.toLocaleFormat uses in toolkit/content/widgets

RESOLVED FIXED in Firefox 52

Status

()

RESOLVED FIXED
2 years ago
10 months ago

People

(Reporter: anba, Assigned: anba)

Tracking

Trunk
mozilla52
Points:
---

Firefox Tracking Flags

(firefox52 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

2 years ago
Date.prototype.toLocaleFormat is a non-standard API and we plan to warn when it's used (bug 1299900) and eventually want to remove it completely (bug 818634). As a first step we need to replace all Date.prototype.toLocaleFormat uses in Firefox with standardized APIs.

toolkit/content/widgets/datetimepicker.xml uses toLocaleFormat with the following format strings:

- %X and %x: These formats match (more or less) Date.prototype.toLocale{Time,Date}String, so they were updated accordingly. I've added "-u-ca-gregory-nu-latn" to the default locale to ensure the formatted strings use the Gregorian calendar with Latin numbers.

- %B and %a: When the Intl object is available, we can simply use the additional parameters for Date.prototype.toLocaleString to retrieve the month/week name. But when Intl isn't available (bug 1215247), JavaScript doesn't provide any standard method to get the localized month/week name. So for the time being, toLocaleFormat still needs to be used until bug 1215247 is fixed. Nevertheless let's try to switch to the standardized APIs for those platforms which provide Intl support.
(Assignee)

Comment 1

2 years ago
Created attachment 8805724 [details] [diff] [review]
toolkit_content_widgets.patch
Attachment #8805724 - Flags: review?(enndeakin)
Comment on attachment 8805724 [details] [diff] [review]
toolkit_content_widgets.patch

This code shouldn't run on Android, so Intl should always be available.
Attachment #8805724 - Flags: review?(enndeakin) → review+
(Assignee)

Comment 3

2 years ago
Created attachment 8806382 [details] [diff] [review]
toolkit_content_widgets.patch

That's great news, so we don't even need the toLocaleFormat() fallback for Android! I've updated the patch accordingly. Carrying r+.
Attachment #8805724 - Attachment is obsolete: true
Attachment #8806382 - Flags: review+
(Assignee)

Comment 4

2 years ago
Thanks for reviewing the patch!
Keywords: checkin-needed

Comment 5

2 years ago
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/88013961312c
Remove Date.prototype.toLocaleFormat uses in toolkit/content/widgets. r=Neil
Keywords: checkin-needed

Comment 6

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/88013961312c
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
status-firefox52: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla52

Updated

10 months ago
See Also: → bug 515577
You need to log in before you can comment on or make changes to this bug.