Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[115] Update formik datepicker date parsing method to avoid timezone issues #133

Merged

Conversation

stanislaw-zakrzewski
Copy link
Collaborator

Partly solves: #115

Formik was parsing date timestamp to local date, which caused issues for some of the timezones. Making sure that no parsing from UTC to local time takes place we fix that issue.

@stanislaw-zakrzewski stanislaw-zakrzewski self-assigned this May 22, 2024
@stanislaw-zakrzewski stanislaw-zakrzewski linked an issue May 22, 2024 that may be closed by this pull request
@@ -210,6 +210,8 @@ const initialValuesFromCase = (
},
events: {
...c.events,
dateEntry: toLocalDate(c.events.dateEntry),
dateReported: toLocalDate(c.events.dateReported),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason not to report in UTC everywhere? I can see the value of timezones in data collection, less so for reporting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do store all of the dates in the UTC values, however the component for selecting date on the front-end automatically adjusts date in UTC to local time, thus making the local-date itself. This was an issue as the users in "minus" timezones experienced an issue where they see a date set to a day before.
It can be solved by parsing the UTC date to a local date before by removing the time component (dayjs(dateString.split('T')[0]).toDate()), which will solve the issue with "skipping days" in certain timezones.

@stanislaw-zakrzewski stanislaw-zakrzewski merged commit a24ecec into main Aug 6, 2024
2 checks passed
@stanislaw-zakrzewski stanislaw-zakrzewski deleted the 115-consider-removal-of-date-auto-populate-function branch August 6, 2024 09:47
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.

Consider removal of Date auto-populate function
2 participants