From 72a511ba816ab848e677d25fa58152d119d7c928 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Fri, 18 Mar 2011 08:26:55 +0000 Subject: [PATCH] fix for lowercase months in non-English locales --- chrome/content/zotero/xpcom/date.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/date.js b/chrome/content/zotero/xpcom/date.js index 9cd9c496d..b29eb8a28 100644 --- a/chrome/content/zotero/xpcom/date.js +++ b/chrome/content/zotero/xpcom/date.js @@ -330,12 +330,14 @@ Zotero.Date = new function(){ // MONTH if(!date.month) { // compile month regular expression - var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', - 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + var months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', + 'aug', 'sep', 'oct', 'nov', 'dec']; // If using a non-English bibliography locale, try those too if (Zotero.locale != 'en-US') { - months = months.concat(Zotero.Date.months.short); + months = months.concat(Zotero.Date.months.short).concat(Zotero.Date.months.long); + for(var i in months) months[i] = months[i].toLowerCase(); } + if(!_monthRe) { _monthRe = new RegExp("^(.*)\\b("+months.join("|")+")[^ ]*(?: (.*)$|$)", "i"); } @@ -343,7 +345,7 @@ Zotero.Date = new function(){ var m = _monthRe.exec(date.part); if(m) { // Modulo 12 in case we have multiple languages - date.month = months.indexOf(m[2][0].toUpperCase()+m[2].substr(1).toLowerCase()) % 12; + date.month = months.indexOf(m[2].toLowerCase()) % 12; date.part = m[1]+m[3]; Zotero.debug("DATE: got month ("+date.month+", "+date.part+")"); }