Fix entering date without time into Accessed

https://forums.zotero.org/discussion/65560/5-0-beta-accessed-field-changes-dates
This commit is contained in:
Dan Stillman 2017-05-05 17:57:24 -04:00
parent b679adad45
commit e0e22225bc
3 changed files with 9 additions and 2 deletions

View file

@ -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':

View file

@ -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);
}

View file

@ -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"