Bug 1301655 - pt 7 - Replace use of nsIScriptableDateFormat in crashreporter. r=gandalf
authorJonathan Kew <jkew@mozilla.com>
Fri, 28 Oct 2016 12:04:07 +0100
changeset 319934 17efbf713de8bb8f672340ef87cf0e78e5565232
parent 319933 48e81da5a95b8b2c53213a3675ce20d86df87a35
child 319935 8e2d25bd70b8412864e5005ea4099eb53f183d5c
push id83271
push userjkew@mozilla.com
push dateFri, 28 Oct 2016 11:07:26 +0000
treeherdermozilla-inbound@686282bd2f19 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgandalf
bugs1301655
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1301655 - pt 7 - Replace use of nsIScriptableDateFormat in crashreporter. r=gandalf
toolkit/crashreporter/content/crashes.js
--- a/toolkit/crashreporter/content/crashes.js
+++ b/toolkit/crashreporter/content/crashes.js
@@ -73,18 +73,24 @@ function populateReportList() {
 
   if (reports.length == 0) {
     document.getElementById("clear-reports").style.display = "none";
     document.getElementById("reportList").style.display = "none";
     document.getElementById("noReports").style.display = "block";
     return;
   }
 
-  var formatter = Cc["@mozilla.org/intl/scriptabledateformat;1"].
-                  createInstance(Ci.nsIScriptableDateFormat);
+  const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
+                 .getService(Ci.nsIXULChromeRegistry)
+                 .getSelectedLocale("global", true);
+  var dateFormatter = new Intl.DateTimeFormat(locale, { year: '2-digit',
+                                                        month: 'numeric',
+                                                        day: 'numeric' });
+  var timeFormatter = new Intl.DateTimeFormat(locale, { hour: 'numeric',
+                                                        minute: 'numeric' });
   var ios = Cc["@mozilla.org/network/io-service;1"].
             getService(Ci.nsIIOService);
   var reportURI = ios.newURI(reportURL, null, null);
   // resolving this URI relative to /report/index
   var aboutThrottling = ios.newURI("../../about/throttling", null, reportURI);
 
   for (var i = 0; i < reports.length; i++) {
     var row = document.createElement("tr");
@@ -100,30 +106,20 @@ function populateReportList() {
     }
     link.setAttribute("id", reports[i].id);
     link.classList.add("crashReport");
     link.appendChild(document.createTextNode(reports[i].id));
     cell.appendChild(link);
 
     var date = new Date(reports[i].date);
     cell = document.createElement("td");
-    var datestr = formatter.FormatDate("",
-                                       Ci.nsIScriptableDateFormat.dateFormatShort,
-                                       date.getFullYear(),
-                                       date.getMonth() + 1,
-                                       date.getDate());
-    cell.appendChild(document.createTextNode(datestr));
+    cell.appendChild(document.createTextNode(dateFormatter.format(date)));
     row.appendChild(cell);
     cell = document.createElement("td");
-    var timestr = formatter.FormatTime("",
-                                       Ci.nsIScriptableDateFormat.timeFormatNoSeconds,
-                                       date.getHours(),
-                                       date.getMinutes(),
-                                       date.getSeconds());
-    cell.appendChild(document.createTextNode(timestr));
+    cell.appendChild(document.createTextNode(timeFormatter.format(date)));
     row.appendChild(cell);
     if (reports[i].pending) {
       document.getElementById("unsubmitted").appendChild(row);
     } else {
       document.getElementById("submitted").appendChild(row);
     }
   }
 }