www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 1ea0e14ad392ec997f908d671634f3b683c1a382
parent 496daebd8edf0e395f6fbee51953c48546d96327
Author: Dan Stillman <dstillman@zotero.org>
Date:   Mon, 14 Aug 2006 03:19:01 +0000

Fixes #182, Date Added/Modified is in UTC

Added isUTC parameter to Scholar.Date.sqlToDate() and now run the two columns through that

Side effect: now using toLocaleString() to format the date strings


Diffstat:
Mchrome/chromeFiles/content/scholar/itemPane.js | 13++++++++++---
Mchrome/chromeFiles/content/scholar/xpcom/scholar.js | 8+++++++-
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js @@ -118,9 +118,16 @@ ScholarItemPane = new function() for(var i = 0; i<fieldNames.length; i++) { var editable = (!_itemBeingEdited.isPrimaryField(fieldNames[i]) || _itemBeingEdited.isEditableField(fieldNames[i])); - - var valueElement = createValueElement(_itemBeingEdited.getField(fieldNames[i]), editable ? fieldNames[i] : null); - + + var val = _itemBeingEdited.getField(fieldNames[i]); + + // Convert dates from UTC + if (fieldNames[i]=='dateAdded' || fieldNames[i]=='dateModified'){ + val = Scholar.Date.sqlToDate(val, true).toLocaleString(); + } + + var valueElement = createValueElement(val, editable ? fieldNames[i] : null); + var label = document.createElement("label"); label.setAttribute("value",Scholar.getString("itemFields."+fieldNames[i])+":"); label.setAttribute("onclick","this.nextSibling.blur();"); diff --git a/chrome/chromeFiles/content/scholar/xpcom/scholar.js b/chrome/chromeFiles/content/scholar/xpcom/scholar.js @@ -596,7 +596,7 @@ Scholar.Date = new function(){ * * Can also accept just the date part (e.g. '2006-06-13') **/ - function sqlToDate(sqldate){ + function sqlToDate(sqldate, isUTC){ try { var datetime = sqldate.split(' '); var dateparts = datetime[0].split('-'); @@ -606,6 +606,12 @@ Scholar.Date = new function(){ else { timeparts = [false, false, false]; } + + if (isUTC){ + return new Date(Date.UTC(dateparts[0], dateparts[1]-1, dateparts[2], + timeparts[0], timeparts[1], timeparts[2])); + } + return new Date(dateparts[0], dateparts[1]-1, dateparts[2], timeparts[0], timeparts[1], timeparts[2]); }