From: <jwi...@op...> - 2012-03-15 13:42:16
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "opentaps v2". The branch, master has been updated via ffd2dc9959024de0384f916773f2799b1dc754cc (commit) from 314c7e95abaad6f1d0ce15f3dfe8ee30815a66af (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ffd2dc9959024de0384f916773f2799b1dc754cc Author: Jeremy Wickersheimer <jwi...@gm...> Date: Thu Mar 15 21:41:31 2012 +0800 #2660 Manual date parsing as the Date object parser behavior varies from browser to browser diff --git a/clients/html/note_app.html b/clients/html/note_app.html index 6f533e0..e6c2568 100644 --- a/clients/html/note_app.html +++ b/clients/html/note_app.html @@ -476,6 +476,39 @@ notes.direction = "DESC"; notes.latestDisplayedNoteSequence = undefined; notes.oldestDisplayedNoteSequence = undefined; +function parseDate(dateStr) { + var date = new Date(); + + var parts = dateStr.split(" "); + + if (parts.length < 2) { + console.log("Date [" + dateStr + "] did not split into a Date + Time"); + return date; + } + + var dateParts = parts[0].split("-"); + if (dateParts.length < 3) { + console.log("Date part [" + parts[0] + "] did not split into Year - Month - Day"); + return date; + } + + date.setFullYear(dateParts[0]); + date.setMonth(dateParts[1] - 1); + date.setDate(dateParts[2]); + + var timeParts = parts[1].split(":"); + if (timeParts.length < 3) { + console.log("Time [" + dateStr + "] did not split into Hours : Minutes : Seconds"); + return date; + } + + date.setHours(timeParts[0]); + date.setMinutes(timeParts[1]); + date.setSeconds(timeParts[2]); + + return date; +} + function formatDate(d) { if (!d) return ""; var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); @@ -499,7 +532,7 @@ function createNoteElement(note) { } } - var dateCreated = formatDate(new Date(note.dateTimeCreated)); + var dateCreated = formatDate(parseDate(note.dateTimeCreated)); var userName = "anonymous"; var noteEl = document.createElement("div"); ----------------------------------------------------------------------- Summary of changes: clients/html/note_app.html | 35 ++++++++++++++++++++++++++++++++++- 1 files changed, 34 insertions(+), 1 deletions(-) hooks/post-receive -- opentaps v2 |