www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 698254adb7dd20854a0f188660302c5c243a3432
parent 69f273a60ecad5799df720e77c399f9c6603d456
Author: Simon Kornblith <simon@simonster.com>
Date:   Sun, 17 Jun 2012 10:12:40 -0400

Fix "value is undefined" error handling dates from embedded data

Diffstat:
Mchrome/content/zotero/xpcom/utilities.js | 37+++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js @@ -1489,21 +1489,30 @@ Zotero.Utilities = { } else { date = cslDate.literal; } - } else if(cslDate.year) { - if(variable === "accessed") { - // Need to convert to SQL - var date = Zotero.Utilities.lpad(cslDate.year, "0", 4); - if(cslDate.month) { - date += "-"+Zotero.Utilities.lpad(cslDate.month+1, "0", 2); - if(cslDate.day) { - date += "-"+Zotero.Utilities.lpad(cslDate.day, "0", 2); + } else { + var newDate = Zotero.Utilities.deepCopy(cslDate);; + if(cslDate.dateParts && typeof cslDate.dateParts == "object") { + if(cslDate.dateParts[0]) newDate.year = cslDate.dateParts[0]; + if(cslDate.dateParts[1]) newDate.month = cslDate.dateParts[1]; + if(cslDate.dateParts[2]) newDate.day = cslDate.dateParts[2]; + } + + if(newDate.year) { + if(variable === "accessed") { + // Need to convert to SQL + var date = Zotero.Utilities.lpad(newDate.year, "0", 4); + if(newDate.month) { + date += "-"+Zotero.Utilities.lpad(newDate.month+1, "0", 2); + if(newDate.day) { + date += "-"+Zotero.Utilities.lpad(newDate.day, "0", 2); + } + } + } else { + if(newDate.month) newDate.month--; + date = Zotero.Date.formatDate(newDate); + if(newDate.season) { + date = newDate.season+" "+date; } - } - } else { - if(cslDate.month) cslDate.month--; - date = Zotero.Date.formatDate(cslDate); - if(cslDate.season) { - date = date+" "+cslDate.season; } } }