Skip to content

fix: datetime parsing with non-UTC timezones #2322

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

Merged
merged 4 commits into from
Mar 12, 2024
Merged

Conversation

mxschmitt
Copy link
Member

@mxschmitt mxschmitt commented Feb 26, 2024

Motivation: This makes datetime with non-UTC timezone objects

@mxschmitt mxschmitt force-pushed the fix-datetime-parsing branch from b40b669 to a67c336 Compare February 26, 2024 13:42
@mxschmitt mxschmitt changed the title chore: fix datetime parsing fix: datetime parsing Feb 26, 2024
@mxschmitt mxschmitt force-pushed the fix-datetime-parsing branch from 2967a13 to 5c8d201 Compare February 26, 2024 19:06
@mxschmitt mxschmitt marked this pull request as ready for review February 26, 2024 19:06
@mxschmitt mxschmitt marked this pull request as draft February 26, 2024 19:13
@mxschmitt mxschmitt force-pushed the fix-datetime-parsing branch from 5c8d201 to 0e65fb7 Compare March 5, 2024 11:41
@mxschmitt mxschmitt marked this pull request as ready for review March 5, 2024 11:43
@mxschmitt mxschmitt force-pushed the fix-datetime-parsing branch 3 times, most recently from eddec2b to aaa2bf2 Compare March 5, 2024 16:20
@mxschmitt mxschmitt changed the title fix: datetime parsing fix: datetime parsing with timezones Mar 5, 2024
@mxschmitt mxschmitt changed the title fix: datetime parsing with timezones fix: datetime parsing with non-UTC timezones Mar 5, 2024
@mxschmitt mxschmitt force-pushed the fix-datetime-parsing branch from aaa2bf2 to 3879299 Compare March 5, 2024 19:54
@@ -205,7 +210,10 @@ def parse_value(value: Any, refs: Optional[Dict[int, Any]] = None) -> Any:
return a

if "d" in value:
return datetime.fromisoformat(value["d"][:-1])
# Node.js Date objects are always in UTC.
return datetime.datetime.strptime(
Copy link
Member

Choose a reason for hiding this comment

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

It's unfortunate that we send an iso string over the wire, parsing millis since epoch (with datetime.fromtimestamp) would be more straightforward. But that's a big change.

@mxschmitt mxschmitt merged commit 812f8f9 into main Mar 12, 2024
@mxschmitt mxschmitt deleted the fix-datetime-parsing branch March 12, 2024 16:20
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.

2 participants