Skip to content

Commit 97fd0e1

Browse files
authored
Apply 5.0 deprecation and renaming to neo4j.time module. (#635)
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 #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.
1 parent 19ad25b commit 97fd0e1

File tree

9 files changed

+355
-395
lines changed

9 files changed

+355
-395
lines changed

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,41 @@
1515
- `trust` has been removed.
1616
Use `trusted_certificates` instead which expects `None` or a `list`. See the
1717
API documentation for more details.
18+
- `neo4j.time` module:
19+
- `Duration`
20+
- The constructor does not accept `subseconds` anymore.
21+
Use `milliseconds`, `microseconds`, or `nanoseconds` instead.
22+
- The property `subseconds` has been removed.
23+
Use `nanoseconds` instead.
24+
- The property `hours_minutes_seconds` has been removed.
25+
Use `hours_minutes_seconds_nanoseconds` instead.
26+
- For all math operations holds: they are element-wise on
27+
(`months`, `days`, `nanoseconds`).
28+
This affects (i.e., changes) the working of `//`, `%`, `/`, and `*`.
29+
- Years are equal to 12 months.
30+
- Weeks are equal to 7 days.
31+
- `seconds`, `milliseconds`, `microseconds`, and `nanoseconds` are
32+
implicitly converted to `nanoseconds` or `seconds` as fit.
33+
- Multiplication and division allow for floats but will always result in
34+
integer values (round to nearest even).
35+
- `Time`
36+
- The constructor does not accept `float`s for `second` anymore.
37+
Use `nanosecond` instead.
38+
- Ticks are now nanoseconds since midnight (`int`).
39+
- The property `ticks_ns` has been renamed to `ticks`.
40+
The old `ticks` is no longer supported.
41+
- The property`from_ticks_ns` has been renamed to `from_ticks`.
42+
The old `from_ticks` is no longer supported.
43+
- The property `second` returns an `int` instead of a `float`.
44+
Use `nanosecond` to get the sub-second information.
45+
- The property `hour_minute_second` has been removed.
46+
Use `hour_minute_second_nanosecond` instead.
47+
- `DateTime`
48+
- The property `hour_minute_second` has been removed.
49+
Use `hour_minute_second_nanosecond` instead.
50+
- The property `second` returns an `int` instead of a `float`.
51+
Use `nanosecond` to get the sub-second information.
52+
1853

1954
## Version 4.4
2055

docs/source/temporal_types.rst

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ Class methods
142142

143143
.. automethod:: neo4j.time.Time.from_ticks
144144

145-
.. automethod:: neo4j.time.Time.from_ticks_ns
146-
147145
.. automethod:: neo4j.time.Time.from_native
148146

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

165163
.. autoattribute:: neo4j.time.Time.ticks
166164

167-
.. autoattribute:: neo4j.time.Time.ticks_ns
168-
169165
.. autoattribute:: neo4j.time.Time.hour
170166

171167
.. autoattribute:: neo4j.time.Time.minute
172168

173169
.. autoattribute:: neo4j.time.Time.second
174170

175-
.. autoattribute:: neo4j.time.Time.hour_minute_second
171+
.. autoattribute:: neo4j.time.Time.nanosecond
176172

177173
.. autoattribute:: neo4j.time.Time.hour_minute_second_nanosecond
178174

@@ -290,8 +286,6 @@ Instance attributes
290286

291287
.. autoattribute:: neo4j.time.DateTime.tzinfo
292288

293-
.. autoattribute:: neo4j.time.DateTime.hour_minute_second
294-
295289
.. autoattribute:: neo4j.time.DateTime.hour_minute_second_nanosecond
296290

297291

@@ -388,14 +382,10 @@ Instance attributes
388382

389383
.. autoattribute:: neo4j.time.Duration.seconds
390384

391-
.. autoattribute:: neo4j.time.Duration.subseconds
392-
393385
.. autoattribute:: neo4j.time.Duration.nanoseconds
394386

395387
.. autoattribute:: neo4j.time.Duration.years_months_days
396388

397-
.. autoattribute:: neo4j.time.Duration.hours_minutes_seconds
398-
399389
.. autoattribute:: neo4j.time.Duration.hours_minutes_seconds_nanoseconds
400390

401391

@@ -410,6 +400,14 @@ Operations
410400

411401
.. automethod:: neo4j.time.Duration.__mul__
412402

403+
.. automethod:: neo4j.time.Duration.__truediv__
404+
405+
.. automethod:: neo4j.time.Duration.__floordiv__
406+
407+
.. automethod:: neo4j.time.Duration.__mod__
408+
409+
.. automethod:: neo4j.time.Duration.__divmod__
410+
413411
.. automethod:: neo4j.time.Duration.__pos__
414412

415413
.. automethod:: neo4j.time.Duration.__neg__

0 commit comments

Comments
 (0)