Skip to content

Clean up neo4j.time public exports #1191

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 2 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
- Remove `ExperimentalWarning` and turn the few left instances of it into `PreviewWarning`.
- Deprecate importing `PreviewWarning` from `neo4j`.
Import it from `neo4j.warnings` instead.
- Make undocumented internal constants and helper functions private:
- Make undocumented internal constants, helper functions, and other items private:
- `neo4j.api`
- `DRIVER_BOLT`
- `DRIVER_NEO4J`
Expand All @@ -98,6 +98,23 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
- `ERROR_REWRITE_MAP`
- `client_errors`
- `transient_errors`
- `neo4j.time`
- `DATE_ISO_PATTERN`
- `TIME_ISO_PATTERN`
- `DURATION_ISO_PATTERN`
- `NANO_SECONDS`
- `AVERAGE_SECONDS_IN_MONTH`
- `AVERAGE_SECONDS_IN_DAY`
- `FORMAT_F_REPLACE`
- `IS_LEAP_YEAR`
- `DAYS_IN_YEAR`
- `DAYS_IN_MONTH`
- `round_half_to_even`
- `symmetric_divmod`
- `DateTimeType`
- `DateType`
- `TimeType`
- all other indirectly exposed items from imports (e.g. `re` as `neo4j.time.re`)
- `neo4j.spatial`
- `hydrate_point`
- `dehydrate_point`
Expand All @@ -111,6 +128,10 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
- `.default_host`
- `.default_port`
- `.default_target`
- Deprecate ClockTime and its accessors
- For each `neo4j.time.Date`, `neo4j.time.DateTime`, `neo4j.time.Time`
- `from_clock_time` and `to_clock_time` methods
- `neo4j.time.ClockTime` itself
- Raise `ConfigurationError` instead of ignoring the routing context (URI query parameters) when creating a direct
driver ("bolt[+s[sc]]://" scheme).
- Change behavior of closed drivers:
Expand Down
9 changes: 5 additions & 4 deletions src/neo4j/_codec/hydration/v1/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
pd,
)
from ....time import (
_NANO_SECONDS,
Date,
DateTime,
Duration,
MAX_YEAR,
MIN_YEAR,
NANO_SECONDS,
Time,
)
from ...packstream import Structure
Expand Down Expand Up @@ -170,8 +170,8 @@ def seconds_and_nanoseconds(dt):
if isinstance(dt, datetime):
dt = DateTime.from_native(dt)
zone_epoch = DateTime(1970, 1, 1, tzinfo=dt.tzinfo)
dt_clock_time = dt.to_clock_time()
zone_epoch_clock_time = zone_epoch.to_clock_time()
dt_clock_time = dt._to_clock_time()
zone_epoch_clock_time = zone_epoch._to_clock_time()
t = dt_clock_time - zone_epoch_clock_time
return t.seconds, t.nanoseconds

Expand Down Expand Up @@ -226,7 +226,8 @@ def dehydrate_np_datetime(value):
)
seconds = value.astype(np.dtype("datetime64[s]")).astype(int)
nanoseconds = (
value.astype(np.dtype("datetime64[ns]")).astype(int) % NANO_SECONDS
value.astype(np.dtype("datetime64[ns]")).astype(int)
% _NANO_SECONDS
)
return Structure(b"d", seconds, nanoseconds)

Expand Down
8 changes: 4 additions & 4 deletions src/neo4j/_codec/hydration/v2/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

from ...._optional_deps import pd
from ....time import (
_NANO_SECONDS,
Date,
DateTime,
NANO_SECONDS,
Time,
)
from ...packstream import Structure
Expand Down Expand Up @@ -74,8 +74,8 @@ def seconds_and_nanoseconds(dt):
dt = DateTime.from_native(dt)
dt = dt.astimezone(pytz.UTC)
utc_epoch = DateTime(1970, 1, 1, tzinfo=pytz.UTC)
dt_clock_time = dt.to_clock_time()
utc_epoch_clock_time = utc_epoch.to_clock_time()
dt_clock_time = dt._to_clock_time()
utc_epoch_clock_time = utc_epoch._to_clock_time()
t = dt_clock_time - utc_epoch_clock_time
return t.seconds, t.nanoseconds

Expand Down Expand Up @@ -119,7 +119,7 @@ def dehydrate_pandas_datetime(value):
:type value: pandas.Timestamp
:returns:
"""
seconds, nanoseconds = divmod(value.value, NANO_SECONDS)
seconds, nanoseconds = divmod(value.value, _NANO_SECONDS)

tz = value.tzinfo
if tz is None:
Expand Down
Loading