commit 6673c64ac651c94637f126be63b9f2a3e5ab9776
parent d92f5669f3f432550156786b615830b4c345e382
Author: Dan Stillman <dstillman@zotero.org>
Date: Sat, 19 Aug 2017 15:21:57 +0200
Fix accessDate when translators set CURRENT_TIMESTAMP
(But it also seems like we always do that automatically for web
translators, so I'm not sure why so many translators set that.)
Diffstat:
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js
@@ -107,6 +107,10 @@ Zotero.Translate.ItemSaver.prototype = {
newItem.libraryID = this._libraryID;
if (item.creators) this._cleanCreators(item.creators);
if(item.tags) item.tags = this._cleanTags(item.tags);
+
+ if (item.accessDate == 'CURRENT_TIMESTAMP') {
+ item.accessDate = Zotero.Date.dateToISO(new Date());
+ }
// Need to handle these specially. Put them in a separate object to
// avoid a warning from fromJSON()
diff --git a/test/tests/translateTest.js b/test/tests/translateTest.js
@@ -400,6 +400,20 @@ describe("Zotero.Translate", function() {
assert.isAbove(delta, -500);
assert.isBelow(delta, 5000);
});
+
+ it('web translators should set accessDate to current date for CURRENT_TIMESTAMP', function* () {
+ let myItem = {
+ itemType: "webpage",
+ title: "Test Item",
+ url: "https://www.zotero.org/",
+ accessDate: 'CURRENT_TIMESTAMP'
+ };
+ let newItems = yield saveItemsThroughTranslator("web", [myItem]);
+ let currentDate = new Date();
+ let delta = currentDate - Zotero.Date.sqlToDate(newItems[0].getField("accessDate"), true);
+ assert.isAbove(delta, -500);
+ assert.isBelow(delta, 5000);
+ });
it('web translators should save attachments', function* () {
let myItems = [