Closed Bug 1669573 Opened 4 years ago Closed 4 years ago

Simplify nsDateFormatSelector enum

Categories

(Core :: Internationalization, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
83 Branch
Tracking Status
firefox83 --- fixed

People

(Reporter: dminor, Assigned: dminor)

References

Details

Attachments

(6 files)

From Bug 1426907 comment 158, some of the values for nsDateFormatSelector are no longer used or not appropriate. This bug will track removing the unused values and adding a new DateTimeFormat::GetDisplayName method for kDateFormatMonthLong and kDateFormatWeekday. This cleanup will help with Bug 1426907 and hopefully simplify switching over to the Rust DateTime implementation in the future.

This adds a method to get the display name for a month or a weekday in long or
short form. We'll add more fields and styles in the future, the current patch
provides enough functionality to replace the selectors for kDateFormatMonthLong
and kDateFormatWeekday, which are currently used to retrieve display names by
calling FormatPRExplodedTime.

The formatters in mFormatCache are only valid for the locale in which they were
created. Currently the tests change mLocale directly but leave the cache in
place which can lead to incorrect test results depending upon which tests are
executed. This is not a problem outside of the tests because mLocale is normally
only set once during the call to Initialize() which will not change the current
locale once it is set.

Depends on D93008

This renames kTimeFormatSeconds to kTimeFormatLong and kTimeFormatNoSeconds to
kTimeFormatShort. This is consistent with the naming used for date format
selectors.

Depends on D93010

This adds a FormatDateTime method that takes a skeleton as an argument and
returns the localized date and time according to the skeleton. In the future,
we'll add an overload that allows taking an DateTimeOptions property bag, but
for now, this will provide enough functionality to allow us to remove the
kDateFormatYearMonth and kDateFormatYearMonthLong selectors as well as the code
for handling skeletons from FormatPRExplodedTime.

Depends on D93011

Attachment #9180545 - Attachment description: Bug 1669573 - Add DataTimeFormat::GetDisplayName; r=zbraniecki! → Bug 1669573 - Add DataTimeFormat::GetCalendarSymbol; r=zbraniecki!
Attachment #9180547 - Attachment description: Bug 1669573 - Replace kDateFormatMonthLong/kDateFormatWeekday with GetDisplayName; r=zbraniecki! → Bug 1669573 - Replace kDateFormatMonthLong/kDateFormatWeekday with GetCalendarSymbol; r=zbraniecki!
Pushed by dminor@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9230f50a236e
Add DataTimeFormat::GetCalendarSymbol; r=zbraniecki
https://hg.mozilla.org/integration/autoland/rev/2d91e316f450
Call DeleteCache when changing locale in TestDateTimeFormat; r=zbraniecki
https://hg.mozilla.org/integration/autoland/rev/f2800056f310
Replace kDateFormatMonthLong/kDateFormatWeekday with GetCalendarSymbol; r=zbraniecki
https://hg.mozilla.org/integration/autoland/rev/0fac34686721
Rename kTimeFormatSeconds and kTimeFormatNoSeconds; r=zbraniecki
https://hg.mozilla.org/integration/autoland/rev/9e44a2c80df2
Add DataTimeFormat::FormatDateTime; r=zbraniecki
https://hg.mozilla.org/integration/autoland/rev/0f1220aeaf17
Replace kDateFormatYearMonth/kDateFormatYearMonthLong with FormatDateTime; r=zbraniecki
Regressions: 1671532
Regressions: 1671695

Just for the record: kDateFormatWeekday was used in Thunderbird and had especially been restored in bug 1329841 after being removed for the first time when switching to ICU earlier on. Now Thunderbird filed bug 1672548 to restore that formatting.

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

Attachment

General

Created:
Updated:
Size: