Fix display of pre-1000 dates in Year column and Quick Format

And avoid "0000" in Year column if date value but unparsed year
This commit is contained in:
Dan Stillman 2019-12-19 03:22:55 -05:00
parent b7dc0d8b0a
commit 85a3f03002
2 changed files with 13 additions and 3 deletions

View file

@ -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

View file

@ -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();