Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/neo4j/time/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2019,6 +2019,12 @@ def __new__(
return cls.combine(Date(year, month, day),
Time(hour, minute, second, nanosecond, tzinfo))

# SERIALIZATION #

def __reduce__(cls):
return (cls.__class__,
(cls.year, cls.month, cls.day, cls.hour, cls.minute, cls.second, cls.nanosecond, cls.tzinfo))

# CLASS METHODS #

@classmethod
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/common/time/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import copy
import itertools
import operator
import pickle
from datetime import (
datetime,
timedelta,
Expand Down Expand Up @@ -410,6 +411,11 @@ def test_datetime_deep_copy(self) -> None:
assert d is not d2
assert d == d2

def test_datetime_pickle(self) -> None:
expected = DateTime(2023, 12, 7, 12, 34, 56, 7890)
actual = pickle.loads(pickle.dumps(expected))
assert expected == actual


def test_iso_format_with_time_zone_case_1() -> None:
# python -m pytest tests/unit/time/test_datetime.py -s -v -k test_iso_format_with_time_zone_case_1
Expand Down