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
|
@ -108,6 +108,10 @@ Zotero.Translate.ItemSaver.prototype = {
|
||||||
if (item.creators) this._cleanCreators(item.creators);
|
if (item.creators) this._cleanCreators(item.creators);
|
||||||
if(item.tags) item.tags = this._cleanTags(item.tags);
|
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
|
// Need to handle these specially. Put them in a separate object to
|
||||||
// avoid a warning from fromJSON()
|
// avoid a warning from fromJSON()
|
||||||
let specialFields = {
|
let specialFields = {
|
||||||
|
|
|
@ -401,6 +401,20 @@ describe("Zotero.Translate", function() {
|
||||||
assert.isBelow(delta, 5000);
|
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* () {
|
it('web translators should save attachments', function* () {
|
||||||
let myItems = [
|
let myItems = [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue