ericgio / weekday-golf

A codified history of our bi-weekly-ish games.
1 stars 2 forks source link

Fixing Dates #34

Closed makinde closed 3 years ago

makinde commented 3 years ago

27 introduced an off by one error in date displays. This happened because javascript's Date constructor parses date strings in UTC, but renders them out in the local timezone. Only strings are parsed into UTC, while other param configurations are done in local time. Facepalm.

Options for a fix included passing the date arroung as an array of params to the Date constructor, but that feels a bit wonky. Another option is using moment, but that bring back 70k into the bundle to render a date. Other options were luxon (the newer, smaller successor to moment, made by its creators), but that also seemed like overkill. date-fns seems to be a nice, usable compromise. we're importing just the parseISO and format methods, and it gets done pretty simply.

makinde commented 3 years ago

Fixes #27 again