www

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

commit 69f273a60ecad5799df720e77c399f9c6603d456
parent a48a60a2303cd8a9d1be63709e132a3b285a514f
Author: Simon Kornblith <simon@simonster.com>
Date:   Fri, 15 Jun 2012 15:54:27 -0400

Fix handling of item types and accesDate in ZU.itemFromCSLJSON()

Diffstat:
Mchrome/content/zotero/xpcom/utilities.js | 27++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js @@ -1399,7 +1399,7 @@ Zotero.Utilities = { var isZoteroItem = item instanceof Zotero.Item, zoteroType; for(var type in CSL_TYPE_MAPPINGS) { - if(CSL_TYPE_MAPPINGS[zoteroType] == item.type) { + if(CSL_TYPE_MAPPINGS[type] == cslItem.type) { zoteroType = type; break; } @@ -1484,11 +1484,28 @@ Zotero.Utilities = { if(Zotero.ItemFields.isValidForType(fieldID, itemTypeID)) { var date = ""; if(cslDate.literal) { - date = cslDate.literal; + if(variable === "accessed") { + date = strToISO(cslDate.literal); + } else { + date = cslDate.literal; + } } else if(cslDate.year) { - if(cslDate.month) cslDate.month--; - date = Zotero.Date.formatDate(cslDate); - if(cslDate.season) date = cslDate.season+date; + 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 { + if(cslDate.month) cslDate.month--; + date = Zotero.Date.formatDate(cslDate); + if(cslDate.season) { + date = date+" "+cslDate.season; + } + } } if(isZoteroItem) {