Skip to content

fixing timezone - #1381

Closed
ChayaNine wants to merge 1 commit into
neo4j:6.xfrom
ChayaNine:fix/1380-timezone-time-parameter
Closed

ChayaNine wants to merge 1 commit into
neo4j:6.xfrom
ChayaNine:fix/1380-timezone-time-parameter

Conversation

@ChayaNine

Copy link
Copy Markdown

Summary

Fixes #1380.

This PR fixes a TypeError when serializing Python datetime.time objects with a standard library datetime.timezone.

Changes

  • Fixed timezone offset handling in dehydrate_time().
  • Used value.utcoffset() for standard Python time objects.
  • Preserved support for Neo4j's custom Time objects.
  • Added regression tests covering positive, negative, and zero UTC offsets, as well as naive time objects.

Testing

  • Full unit test suite: 51,543 passed, 73 skipped
  • Regression tests: 6 passed
  • Ruff lint and formatting checks: Passed
  • Pre-commit checks: Passed
  • Tested on Windows with Python 3.12.10

The regression tests failed before the fix and passed afterward.

@robsdedude

Copy link
Copy Markdown
Member

Superseded by #1384

Thanks a bunch for taking a stab at this @ChayaNine. I had to dig into the problem myself to make up my mind on what approach would be best to take. As you can see in the linked PR, the logic turned out to be more involved as is needed to take into account:

  • Backward compatibility with undesired but present driver behavior
  • Time zones that don't have a fixed offset (where value.utcoffset() would return None)

I appreciate your effort and will make sure to give you credits in the changelog 🙇

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.

A datetime.time with a datetime.timezone can't be sent as a parameter: utcoffset(dt) argument must be a datetime instance

2 participants