Closed Bug 1313795 Opened 8 years ago Closed 8 years ago

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

Categories

(Toolkit :: UI Widgets, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: anba, Assigned: anba)

References

Details

Attachments

(1 file, 1 obsolete file)

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.
Attached patch toolkit_content_widgets.patch (obsolete) — Splinter Review
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+
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+
Thanks for reviewing the patch!
Keywords: checkin-needed
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
https://hg.mozilla.org/mozilla-central/rev/88013961312c
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
See Also: → 515577
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: