diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 7f064d6cbb..1ed4ae5d3e 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -492,7 +492,29 @@ Zotero.ItemTreeView.prototype.getCellText = function(row, column) if(column.id == 'zotero-items-column-dateAdded' || column.id == 'zotero-items-column-dateModified') //this is not so much that we will use this format for date, but a simple template for later revisions. { - val = new Date(Date.parse(val.replace(/-/g,"/"))).toLocaleString(); + // Format date as short date in proper locale order and locale time + // (e.g. "4/4/07 14:27:23") + var order = Zotero.Date.getLocaleDateOrder(); + var date = Zotero.Date.sqlToDate(val, true); + var parts = []; + for (var i=0; i<3; i++) { + switch (order[i]) { + case 'y': + parts.push(date.getFullYear().toString().substr(2)); + break; + + case 'm': + parts.push((date.getMonth() + 1)); + break; + + case 'd': + parts.push(date.getDate()); + break; + } + + val = parts.join('/'); + val += ' ' + date.toLocaleTimeString(); + } } return val; diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 20f22c0ee9..ad04844a08 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -986,6 +986,8 @@ Zotero.Date = new function(){ this.getFileTimeString = getFileTimeString; this.getLocaleDateOrder = getLocaleDateOrder; + var _localeDateOrder = null; + /** * Convert an SQL date in the form '2006-06-13 11:03:05' into a JS Date object @@ -1380,9 +1382,13 @@ Zotero.Date = new function(){ * Returns a string with y, m, and d (e.g. 'ymd', 'mdy') */ function getLocaleDateOrder(){ + if (_localeDateOrder) { + return _localeDateOrder; + } + var date = new Date("October 5, 2006"); var parts = date.toLocaleDateString().match(/([0-9]+)[^0-9]+([0-9]+)[^0-9]+([0-9]+)/); - alert(parts); + switch (parseInt(parts[1])){ case 2006: var order = 'y'; @@ -1417,6 +1423,8 @@ Zotero.Date = new function(){ break; } + _localeDateOrder = order; + return order; } }