From c7a029f8429f2a0e348a4039876dca5afb7cbc75 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 4 Dec 2020 18:11:46 +0000 Subject: Issue #31 - Part 1: Use nsIScriptableDateFormat in Page Info. --- basilisk/base/content/pageinfo/pageInfo.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/basilisk/base/content/pageinfo/pageInfo.js b/basilisk/base/content/pageinfo/pageInfo.js index 7a6d0a0..98e567c 100644 --- a/basilisk/base/content/pageinfo/pageInfo.js +++ b/basilisk/base/content/pageinfo/pageInfo.js @@ -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() -- cgit v1.2.3