[Basilisk] Issue #31 - Part 1: Use nsIScriptableDateFormat in Page Info.

This commit is contained in:
Moonchild 2020-12-04 18:11:46 +00:00 committed by roytam1
commit b1d1a02c6c

View file

@ -1051,16 +1051,18 @@ function formatNumber(number)
function formatDate(datestr, unknown)
{
// scriptable date formatter, for pretty printing dates
var dateService = Components.classes["@mozilla.org/intl/scriptabledateformat;1"]
.getService(Components.interfaces.nsIScriptableDateFormat);
var date = new Date(datestr);
if (!date.valueOf())
return unknown;
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 dateService.FormatDateTime("", dateService.dateFormatLong,
dateService.timeFormatSeconds,
date.getFullYear(), date.getMonth()+1, date.getDate(),
date.getHours(), date.getMinutes(), date.getSeconds());
}
function doCopy()