diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml index fdec1317b..9639e3cf1 100644 --- 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 index e9caab6bb..081d59fde 100644 --- 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 + ); + }); })