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)
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 1•9 years ago
|
||
Assignee | ||
Comment 2•9 years ago
|
||
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 | ||
Updated•9 years ago
|
Assignee: nobody → gandalf
Comment 3•9 years ago
|
||
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+
Assignee | ||
Comment 4•9 years ago
|
||
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.
Assignee | ||
Comment 5•9 years ago
|
||
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Comment 6•9 years ago
|
||
(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?
Assignee | ||
Comment 7•9 years ago
|
||
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'});
Comment 8•9 years ago
|
||
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)
Assignee | ||
Comment 9•9 years ago
|
||
Yeah! Thank you for finding it!
Fixed: https://github.com/mozilla-b2g/gaia/commit/355baa0efee94e9c6f7aea4b3935060753831d01
Flags: needinfo?(gandalf)
You need to log in
before you can comment on or make changes to this bug.
Description
•