From 29f436289411b784efab244a5e1aa58b1bf63f88 Mon Sep 17 00:00:00 2001 From: iamleese Date: Mon, 22 Aug 2016 11:49:57 -0700 Subject: [PATCH] Convert string date to date object This allows for the dates and times to be sorted in the correct order if a file's JSON date is a string. --- js/jquery.eventCalendar.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/jquery.eventCalendar.js b/js/jquery.eventCalendar.js index aedd90b..5dc2d2e 100644 --- a/js/jquery.eventCalendar.js +++ b/js/jquery.eventCalendar.js @@ -148,9 +148,13 @@ } function sortJson(a, b){ - if ( typeof a.date === 'string' ) { - return a.date.toLowerCase() > b.date.toLowerCase() ? 1 : -1; - } + var DateObj; + + if ( typeof a.date === 'string' ) { //convert to object if date is a string + DateObj = Date.parse(date); + return a.DateObj> b.DateObj ? 1 : -1; + } + return a.date > b.date ? 1 : -1; }