Bug 1301655 - pt 5 - Replace use of nsIScriptableDateFormat for cookie date formatting. r=gandalf

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

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

@ -16,8 +16,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
var gCookiesWindow = {
_cm : Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager),
_ds : Components.classes["@mozilla.org/intl/scriptabledateformat;1"]
.getService(Components.interfaces.nsIScriptableDateFormat),
_hosts : {},
_hostOrder : [],
_tree : null,
@ -513,14 +511,12 @@ var gCookiesWindow = {
formatExpiresString: function (aExpires) {
if (aExpires) {
var date = new Date(1000 * aExpires);
return this._ds.FormatDateTime("", this._ds.dateFormatLong,
this._ds.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);
}
return this._bundle.getString("expireAtEndOfSession");
},

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

@ -13,7 +13,6 @@ Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
var params;
var cookieBundle;
var gDateService = null;
var showDetails = "";
var hideDetails = "";
@ -39,13 +38,6 @@ function onload()
document.getElementById("cancel").setAttribute("icon", "cancel");
document.getElementById("disclosureButton").setAttribute("icon", "properties");
if (!gDateService) {
const nsScriptableDateFormat_CONTRACTID = "@mozilla.org/intl/scriptabledateformat;1";
const nsIScriptableDateFormat = Components.interfaces.nsIScriptableDateFormat;
gDateService = Components.classes[nsScriptableDateFormat_CONTRACTID]
.getService(nsIScriptableDateFormat);
}
cookieBundle = document.getElementById("cookieBundle");
//cache strings
@ -183,21 +175,12 @@ function cookieDeny()
function GetExpiresString(secondsUntilExpires) {
if (secondsUntilExpires) {
var date = new Date(1000*secondsUntilExpires);
// if a server manages to set a really long-lived cookie, the dateservice
// can't cope with it properly, so we'll just return a blank string
// see bug 238045 for details
var expiry = "";
try {
expiry = gDateService.FormatDateTime("", gDateService.dateFormatLong,
gDateService.timeFormatSeconds,
date.getFullYear(), date.getMonth()+1,
date.getDate(), date.getHours(),
date.getMinutes(), date.getSeconds());
} catch (ex) {
// do nothing
}
return expiry;
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);
}
return cookieBundle.getString("expireAtEndOfSession");
}