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

Another possible serialization issue with the date transform #7

Open
Windvis opened this issue Oct 20, 2022 · 0 comments
Open

Another possible serialization issue with the date transform #7

Windvis opened this issue Oct 20, 2022 · 0 comments

Comments

@Windvis
Copy link
Collaborator

Windvis commented Oct 20, 2022

In #6 I switched from using UTC dates to local dates because it fixed some issues. It turns out that it might have created others though 😅, more specifically this potentially breaks UTC dates created in negative timezones.

For example, if you create a date instance like this:

new Date('2022-10-20') the browser will assume the date is an UTC date.

From the MDN docs:

Date-only strings (e.g. "1970-01-01") are treated as UTC, while date-time strings (e.g. "1970-01-01T12:00") are treated as local.

The time will still be set to 0, but for the UTC time. So it will be something like this in Belgian time: 2022-10-20T02:00:00+02:00. This will still serialize properly with the current implementation.

The problem is if you execute the code in a "negative" timezone. For example if you create the same UTC date in a -4 timezone it will serialize the previous date again: 2022-10-19T20:00:00-04:00 -> 2022-10-19.

So this PR wasn't really correct either, but I'm not sure what the real solution is at this point. I'm not smart enough for timezones 😬.

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

No branches or pull requests

1 participant