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.)
This commit is contained in:
parent
d92f5669f3
commit
6673c64ac6
2 changed files with 18 additions and 0 deletions
|
@ -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()
|
||||
|
|
|
@ -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 = [
|
||||
|
|
Loading…
Reference in a new issue