Bug 1301655 - pt 4 - Replace use of nsIScriptableDateFormat with Date.toLocaleString in toolkit Update history. r=gandalf

This commit is contained in:
Jonathan Kew 2016-10-28 12:04:07 +01:00
Родитель 4d16a0f88a
Коммит b9c50d4bdd
2 изменённых файлов: 12 добавлений и 22 удалений

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

@ -8,8 +8,6 @@ const { classes: Cc, interfaces: Ci, manager: Cm, utils: Cu, results: Cr } = Com
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
const dateFormat = Cc["@mozilla.org/intl/scriptabledateformat;1"]
.getService(Components.interfaces.nsIScriptableDateFormat);
const mockUpdateManager = {
contractId: "@mozilla.org/updates/update-manager;1",
@ -87,15 +85,12 @@ function resetPreferences() {
function formatInstallDate(sec) {
var date = new Date(sec);
return dateFormat.FormatDateTime("",
dateFormat.dateFormatLong,
dateFormat.timeFormatSeconds,
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds());
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: 'numeric', month: 'long', day: 'numeric',
hour: 'numeric', minute: 'numeric', second: 'numeric' };
return date.toLocaleString(locale, dtOptions);
}
registerCleanupFunction(resetPreferences);

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

@ -58,18 +58,13 @@ var gUpdateHistory = {
* @returns A human readable date string
*/
_formatDate: function(seconds) {
var sdf =
Components.classes["@mozilla.org/intl/scriptabledateformat;1"].
getService(Components.interfaces.nsIScriptableDateFormat);
var date = new Date(seconds);
return sdf.FormatDateTime("", sdf.dateFormatLong,
sdf.timeFormatSeconds,
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds());
const locale = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: 'numeric', month: 'long', day: 'numeric',
hour: 'numeric', minute: 'numeric', second: 'numeric' };
return date.toLocaleString(locale, dtOptions);
}
};