Closed
Bug 1313659
Opened 8 years ago
Closed 7 years ago
Replace nsIScriptableDateFormat in editor/ and chat/
Categories
(MailNews Core :: Internationalization, defect)
MailNews Core
Internationalization
Tracking
(thunderbird_esr52 unaffected, thunderbird55 fixed, thunderbird56 fixed)
RESOLVED
FIXED
Thunderbird 56.0
Tracking | Status | |
---|---|---|
thunderbird_esr52 | --- | unaffected |
thunderbird55 | --- | fixed |
thunderbird56 | --- | fixed |
People
(Reporter: jfkthame, Assigned: jorgk-bmo)
References
Details
Attachments
(2 files, 8 obsolete files)
2.05 KB,
patch
|
aceman
:
review+
jorgk-bmo
:
approval-comm-beta+
|
Details | Diff | Splinter Review |
15.94 KB,
patch
|
jorgk-bmo
:
review+
jorgk-bmo
:
approval-comm-beta+
|
Details | Diff | Splinter Review |
We'd like to remove nsIScriptableDateFormat (and its supporting platform-specific code) from mozilla-central; see bug 1313625. There are a bunch of callers in comm-central, but I suspect they could all be fairly easily converted to use Intl.DateTimeFormat, either directly or through the extended options to Date.toLocaleString() etc. (See also bug 1301655, which is doing this conversion for the Firefox front-end code in m-c.)
Comment 1•8 years ago
|
||
any impact to calendar?
Comment 2•8 years ago
|
||
Bug 1229684 was filed last year to replace nsIScriptableDateFormat in Lightning.
Comment 3•8 years ago
|
||
Thanks for the heads up - is nsIScriptableDateFormat still intended to be removed for ESR52 already or 53+?
Updated•8 years ago
|
Assignee: nobody → aryx.bugmail
Status: NEW → ASSIGNED
Reporter | ||
Comment 4•8 years ago
|
||
(In reply to [:MakeMyDay] from comment #3) > Thanks for the heads up - is nsIScriptableDateFormat still intended to be > removed for ESR52 already or 53+? No, I don't expect it will be removed from 52. First, I'd like to issue a warning that it is deprecated, and allow some time for people to convert callsites, so I expect it'll take at least a couple of additional release cycles before we're ready to actually kill it.
Comment 5•7 years ago
|
||
Attachment #8846658 -
Flags: review?(mkmelin+mozilla)
Comment 6•7 years ago
|
||
Attachment #8846660 -
Flags: review?(aleth)
Assignee | ||
Comment 7•7 years ago
|
||
Comment on attachment 8846658 [details] [diff] [review] editor, v3 I'll take this review, Magnus has too many. I suggest to use toLocaleString(), same comment as in bug 1346549, but let's wait for bug 1332351.
Attachment #8846658 -
Flags: review?(mkmelin+mozilla) → review?(jorgk)
Assignee | ||
Comment 8•7 years ago
|
||
Bug 1332351 has just landed, so this can go ahead now.
Comment on attachment 8846658 [details] [diff] [review] editor, v3 Review of attachment 8846658 [details] [diff] [review]: ----------------------------------------------------------------- ::: editor/ui/dialogs/content/EdPageProps.js @@ +49,5 @@ > // Convert modified string to date (0 = unknown date or January 1, 1970 GMT) > if(Date.parse(lastmod)) > { > try { > + const dateTimeFormatter = new Intl.DateTimeFormat(undefined, { We probably do not need the Intl. version here as it is not in a loop. @@ +51,5 @@ > { > try { > + const dateTimeFormatter = new Intl.DateTimeFormat(undefined, { > + year: 'numeric', month: 'long', day: 'numeric', > + hour: 'numeric', minute: 'numeric' Why 'numeric' for hour and minute? I'd think minutes:'2-digit' is a must-have when also displaying hours and seconds (you wouldn't like something like 1:2:3 displayed for time, but 1:02:03). The display for 'hour' could be argued about. Also I'd specify second: '2-digit' too here, if the original dateService.timeFormatSeconds also contained them.
Attachment #8846658 -
Flags: feedback+
Comment 10•7 years ago
|
||
(In reply to :aceman from comment #9) > Why 'numeric' for hour and minute? I'd think minutes:'2-digit' is a > must-have when also displaying hours and seconds (you wouldn't like > something like 1:2:3 displayed for time, but 1:02:03). The display for > 'hour' could be argued about. OK, I was mistaken here. It seems the formatter is clever enough to see that if hours and minutes are shown, minutes and seconds are forced to 2-digit display regardless if you set "numeric" or "2-digit". But it should do no harm to specify 2-digit for them explicitly. It seems new Date().toLocaleTimeString(undefined, { second: "2-digit"}) produces seconds that are not always 2-digit, so I'm not sure what the specification is.
Assignee | ||
Comment 11•7 years ago
|
||
I'm happy for Aceman to do the review here, I just wanted to lift some burden off Magnus' shoulders. Aceman did a great job in bug 1332351.
Assignee | ||
Comment 12•7 years ago
|
||
Comment on attachment 8846660 [details] [diff] [review] chat/im, v3 Unless these calls are run in a loop, I think you can lose the new Intl.DateTimeFormat(undefined, ... as was previously commented.
Attachment #8846660 -
Flags: review?(aleth) → review?(clokep)
Assignee | ||
Comment 13•7 years ago
|
||
Comment on attachment 8846658 [details] [diff] [review] editor, v3 Clearing this review for now while waiting for an updated patch. Sorry, first stole it from Magnus, now clearing it ;-(
Attachment #8846658 -
Flags: review?(jorgk)
Comment 14•7 years ago
|
||
(In reply to :aceman from comment #10) > OK, I was mistaken here. It seems the formatter is clever enough to see that > if hours and minutes are shown, minutes and seconds are forced to 2-digit > display regardless if you set "numeric" or "2-digit". But it should do no > harm to specify 2-digit for them explicitly. > > It seems new Date().toLocaleTimeString(undefined, { second: "2-digit"}) > produces seconds that are not always 2-digit, so I'm not sure what the > specification is. >Services.intl.createDateTimeFormat(undefined, {hour: "2-digit", minute: "2-digit"}).format(new Date(2017,3,7,5,9)) returns "5:09 AM" here, so my impression is that it ignores the formats for time parts at the moment and I don't want to specify formats which don't work as expected.
Attachment #8846658 -
Attachment is obsolete: true
Attachment #8857969 -
Flags: review?(acelists)
Updated•7 years ago
|
Attachment #8857969 -
Attachment filename: Cc-1313659-icuDateFormat-editor-v5.patch → editor, v5
Updated•7 years ago
|
Attachment #8857969 -
Attachment description: Cc-1313659-icuDateFormat-editor-v5.patch → editor, v5
Attachment #8857969 -
Attachment filename: editor, v5 → editor-v5.patch
Comment 15•7 years ago
|
||
Attachment #8846660 -
Attachment is obsolete: true
Attachment #8846660 -
Flags: review?(clokep)
Attachment #8857971 -
Flags: review?(clokep)
Assignee | ||
Comment 16•7 years ago
|
||
(In reply to Sebastian Hengst [:aryx][:archaeopteryx] (needinfo on intermittent or backout) from comment #14) > >Services.intl.createDateTimeFormat(undefined, {hour: "2-digit", minute: "2-digit"}).format(new Date(2017,3,7,5,9)) > returns "5:09 AM" here, so my impression is that it ignores the formats for > time parts at the moment and I don't want to specify formats which don't > work as expected. Do you know the work of Zbigniew Braniecki? He's been reworking Intl. For date/time formatting that obeys the OS setting of the user, he created mozIMozIntl.idl. So those functions should be used where date/times show in chrome. He's just converted the UI of FF in bug 1354445: https://hg.mozilla.org/mozilla-central/rev/79673e659b31. Hmm, if I see it correctly, Services.intl.createDateTimeFormat() should *already* use mozIMozIntl, right? You're on Windows? Try setting your "format locale" (not the system locale) to en-US or some other en-* locale and then select a format. When mozIMozIntl is used, that format should appear in the UI.
Comment 17•7 years ago
|
||
Comment on attachment 8857969 [details] [diff] [review] editor, v5 Review of attachment 8857969 [details] [diff] [review]: ----------------------------------------------------------------- ::: editor/ui/dialogs/content/EdPageProps.js @@ +51,5 @@ > { > try { > + const dateTimeFormatter = Services.intl.createDateTimeFormat(undefined, { > + year: 'numeric', month: 'long', day: 'numeric', > + hour: 'numeric', minute: 'numeric' This probably isn't used in TB, but I wonder if the "last page modification" date shouldn't be stored in the document in some fixed format mandated by spec, not the user's locale. But I do not see where gDialog.PageModDate.value is used later on so maybe this isn't even used right now.
Attachment #8857969 -
Flags: review?(acelists) → review+
Assignee | ||
Comment 18•7 years ago
|
||
Why not simply: dateTimeFormatter = Services.intl.createDateTimeFormat(undefined, { dateStyle: "long", timeStyle: "medium" // gives you seconds.
Comment 19•7 years ago
|
||
Another API for the date formatting? OK, so this one should be used for the app UI as it takes some OS settings into account? And the Date().toLocaleString() should only be used by webpages that can ignore OS settings? Does it already take OS settings into account or does it need to wait for your your C++ bug 1351427 ?
Assignee | ||
Comment 20•7 years ago
|
||
Intl.DateTimeFormat, that is .toLocaleString(), is a JS thing in-built thing (ECMA402). But where this stuff shows in chrome, like in the case of the patch, it should follow mozIntl.DateTimeFormat. That wasn't available some weeks ago. It's extensively used in attachment 8857963 [details] [diff] [review]. So I suggest not to land the patch, but to follow my suggestion from comment #18 to bring it inline with other chrome dates (bug 1354445: https://hg.mozilla.org/mozilla-central/rev/79673e659b31), see bug 1356403 for TB. I'm really sorry, this whole area has been in a state of flux. But FF now uses mozIntl.DateTimeFormat everywhere and with bug 1351427 finally landed, all JS and C++ dates will follow the same scheme. Further reading: https://mail.mozilla.org/pipermail/firefox-dev/2017-April/005293.html, quotes: You can think of it as a regular ECMA402 DateTimeFormat on steroids. let dtf = mozIntl.createDateTimeFormat(undefined, { dateStyle: 'long', // full | long | medium | short timeStyle: 'medium // full | long | medium | short }); dtf.format(now); Please, use the new API for all new code and when possible, migrate old code to use it.
Comment 21•7 years ago
|
||
(In reply to Jorg K (GMT+2) from comment #16) > Do you know the work of Zbigniew Braniecki? He's been reworking Intl. Yes, I know- > For date/time formatting that obeys the OS setting of the user, he created > mozIMozIntl.idl. So those functions should be used where date/times show in > chrome. He's just converted the UI of FF in bug 1354445: > https://hg.mozilla.org/mozilla-central/rev/79673e659b31. > Hmm, if I see it correctly, Services.intl.createDateTimeFormat() should > *already* use mozIMozIntl, right? Yes. (In reply to :aceman from comment #17) > This probably isn't used in TB, but I wonder if the "last page modification" > date shouldn't be stored in the document in some fixed format mandated by > spec, not the user's locale. But I do not see where > gDialog.PageModDate.value is used later on so maybe this isn't even used > right now. According to the source, it's just a formatted datetime display of the last page modification and doesn't get stored like that: https://dxr.mozilla.org/comm-central/search?q=PageModDate&redirect=false (In reply to Jorg K (GMT+2) from comment #18) > Why not simply: > dateTimeFormatter = Services.intl.createDateTimeFormat(undefined, { > dateStyle: "long", > timeStyle: "medium" // gives you seconds. Not all of these do at the moment what they are expected to do, e.g. dateStyle "short" uses 4 digits for the year and "long" and "full" are the same: both show the weekday, but only "full" is supposed to do that: http://www.unicode.org/cldr/charts/30/summary/en.html#1940 We can switch to this format when it properly supports these cldr variables.
Assignee | ||
Comment 22•7 years ago
|
||
There is a misunderstanding here. mozIntl.DateTimeFormat follows the OS settings. So if you ask for "short", the default on Windows for en-US still has yyyy. Long on Windows does show the weekday by default. The user can of course adjust that and all short dates in the application will follow. So my suggestion as stated in comment #18 still stands. The same goes for bug 1346549. I even filed bug 1356403 to undo the "damage" we did in bug 1332351. BTW, M-C are moving to remove nsIScriptableDateFormat, so we need to move here unless you want me to land this as a bustage fix ;-)
Assignee | ||
Comment 23•7 years ago
|
||
Comment on attachment 8857971 [details] [diff] [review] chat/im, v5 All these dates look like they show in chrome, so I'd use Services.intl.createDateTimeFormat(undefined, { dateStyle: "long", timeStyle: "short" }); everywhere. Zibi, would you mind to advise us here. Can you please comment on both patches.
Flags: needinfo?(gandalf)
Comment 24•7 years ago
|
||
If you're in chrome, you should use mozIntl version as it'll give you the OS Regional Preferences data sync.
Flags: needinfo?(gandalf)
Comment 25•7 years ago
|
||
Comment on attachment 8857969 [details] [diff] [review] editor, v5 Review of attachment 8857969 [details] [diff] [review]: ----------------------------------------------------------------- Aryx, can you please change it to what Jorg proposes? Services.intl.createDateTimeFormat(undefined, { dateStyle: "long", timeStyle: "medium" }); seems to produce the time with seconds for me on Linux.
Attachment #8857969 -
Flags: review+ → feedback+
Comment 26•7 years ago
|
||
Aryx, I'm a bit confused by this bug -- I was requested review a while ago, but there's been a lot of discussion since then. Is there something I need to review or are there changes that need to be made to the chat patch? Thanks!
Assignee | ||
Updated•7 years ago
|
Summary: Replace usage of nsIScriptableDateFormat with ECMA402 functions (Intl.DateTimeFormat etc) → Replace nsIScriptableDateFormat in edtor/ and chat/
Assignee | ||
Comment 27•7 years ago
|
||
Another friendly take-over addressing review issues.
Assignee: aryx.bugmail → jorgk
Attachment #8857969 -
Attachment is obsolete: true
Attachment #8881766 -
Flags: review?(acelists)
Assignee | ||
Comment 28•7 years ago
|
||
Corrected bug number in checkin comment.
Attachment #8881766 -
Attachment is obsolete: true
Attachment #8881766 -
Flags: review?(acelists)
Attachment #8881767 -
Flags: review?(acelists)
Assignee | ||
Comment 29•7 years ago
|
||
This should be the final version ready for review. Basically, if we format full dates/times, we just use Services.intl.createDateTimeFormat() with long or short formats. For dates, the short format has a numeric month; for times, the short format doesn't have seconds. I left Aryx as original author since he started here, but he submitted the patches *before* that service was available. Looks like he's got other commitments now, so I've just finished of the cut/paste job for him to get the bug off the books, just like bug 1346549.
Attachment #8857971 -
Attachment is obsolete: true
Attachment #8857971 -
Flags: review?(clokep)
Attachment #8881778 -
Flags: review?(clokep)
Attachment #8881767 -
Flags: review?(acelists) → review+
Reporter | ||
Updated•7 years ago
|
Summary: Replace nsIScriptableDateFormat in edtor/ and chat/ → Replace nsIScriptableDateFormat in editor/ and chat/
Assignee | ||
Comment 30•7 years ago
|
||
Comment on attachment 8881767 [details] [diff] [review] 1313659-editor.patch (JK v1) [landed in comment #30] https://hg.mozilla.org/comm-central/rev/e5af1840e19169c3e11f8bb6483f0384f7fac71a
Attachment #8881767 -
Attachment description: 1313659-editor.patch (JK v1) → 1313659-editor.patch (JK v1) [landed in comment #30]
Assignee | ||
Updated•7 years ago
|
Attachment #8881767 -
Flags: approval-comm-beta+
Comment 31•7 years ago
|
||
Comment on attachment 8881778 [details] [diff] [review] 1313659-chat.patch (JK v1). Review of attachment 8881778 [details] [diff] [review]: ----------------------------------------------------------------- Looks good by code inspection, thanks. I haven't tested this locally, I assume you have. ::: mail/components/im/content/chat-messenger-overlay.js @@ -449,5 @@ > return; > } > } > }, > - _makeFriendlyDate: function(aDate) { I'm surprised this isn't used anywhere. If you remove this, you should also remove the "today" and "yesterday" strings from chat.properties.
Attachment #8881778 -
Flags: review?(clokep) → review+
Assignee | ||
Comment 32•7 years ago
|
||
I must admit, I haven't tested this since I only tweaked Aryx's patch, see interdiff: https://bugzilla.mozilla.org/attachment.cgi?oldid=8857971&action=interdiff&newid=8881778&headers=1 I assume he tested this. Anyway, let's get someone more familiar with chat test this, someone who has complained about the badly formatted dates ;-) Richard, can you help us out here and test the chat patch. Thanks in advance.
Flags: needinfo?(richard.marti)
Assignee | ||
Comment 33•7 years ago
|
||
Removed today and yesterday strings as requested. Richard, this is the test to take for a spin ;-)
Attachment #8881778 -
Attachment is obsolete: true
Attachment #8886276 -
Flags: review+
Assignee | ||
Comment 34•7 years ago
|
||
Oops, this is the *patch* to take for a spin.
Comment 35•7 years ago
|
||
I see no change to without patch. The timestamps in chat area are still AM/PM. In Twitter the user tooltips show still US format for the "User Since" field. The "Previous Conversations" tree shows the correct date format, but this is already without patch correct. I only use IRC and Twitter and can test only this two.
Flags: needinfo?(richard.marti)
Assignee | ||
Comment 36•7 years ago
|
||
Yes, sadly still more uses of toLocale[Time|Date]String(): https://dxr.mozilla.org/comm-central/search?q=path%3Achat+tolocale&redirect=false
Assignee | ||
Comment 37•7 years ago
|
||
Attachment #8886276 -
Attachment is obsolete: true
Comment 38•7 years ago
|
||
Comment on attachment 8886321 [details] [diff] [review] 1313659-chat.patch (JK v3). The dates I can check are correct now. Thank you.
Attachment #8886321 -
Flags: feedback+
Assignee | ||
Comment 39•7 years ago
|
||
OK, I'll land this now with the additional hunks https://bugzilla.mozilla.org/attachment.cgi?oldid=8886276&action=interdiff&newid=8886321&headers=1 to fix the visible dates in the UI. I filed bug 1380799 to cover what's left.
Assignee | ||
Comment 40•7 years ago
|
||
White-space changes and used const throughout.
Attachment #8886321 -
Attachment is obsolete: true
Attachment #8886357 -
Flags: review+
Assignee | ||
Comment 41•7 years ago
|
||
https://hg.mozilla.org/comm-central/rev/e5af1840e19169c3e11f8bb6483f0384f7fac71a - editor/ (comment #30) https://hg.mozilla.org/comm-central/rev/2bc6c38ccf68d00c629309448634dc7857653c06 - chat/
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 56.0
Assignee | ||
Updated•7 years ago
|
Attachment #8886357 -
Flags: approval-comm-beta+
Assignee | ||
Comment 42•7 years ago
|
||
Beta (TB 55): https://hg.mozilla.org/releases/comm-beta/rev/9c39c109d351d6b3eae605e4142f02682a6e479a https://hg.mozilla.org/releases/comm-beta/rev/402684d6d9195fb4f9e1f43bd850de0259717cdf
status-thunderbird55:
--- → fixed
Assignee | ||
Updated•7 years ago
|
status-thunderbird56:
--- → fixed
You need to log in
before you can comment on or make changes to this bug.
Description
•