Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
Fix: change date/time handling to handle older versions of Thunderbir…
Browse files Browse the repository at this point in the history
…d as well as newer
  • Loading branch information
Standard8 committed Sep 3, 2017
1 parent 02a33d8 commit e0559e9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource:///modules/mailServices.js");

if (!Services.intl) {
// That one doesn't belong to MailServices.
XPCOMUtils.defineLazyServiceGetter(MailServices, "i18nDateFormatter",
"@mozilla.org/intl/scriptabledateformat;1",
"nsIScriptableDateFormat");
}


XPCOMUtils.importRelative(this, "../log.js");

let Log = setupLogging(logRoot+".Stdlib");
Expand Down Expand Up @@ -233,6 +241,18 @@ function dateAsInMessageList(aDate) {
now.getMonth() == aDate.getMonth() &&
now.getDate() == aDate.getDate();

// Supports Thunderbird 52 & older.
if (!Services.intl) {
let format = isToday
? Ci.nsIScriptableDateFormat.dateFormatNone
: Ci.nsIScriptableDateFormat.dateFormatShort;
// That is an ugly XPCOM call!
return MailServices.i18nDateFormatter.FormatDateTime(
"", format, Ci.nsIScriptableDateFormat.timeFormatNoSeconds,
aDate.getFullYear(), aDate.getMonth() + 1, aDate.getDate(),
aDate.getHours(), aDate.getMinutes(), aDate.getSeconds());
}

let format = isToday
? {timeStyle: "short"}
: {dateStyle: "short", timeStyle: "short"};
Expand Down

0 comments on commit e0559e9

Please sign in to comment.