www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 3f6ef7fb01f81cef2de78edd11399f7e97c1b232
parent 5847388862a95379cf703972c6b0815037bd3976
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri,  5 Jan 2018 03:40:57 -0500

Allow "now" in Accessed field to use current time

Closes #1340

Diffstat:
Mchrome/content/zotero/bindings/itembox.xml | 6+++++-
Mtest/tests/itemPaneTest.js | 21+++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml @@ -1884,8 +1884,12 @@ if (value != '') { switch (fieldName) { case 'accessDate': + // Allow "now" to use current time + if (value == 'now') { + value = Zotero.Date.dateToSQL(new Date(), true); + } // If just date, don't convert to UTC - if (Zotero.Date.isSQLDate(value)) { + else if (Zotero.Date.isSQLDate(value)) { var localDate = Zotero.Date.sqlToDate(value); value = Zotero.Date.dateToSQL(localDate).replace(' 00:00:00', ''); } diff --git a/test/tests/itemPaneTest.js b/test/tests/itemPaneTest.js @@ -110,6 +110,27 @@ describe("Item pane", function () { // Wait for no-op saveTx() yield Zotero.Promise.delay(1); }); + + it("should accept 'now' for Accessed", async function () { + var item = await createDataObject('item'); + + var itemBox = doc.getElementById('zotero-editpane-item-box'); + var box = doc.getAnonymousNodes(itemBox)[0]; + var label = box.querySelector('label[fieldname="accessDate"][class="zotero-clicky"]'); + label.click(); + var textbox = box.querySelector('textbox[fieldname="accessDate"]'); + textbox.value = 'now'; + // Blur events don't necessarily trigger if window doesn't have focus + itemBox.hideEditor(textbox); + + await waitForItemEvent('modify'); + + assert.approximately( + Zotero.Date.sqlToDate(item.getField('accessDate'), true).getTime(), + Date.now(), + 1000 + ); + }); })