diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 6762d68cc..fbadd7c0c 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1852,6 +1852,7 @@ Zotero.Date = new function(){ // TODO: Allow negative multipart in DB and here with \-? var _multipartRE = /^[0-9]{4}\-(0[0-9]|10|11|12)\-(0[0-9]|[1-2][0-9]|30|31) /; var _sqldateRE = /^\-?[0-9]{4}\-(0[1-9]|10|11|12)\-(0[1-9]|[1-2][0-9]|30|31)$/; + var _sqldateWithZeroesRE = /^\-?[0-9]{4}\-(0[0-9]|10|11|12)\-(0[0-9]|[1-2][0-9]|30|31)$/; var _sqldatetimeRE = /^\-?[0-9]{4}\-(0[1-9]|10|11|12)\-(0[1-9]|[1-2][0-9]|30|31) ([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$/; /** @@ -1900,7 +1901,10 @@ Zotero.Date = new function(){ } - function isSQLDate(str){ + function isSQLDate(str, allowZeroes) { + if (allowZeroes) { + return _sqldateWithZeroesRE.test(str); + } return _sqldateRE.test(str); } @@ -1911,17 +1915,17 @@ Zotero.Date = new function(){ function sqlHasYear(sqldate){ - return isSQLDate(sqldate) && sqldate.substr(0,4)!='0000'; + return isSQLDate(sqldate, true) && sqldate.substr(0,4)!='0000'; } function sqlHasMonth(sqldate){ - return isSQLDate(sqldate) && sqldate.substr(5,2)!='00'; + return isSQLDate(sqldate, true) && sqldate.substr(5,2)!='00'; } function sqlHasDay(sqldate){ - return isSQLDate(sqldate) && sqldate.substr(8,2)!='00'; + return isSQLDate(sqldate, true) && sqldate.substr(8,2)!='00'; }