Closed Bug 1255110 Opened 9 years ago Closed 9 years ago

Migrate mozIntl.DateTimeFormat to Intl.DateTimeFormat.formatToParts

Categories

(Firefox OS Graveyard :: Gaia::L10n, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: zbraniecki, Assigned: zbraniecki)

Details

Attachments

(1 file)

Since we now have DateTimeFormat.prototype.formatToParts in Gecko, we should migrate Gaia to use it and remove mozIntl.DateTimeFormat.
Comment on attachment 8728620 [details] [review] [gaia] zbraniecki:1255110-migrate-to-formattoparts > mozilla-b2g:master Stas, can you review this for me?
Attachment #8728620 - Flags: review?(stas)
Assignee: nobody → gandalf
Comment on attachment 8728620 [details] [review] [gaia] zbraniecki:1255110-migrate-to-formattoparts > mozilla-b2g:master LGTM, thanks, Zibi! Just a nit about Array.reduce: you may want to change: .reduce((string, part) => string + part, ''); to the equivalent: .reduce((string, part) => string + part);
Attachment #8728620 - Flags: review?(stas) → review+
Unfortunately, I cannot do that. formatToParts may return an empty array and in that case, reduce will error because original string is undefined. In order cover that scenario, we need the second argument on reduce to be an empty string.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
(In reply to Zibi Braniecki [:gandalf][:zibi] from comment #4) > Unfortunately, I cannot do that. > > formatToParts may return an empty array and in that case, reduce will error > because original string is undefined. Ah, I didn't realize this was possible, thanks! Out of curiosity, in what cases would formatToParts return an empty array?
When Intl can't find a matching pattern in selected language. Each language may have different coverage of patterns (although at the moment I think that's rare). An example combo that works in the current Firefox is: (new Date()).toLocaleString('en-US', {era: 'long', day: '2-digit'});
Ey :gandalf! It seems that GU3 started failing after this commit: TEST-UNEXPECTED-FAIL | null | [calendar-test/unit/views/current_time_test.js] Views.CurrentTime #_render should update position and time TypeError: formatter.formatToParts is not a function Is there anything missing in the test? Thanks!
Flags: needinfo?(gandalf)
Flags: needinfo?(gandalf)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: