Bug 1318204 - Provide fallback date/time formatting in about:crashes for Android, where Intl API is not available. r=gandalf

This commit is contained in:
Jonathan Kew 2016-11-19 12:48:46 +00:00
Родитель e472d96785
Коммит 85311d5f6e
1 изменённых файлов: 25 добавлений и 8 удалений

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

@ -78,14 +78,31 @@ function populateReportList() {
return;
}
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 dateFormatter;
var timeFormatter;
try {
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
dateFormatter = new Intl.DateTimeFormat(locale, { year: '2-digit',
month: 'numeric',
day: 'numeric' });
timeFormatter = new Intl.DateTimeFormat(locale, { hour: 'numeric',
minute: 'numeric' });
} catch (e) {
// XXX Fallback to be removed once bug 1215247 is complete
// and the Intl API is available on all platforms.
dateFormatter = {
format: function(date) {
return date.toLocaleDateString();
}
}
timeFormatter = {
format: function(date) {
return date.toLocaleTimeString();
}
}
}
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var reportURI = ios.newURI(reportURL, null, null);