Align various UI string formatting with the OS.
parent
38fd9ff2bb
commit
1ae9412488
|
@ -13,6 +13,7 @@ Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
|
|||
|
||||
var params;
|
||||
var cookieBundle;
|
||||
var gDateService = null;
|
||||
|
||||
var showDetails = "";
|
||||
var hideDetails = "";
|
||||
|
@ -38,6 +39,14 @@ function onload()
|
|||
document.getElementById("cancel").setAttribute("icon", "cancel");
|
||||
document.getElementById("disclosureButton").setAttribute("icon", "properties");
|
||||
|
||||
// Initialize the date formatter
|
||||
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
|
||||
|
@ -174,12 +183,21 @@ function cookieDeny()
|
|||
function GetExpiresString(secondsUntilExpires) {
|
||||
if (secondsUntilExpires) {
|
||||
var date = new Date(1000*secondsUntilExpires);
|
||||
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);
|
||||
|
||||
// if a server manages to set a really long-lived cookie, the dateservice
|
||||
// can't cope with it properly, so we'll return a descriptive string instead.
|
||||
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) {
|
||||
// Expiry duration was out of range for the date formatter, meaning a silly long time.
|
||||
expiry = cookieBundle.getString("expireInAVeryLongTime");
|
||||
}
|
||||
return expiry;
|
||||
}
|
||||
return cookieBundle.getString("expireAtEndOfSession");
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ domainColon=Domain:
|
|||
forSecureOnly=Encrypted connections only
|
||||
forAnyConnection=Any type of connection
|
||||
expireAtEndOfSession=At end of session
|
||||
# LOCALIZATION NOTE (expireInAVeryLongTime) This string is used if a cookie won't expire for a literal life age and then some.
|
||||
expireInAVeryLongTime=Not in your lifetime
|
||||
|
||||
showDetails=Show Details
|
||||
hideDetails=Hide Details
|
||||
|
|
|
@ -58,13 +58,18 @@ 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);
|
||||
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 sdf.FormatDateTime("", sdf.dateFormatLong,
|
||||
sdf.timeFormatSeconds,
|
||||
date.getFullYear(),
|
||||
date.getMonth() + 1,
|
||||
date.getDate(),
|
||||
date.getHours(),
|
||||
date.getMinutes(),
|
||||
date.getSeconds());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue