mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1301655 - pt 4 - Replace use of nsIScriptableDateFormat with Date.toLocaleString in toolkit Update history. r=gandalf
This commit is contained in:
parent
4d16a0f88a
commit
b9c50d4bdd
@ -8,8 +8,6 @@ const { classes: Cc, interfaces: Ci, manager: Cm, utils: Cu, results: Cr } = Com
|
|||||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||||
|
|
||||||
const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
|
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 = {
|
const mockUpdateManager = {
|
||||||
contractId: "@mozilla.org/updates/update-manager;1",
|
contractId: "@mozilla.org/updates/update-manager;1",
|
||||||
@ -87,15 +85,12 @@ function resetPreferences() {
|
|||||||
|
|
||||||
function formatInstallDate(sec) {
|
function formatInstallDate(sec) {
|
||||||
var date = new Date(sec);
|
var date = new Date(sec);
|
||||||
return dateFormat.FormatDateTime("",
|
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
|
||||||
dateFormat.dateFormatLong,
|
.getService(Ci.nsIXULChromeRegistry)
|
||||||
dateFormat.timeFormatSeconds,
|
.getSelectedLocale("global", true);
|
||||||
date.getFullYear(),
|
const dtOptions = { year: 'numeric', month: 'long', day: 'numeric',
|
||||||
date.getMonth() + 1,
|
hour: 'numeric', minute: 'numeric', second: 'numeric' };
|
||||||
date.getDate(),
|
return date.toLocaleString(locale, dtOptions);
|
||||||
date.getHours(),
|
|
||||||
date.getMinutes(),
|
|
||||||
date.getSeconds());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerCleanupFunction(resetPreferences);
|
registerCleanupFunction(resetPreferences);
|
||||||
|
@ -58,18 +58,13 @@ var gUpdateHistory = {
|
|||||||
* @returns A human readable date string
|
* @returns A human readable date string
|
||||||
*/
|
*/
|
||||||
_formatDate: function(seconds) {
|
_formatDate: function(seconds) {
|
||||||
var sdf =
|
|
||||||
Components.classes["@mozilla.org/intl/scriptabledateformat;1"].
|
|
||||||
getService(Components.interfaces.nsIScriptableDateFormat);
|
|
||||||
var date = new Date(seconds);
|
var date = new Date(seconds);
|
||||||
return sdf.FormatDateTime("", sdf.dateFormatLong,
|
const locale = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||||
sdf.timeFormatSeconds,
|
.getService(Components.interfaces.nsIXULChromeRegistry)
|
||||||
date.getFullYear(),
|
.getSelectedLocale("global", true);
|
||||||
date.getMonth() + 1,
|
const dtOptions = { year: 'numeric', month: 'long', day: 'numeric',
|
||||||
date.getDate(),
|
hour: 'numeric', minute: 'numeric', second: 'numeric' };
|
||||||
date.getHours(),
|
return date.toLocaleString(locale, dtOptions);
|
||||||
date.getMinutes(),
|
|
||||||
date.getSeconds());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user