From 6d2080325620044669b4143a232fa9837ebb33a1 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 25 May 2017 19:49:55 -0400 Subject: [PATCH] Firefox 54 compatibility: dateFormat.properties -> Intl.DateTimeFormat --- chrome/content/zotero/xpcom/date.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/xpcom/date.js b/chrome/content/zotero/xpcom/date.js index d34c326a33..75547f95b4 100644 --- a/chrome/content/zotero/xpcom/date.js +++ b/chrome/content/zotero/xpcom/date.js @@ -54,19 +54,13 @@ Zotero.Date = new function(){ if(_months) return _months; if(Zotero.isFx && !Zotero.isBookmarklet) { - var src = 'chrome://global/locale/dateFormat.properties'; - var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1']. - getService(Components.interfaces.nsILocaleService); - var appLocale = localeService.getApplicationLocale(); - - var bundle = - Components.classes["@mozilla.org/intl/stringbundle;1"] - .getService(Components.interfaces.nsIStringBundleService).createBundle(src, appLocale); + let dtfShort = new Intl.DateTimeFormat('en', { year: 'numeric', month: 'short'}); + let dtfLong = new Intl.DateTimeFormat('en', { year: 'numeric', month: 'long'}); _months = {"short":[], "long":[]}; - for(var i=1; i<=12; i++) { - _months.short.push(bundle.GetStringFromName("month."+i+".Mmm")); - _months.long.push(bundle.GetStringFromName("month."+i+".name")); + for(var i=0; i<=11; i++) { + _months.short.push(dtfShort.format(new Date(2017, i)).split(' ')[0]); + _months.long.push(dtfLong.format(new Date(2017, i)).split(' ')[0]); } } else { // TODO localize for Chrome/Safari