From d500b50e2e86c707a3c704505cffb644ceac17b2 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 25 Jan 2010 18:39:23 +0000 Subject: [PATCH] Don't store literal 'today' in Date field --- chrome/content/zotero/bindings/itembox.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml index 15d7b3ecfe..6c1d1a1741 100644 --- a/chrome/content/zotero/bindings/itembox.xml +++ b/chrome/content/zotero/bindings/itembox.xml @@ -1810,6 +1810,23 @@ } } break; + + default: + // TODO: generalize to all date rows/fields + if (Zotero.ItemFields.isFieldOfBase(fieldName, 'date')) { + // Parse 'yesterday'/'today'/'tomorrow' and convert to dates, + // since it doesn't make sense for those to be actual metadata values + var lc = value.toLowerCase(); + if (lc == 'yesterday' || lc == Zotero.getString('date.yesterday')) { + value = Zotero.Date.dateToSQL(new Date(new Date().getTime() - 86400000)).substr(0, 10); + } + else if (lc == 'today' || lc == Zotero.getString('date.today')) { + value = Zotero.Date.dateToSQL(new Date()).substr(0, 10); + } + else if (lc == 'tomorrow' || lc == Zotero.getString('date.tomorrow')) { + value = Zotero.Date.dateToSQL(new Date(new Date().getTime() + 86400000)).substr(0, 10); + } + } } }