Bug 1444480 - Omit timezone in some timestamps. r=florian

--HG--
extra : rebase_source : a5c245dbbf79c2d751d8a6334c20050a0065acef
This commit is contained in:
Martin Giger 2018-03-09 19:54:02 +01:00
Родитель a339ce9e48
Коммит 03cd32f4cf
3 изменённых файлов: 18 добавлений и 19 удалений

Просмотреть файл

@ -488,13 +488,13 @@
let text;
if ((new Date()).toDateString() == date.toDateString()) {
const dateTimeFormatter = new Services.intl.DateTimeFormat(undefined, {
timeStyle: "long"
timeStyle: "medium"
});
text = dateTimeFormatter.format(date);
}
else {
const dateTimeFormatter = new Services.intl.DateTimeFormat(undefined, {
dateStyle: "short", timeStyle: "long"
dateStyle: "short", timeStyle: "medium"
});
text = dateTimeFormatter.format(date);
}

Просмотреть файл

@ -23,18 +23,18 @@ function ToLocaleFormat(aFormat, aDate) {
return Day(t) - DayFromYear(t.getFullYear());
}
function weekday(option) {
return aDate.toLocaleString(locale, {weekday: option});
return aDate.toLocaleString(undefined, {weekday: option});
}
function month(option) {
return aDate.toLocaleString(locale, {month: option});
return aDate.toLocaleString(undefined, {month: option});
}
function hourMinSecTwoDigits() {
return aDate.toLocaleString(locale, {
return aDate.toLocaleString(undefined, {
hour: "2-digit", minute: "2-digit", second: "2-digit"
});
}
function dayPeriod() {
let dtf = Intl.Dateformat(locale, {hour: "2-digit"});
let dtf = Intl.DateTimeFormat(undefined, {hour: "2-digit"});
let dayPeriodPart =
dtf.resolvedOptions().hour12 &&
dtf.formatToParts(aDate).find(part => part.type === "dayPeriod");
@ -76,7 +76,7 @@ function ToLocaleFormat(aFormat, aDate) {
return (offset < 0 ? "+" : "-") + String(tzoff).padStart(4, "0");
}
function timeZone() {
let dtf = Intl.DateTimeFormat("en-US", {timeZoneName: "short"});
let dtf = Intl.DateTimeFormat(undefined, {timeZoneName: "short"});
let timeZoneNamePart = dtf.formatToParts(aDate)
.find(part => part.type === "timeZoneName");
return timeZoneNamePart ? timeZoneNamePart.value : "";

Просмотреть файл

@ -39,6 +39,14 @@ XPCOMUtils.defineLazyGetter(this, "TXTToHTML", function() {
return aTXT => cs.scanTXT(aTXT, cs.kEntities);
});
XPCOMUtils.defineLazyGetter(this, "gTimeFormatter", () => {
return new Services.intl.DateTimeFormat(undefined, {
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
});
});
ChromeUtils.defineModuleGetter(this,
"ToLocaleFormat", "resource:///modules/ToLocaleFormat.jsm");
@ -340,10 +348,7 @@ var headerFooterReplacements = {
let date = new Date(aConv.startDate / 1000);
if (aFormat)
return ToLocaleFormat(aFormat, date);
const timeFormatter = new Services.intl.DateTimeFormat(undefined, {
timeStyle: "long"
});
return timeFormatter.format(date);
return gTimeFormatter.format(date);
}
};
@ -361,17 +366,11 @@ var statusMessageReplacements = {
let date = new Date(aMsg.time * 1000);
if (aFormat)
return ToLocaleFormat(aFormat, date);
const timeFormatter = new Services.intl.DateTimeFormat(undefined, {
timeStyle: "long"
});
return timeFormatter.format(date);
return gTimeFormatter.format(date);
},
timestamp: aMsg => aMsg.time,
shortTime: function(aMsg) {
const timeFormatter = new Services.intl.DateTimeFormat(undefined, {
timeStyle: "long"
});
return timeFormatter.format(new Date(aMsg.time * 1000));
return gTimeFormatter.format(new Date(aMsg.time * 1000));
},
messageClasses: function(aMsg) {
let msgClass = [];