From 85a3f0300278e366c5ab1acb85263cdd98b7f8d7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 19 Dec 2019 03:22:55 -0500 Subject: [PATCH] Fix display of pre-1000 dates in Year column and Quick Format And avoid "0000" in Year column if date value but unparsed year --- chrome/content/zotero/integration/quickFormat.js | 4 ++-- chrome/content/zotero/xpcom/itemTreeView.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index 48ea4009e1..a1d6c92182 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -521,7 +521,7 @@ var Zotero_QuickFormat = new function () { if(item.firstCreator) author = authorDate = item.firstCreator; var date = item.getField("date", true, true); if(date && (date = date.substr(0, 4)) !== "0000") { - authorDate += " ("+date+")"; + authorDate += " (" + parseInt(date) + ")"; } authorDate = authorDate.trim(); if(authorDate) nodes.push(authorDate); @@ -647,7 +647,7 @@ var Zotero_QuickFormat = new function () { // Date var date = item.getField("date", true, true); if(date && (date = date.substr(0, 4)) !== "0000") { - str += ", "+date; + str += ", " + parseInt(date); } // Locator diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 56b3590332..84348d90c1 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -1058,7 +1058,17 @@ Zotero.ItemTreeView.prototype.getCellText = function (row, column) } // Year column is just date field truncated else if (column.id == "zotero-items-column-year") { - val = obj.getField('date', true).substr(0, 4) + val = obj.getField('date', true).substr(0, 4); + if (val) { + // Don't show anything for unparsed year + if (val === "0000") { + val = ""; + } + // Show pre-1000 year without leading zeros + else if (val < 1000) { + val = parseInt(val); + } + } } else if (column.id === "zotero-items-column-numNotes") { val = obj.numNotes();