Skip to content

Commit

Permalink
Fix entering date without time into Accessed
Browse files Browse the repository at this point in the history
  • Loading branch information
dstillman committed May 5, 2017
1 parent b679ada commit e0e2222
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion chrome/content/zotero/bindings/itembox.xml
Expand Up @@ -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':
Expand Down
2 changes: 1 addition & 1 deletion chrome/content/zotero/xpcom/data/item.js
Expand Up @@ -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);
}
Expand Down
7 changes: 7 additions & 0 deletions test/tests/itemTest.js
Expand Up @@ -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"
Expand Down

0 comments on commit e0e2222

Please sign in to comment.