From 7af166ed857b8b8d5cffc594e18c559ab68df3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Lombra=C3=B1a=20Gonz=C3=A1lez?= Date: Tue, 13 Nov 2012 16:00:15 +0100 Subject: [PATCH] Create a Date using the Date type. This commit fixes an error in Safari that was not working. Moment.JS was not converting correctly a string, while with thix fix works. More info here: http://stackoverflow.com/questions/2587345/javascript-date-parse --- src/view.timeline.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/view.timeline.js b/src/view.timeline.js index d00cb577..f49e119c 100644 --- a/src/view.timeline.js +++ b/src/view.timeline.js @@ -142,7 +142,10 @@ my.Timeline = Backbone.View.extend({ var out = date.trim(); out = out.replace(/(\d)th/g, '$1'); out = out.replace(/(\d)st/g, '$1'); - out = out.trim() ? moment(out) : null; + // parse a date in yyyy-mm-dd hh:mm format + var parts = out.match(/(\d+)/g); + out = new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4]); + out = moment(out); if (out.toDate() == 'Invalid Date') { return null; } else {