PokeRogue-Projects / pokerogue-daily-runs

3 stars 9 forks source link

Fix date picker displaying incorrect date depending on timezone #43

Closed coinmoles closed 3 months ago

coinmoles commented 3 months ago

The date object created by new Date("yyyy-MM-dd") is the 00:00 of that date on UTC+0, but date picker display that date using local timezone. This caused inconsistency between date displayed as selected and date that was actually selected on some timezone. For example, if the user selects August 6th, 2024, new Date("2024-08-06") would be sent to the date picker, which will be "2024-08-06 00:00:00". However, since that is "2024-08-05 18:00:00" in central standard time (UTC-6), the date picker displayed 2024-08-05 as selected instead of 2024-08-06.

I was unable to find a way to force react-day-picker to use UTC, so I employed a workaround solution where I adjusted the date sent to date picker to account for timezone offset.

Closes #40