Skip to content

fix(routines): resolve local timezone shift bug on naive dates#1251

Open
Marcelluxx wants to merge 1 commit into
wger-project:masterfrom
Marcelluxx:fix/timezone-dates-2334
Open

fix(routines): resolve local timezone shift bug on naive dates#1251
Marcelluxx wants to merge 1 commit into
wger-project:masterfrom
Marcelluxx:fix/timezone-dates-2334

Conversation

@Marcelluxx
Copy link
Copy Markdown

API returns naive date strings (e.g., 'YYYY-MM-DD') representing routine start and end dates. When parsed and formatted locally, negative UTC offset browser timezones shift the date backward by one day (e.g., formatting UTC midnight as the previous day in local browser time).

Proposed Changes

  1. Implemented formatNaiveDate in date.ts to format date strings and standard Date objects timezone-agnostically using timeZone: UTC.
  2. Replaced dateToLocale calls with formatNaiveDate in routine detail, template detail, and overview screens.
  3. Added exhaustive unit test coverage in date.test.ts verifying parsing, month boundaries, Date object support, and invalid/fallback inputs.

Related Issue(s)

Closes wger-project/wger#2334

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)

API returns naive date strings (e.g., 'YYYY-MM-DD') representing routine start and end dates. When parsed and formatted locally, negative UTC offset browser timezones shift the date backward by one day (e.g., formatting UTC midnight as the previous day in local browser time).

To fix this, we: 1. Implemented 'formatNaiveDate' in 'date.ts' to format date strings and standard Date objects timezone-agnostically using 'timeZone: UTC'. 2. Replaced 'dateToLocale' calls with 'formatNaiveDate' in routine detail, template detail, and overview screens. 3. Added exhaustive unit test coverage in 'date.test.ts' verifying parsing, month boundaries, Date object support, and invalid/fallback inputs.
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

Successfully merging this pull request may close these issues.

Start and End Date of Routine are 1 day off

1 participant