Church-Plugins / cp-library

GNU General Public License v2.0
0 stars 0 forks source link

Fix broken relative date in Safari #31

Closed vleong2332 closed 3 years ago

vleong2332 commented 3 years ago

"YYYY-mm-dd hh:mm:ss.ssssss" returned by the API is not a valid date string format for the Date constructor (at least not supported by Safari). This results in new Date(dateString) returning Invalid Date value in Safari. The value becomes NaN eventually as the lib process the data and, by default, the string representation for that is "over a year from now".

The narrowest gap we can close is to make it a supported format by inserting a "T" where the space between the date and the time is. This commit does this on the front-end as we render the date but, ideally, the fix should be applied in the API layer.