Skip to content

Commit

Permalink
Apply 5.0 deprecation and renaming to neo4j.time module.
Browse files Browse the repository at this point in the history
This makes the module more robust as it models sub-second precision with ints
instead of floats. This finishes off the work started in PR neo4j#551.

Breaking changes:
 - `Duration`
   - The constructor does not accept `subseconds` anymore.
     Use `milliseconds`, `microseconds`, or `nanoseconds` instead.
   - The property `subseconds` has been removed.
     Use `nanoseconds` instead.
   - The property `hours_minutes_seconds` has been removed.
     Use `hours_minutes_seconds_nanoseconds` instead.
   - For all math operations holds: they are element-wise on
     (`months`, `days`, `nanoseconds`).
     This affects (i.e., changes) the working of `//`, `%`, `/`, and `*`.
     - Years are equal to 12 months.
     - Weeks are equal to 7 days.
     - `seconds`, `milliseconds`, `microseconds`, and `nanoseconds` are
       implicitly converted to `nanoseconds` or `seconds` as fit.
   - Multiplication and division allow for floats but will always result in
     integer values (round to nearest even).
 - `Time`
   - The constructor does not accept `float`s for `second` anymore.
     Use `nanosecond` instead.
   - Ticks are now nanoseconds since midnight (`int`).
     - The property `ticks_ns` has been renamed to `ticks`.
       The old `ticks` is no longer supported.
     - The property`from_ticks_ns` has been renamed to `from_ticks`.
       The old `from_ticks` is no longer supported.
   - The property `second` returns an `int` instead of a `float`.
     Use `nanosecond` to get the sub-second information.
   - The property `hour_minute_second` has been removed.
     Use `hour_minute_second_nanosecond` instead.
 - `DateTime`
   - The property `hour_minute_second` has been removed.
     Use `hour_minute_second_nanosecond` instead.
   - The property `second` returns an `int` instead of a `float`.
     Use `nanosecond` to get the sub-second information.
  • Loading branch information
robsdedude committed Jan 4, 2022
1 parent 0f53077 commit 53022c7
Show file tree
Hide file tree
Showing 9 changed files with 354 additions and 395 deletions.
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,40 @@
`neo4j.work`. They should've been imported from `neo4j` all along.
- Experimental pipelines feature has been removed.
- Experimental async driver has been added.
- `neo4j.time` module:
- `Duration`
- The constructor does not accept `subseconds` anymore.
Use `milliseconds`, `microseconds`, or `nanoseconds` instead.
- The property `subseconds` has been removed.
Use `nanoseconds` instead.
- The property `hours_minutes_seconds` has been removed.
Use `hours_minutes_seconds_nanoseconds` instead.
- For all math operations holds: they are element-wise on
(`months`, `days`, `nanoseconds`).
This affects (i.e., changes) the working of `//`, `%`, `/`, and `*`.
- Years are equal to 12 months.
- Weeks are equal to 7 days.
- `seconds`, `milliseconds`, `microseconds`, and `nanoseconds` are
implicitly converted to `nanoseconds` or `seconds` as fit.
- Multiplication and division allow for floats but will always result in
integer values (round to nearest even).
- `Time`
- The constructor does not accept `float`s for `second` anymore.
Use `nanosecond` instead.
- Ticks are now nanoseconds since midnight (`int`).
- The property `ticks_ns` has been renamed to `ticks`.
The old `ticks` is no longer supported.
- The property`from_ticks_ns` has been renamed to `from_ticks`.
The old `from_ticks` is no longer supported.
- The property `second` returns an `int` instead of a `float`.
Use `nanosecond` to get the sub-second information.
- The property `hour_minute_second` has been removed.
Use `hour_minute_second_nanosecond` instead.
- `DateTime`
- The property `hour_minute_second` has been removed.
Use `hour_minute_second_nanosecond` instead.
- The property `second` returns an `int` instead of a `float`.
Use `nanosecond` to get the sub-second information.

## Version 4.4

Expand Down
20 changes: 9 additions & 11 deletions docs/source/temporal_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ Class methods

.. automethod:: neo4j.time.Time.from_ticks

.. automethod:: neo4j.time.Time.from_ticks_ns

.. automethod:: neo4j.time.Time.from_native

.. automethod:: neo4j.time.Time.from_clock_time
Expand All @@ -164,15 +162,13 @@ Instance attributes

.. autoattribute:: neo4j.time.Time.ticks

.. autoattribute:: neo4j.time.Time.ticks_ns

.. autoattribute:: neo4j.time.Time.hour

.. autoattribute:: neo4j.time.Time.minute

.. autoattribute:: neo4j.time.Time.second

.. autoattribute:: neo4j.time.Time.hour_minute_second
.. autoattribute:: neo4j.time.Time.nanosecond

.. autoattribute:: neo4j.time.Time.hour_minute_second_nanosecond

Expand Down Expand Up @@ -290,8 +286,6 @@ Instance attributes

.. autoattribute:: neo4j.time.DateTime.tzinfo

.. autoattribute:: neo4j.time.DateTime.hour_minute_second

.. autoattribute:: neo4j.time.DateTime.hour_minute_second_nanosecond


Expand Down Expand Up @@ -388,14 +382,10 @@ Instance attributes

.. autoattribute:: neo4j.time.Duration.seconds

.. autoattribute:: neo4j.time.Duration.subseconds

.. autoattribute:: neo4j.time.Duration.nanoseconds

.. autoattribute:: neo4j.time.Duration.years_months_days

.. autoattribute:: neo4j.time.Duration.hours_minutes_seconds

.. autoattribute:: neo4j.time.Duration.hours_minutes_seconds_nanoseconds


Expand All @@ -410,6 +400,14 @@ Operations

.. automethod:: neo4j.time.Duration.__mul__

.. automethod:: neo4j.time.Duration.__truediv__

.. automethod:: neo4j.time.Duration.__floordiv__

.. automethod:: neo4j.time.Duration.__mod__

.. automethod:: neo4j.time.Duration.__divmod__

.. automethod:: neo4j.time.Duration.__pos__

.. automethod:: neo4j.time.Duration.__neg__
Expand Down
Loading

0 comments on commit 53022c7

Please sign in to comment.