commit 995091d0a1bde1c7e745103d1d31f1673df5ea40
parent dec5af4d6a5592103fb7692e8f99d10fa368841a
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 7 Mar 2013 18:15:03 -0500
Merge branch '3.0' into 3.1
Conflicts:
chrome/content/zotero/xpcom/date.js
Diffstat:
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/chrome/content/zotero/xpcom/date.js b/chrome/content/zotero/xpcom/date.js
@@ -228,30 +228,31 @@ Zotero.Date = new function(){
var _dayRe = null;
function strToDate(string) {
+ var date = {};
+
+ // skip empty things
+ if(!string) {
+ return date;
+ }
+
+ date.order = '';
+ var parts = [];
+
// Parse 'yesterday'/'today'/'tomorrow'
var lc = (string + '').toLowerCase();
if (lc == 'yesterday' || (Zotero.getString && lc === Zotero.getString('date.yesterday'))) {
- string = Zotero.Date.dateToSQL(new Date(new Date().getTime() - 86400000)).substr(0, 10);
+ string = Zotero.Date.dateToSQL(new Date(Date.now() - 1000*60*60*24)).substr(0, 10);
}
else if (lc == 'today' || (Zotero.getString && lc == Zotero.getString('date.today'))) {
string = Zotero.Date.dateToSQL(new Date()).substr(0, 10);
}
else if (lc == 'tomorrow' || (Zotero.getString && lc == Zotero.getString('date.tomorrow'))) {
- string = Zotero.Date.dateToSQL(new Date(new Date().getTime() + 86400000)).substr(0, 10);
+ string = Zotero.Date.dateToSQL(new Date(Date.now() + 1000*60*60*24)).substr(0, 10);
}
-
- var date = {
- order: ''
- };
- var parts = [];
-
- // skip empty things
- if(!string) {
- return date;
+ else {
+ string = string.toString().replace(/^\s+|\s+$/g, "").replace(/\s+/, " ");
}
- string = string.toString().replace(/^\s+/, "").replace(/\s+$/, "").replace(/\s+/, " ");
-
// first, directly inspect the string
var m = _slashRe.exec(string);
if(m &&
@@ -442,13 +443,16 @@ Zotero.Date = new function(){
// clean up date part
if(date.part) {
- date.part = date.part.replace(/^[^A-Za-z0-9]+/, "").replace(/[^A-Za-z0-9]+$/, "");
+ date.part = date.part.replace(/^[^A-Za-z0-9]+|[^A-Za-z0-9]+$/g, "");
}
if(date.part === "" || date.part == undefined) {
delete date.part;
}
+ //make sure year is always a string
+ if(date.year || date.year === 0) date.year += '';
+
return date;
}
@@ -787,4 +791,4 @@ Zotero.Date = new function(){
}
return _localeDateOrder;
}
-}
-\ No newline at end of file
+}