www

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

commit e0e22225bcbce9c2ce2d929391461e7350ee5349
parent b679adad45f889cbcf561a0d1fa66470abffd0cc
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri,  5 May 2017 17:57:24 -0400

Fix entering date without time into Accessed

https://forums.zotero.org/discussion/65560/5-0-beta-accessed-field-changes-dates

Diffstat:
Mchrome/content/zotero/bindings/itembox.xml | 2+-
Mchrome/content/zotero/xpcom/data/item.js | 2+-
Mtest/tests/itemTest.js | 7+++++++
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml @@ -1854,7 +1854,7 @@ // Fields else { - // Access date needs to be parsed and converted to UTC + // Access date needs to be parsed and converted to UTC SQL date if (value != '') { switch (fieldName) { case 'accessDate': diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -805,7 +805,7 @@ Zotero.Item.prototype.setField = function(field, value, loadIn) { else if (fieldID == Zotero.ItemFields.getID('accessDate')) { if (value && value != 'CURRENT_TIMESTAMP') { // Accept ISO dates - if (Zotero.Date.isISODate(value)) { + if (Zotero.Date.isISODate(value) && !Zotero.Date.isSQLDate(value)) { let d = Zotero.Date.isoToDate(value); value = Zotero.Date.dateToSQL(d, true); } diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js @@ -207,6 +207,13 @@ describe("Zotero.Item", function () { } }) + it("should accept SQL accessDate without time", function* () { + var item = createUnsavedDataObject('item'); + var date = "2017-04-05"; + item.setField("accessDate", date); + assert.strictEqual(item.getField('accessDate'), date); + }); + it("should ignore unknown accessDate values", function* () { var fields = { accessDate: "foo"