Don't store literal 'today' in Date field

This commit is contained in:
Dan Stillman 2010-01-25 18:39:23 +00:00
parent c2fea7e4da
commit d500b50e2e

View file

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