Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events not showing in order of time #39

Open
iamleese opened this issue Aug 18, 2016 · 1 comment
Open

Events not showing in order of time #39

iamleese opened this issue Aug 18, 2016 · 1 comment

Comments

@iamleese
Copy link

My events aren't showing in order by time. The json file is correct (and in order). Is there a way to sort by time?

screen shot 2016-08-18 at 3 33 31 pm

{ "date": "2016-08-22 8:00:00", "endtime": "", "title": "Mass ", "description": "Location: Church", "url": "" }, { "date": "2016-08-22 9:00:00", "endtime": "", "title": "Spanish Prayer Group in De Moor Room ", "description": "Location: De Moor Room", "url": "" }, { "date": "2016-08-22 10:00:00", "endtime": "", "title": "Small Church Communities (Krenz) in Room 2 - CMO ", "description": "Location: Room 2 - CMO", "url": "" }, { "date": "2016-08-22 10:00:00", "endtime": "", "title": "Women's Guild Meeting in Room 5 - CMO ", "description": "Location: Room 5 - CMO", "url": "" }, { "date": "2016-08-22 18:00:00", "endtime": "", "title": "Cub Scouts 355 Pack Meeting in Resource Room 1 & 2 ", "description": "Location: Verhoeven Room", "url": "" },

@iamleese
Copy link
Author

iamleese commented Aug 22, 2016

Solved the issue. The date string needed to be converted to a date object in order to be read correctly.

function sortJson(a, b){
var DateObj;
if ( typeof a.date === 'string' ) { //convert to object
DateObj = Date.parse(date);
return a.DateObj> b.DateObj ? 1 : -1;
}
return a.date > b.date ? 1 : -1;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant