hack4impact-uiuc / nnb-frontend

Frontend for Neighborhood News Bureau
2 stars 0 forks source link

sorting dates not working because api date format is invalid format #121

Closed vrunjeti closed 6 years ago

vrunjeti commented 6 years ago

we need to change the format of the date the api sends because moment isn't able to sort the dates properly:

value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.

vrunjeti commented 6 years ago

the sorting values are resulting in NaN for some values

vrunjeti commented 6 years ago

played around with it, it looks like the year 512 was the one causing issues with utc. when that map year isn't in the story, the sorting works. closing this issue since dealing with years like 512 is an edge case we shouldn't really have to worry about considering nnb's specific use case

vrunjeti commented 6 years ago

the format the api sends looks like: Fri, 01 Jan 512 00:00:00 GMT. played around with it some more, and using 01 Jan 512 00:00:00 GMT is valid. maybe if we chop off the day part of the string, it'll work from year 0 onwards

vrunjeti commented 6 years ago

relevant: https://stackoverflow.com/a/48693122/5773182