Skip to content
Merged
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
11 changes: 3 additions & 8 deletions neo4j/time/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2563,14 +2563,9 @@ def to_ordinal(self) -> int:

def to_clock_time(self) -> ClockTime:
"""Convert to :class:`.ClockTime`."""
total_seconds = 0
for year in range(1, self.year):
total_seconds += 86400 * DAYS_IN_YEAR[year]
for month in range(1, self.month):
total_seconds += 86400 * Date.days_in_month(self.year, month)
total_seconds += 86400 * (self.day - 1)
seconds, nanoseconds = divmod(self.__time.ticks, NANO_SECONDS)
return ClockTime(total_seconds + seconds, nanoseconds)
ordinal_seconds = 86400 * (self.__date.to_ordinal() - 1)
time_seconds, nanoseconds = divmod(self.__time.ticks, NANO_SECONDS)
return ClockTime(ordinal_seconds + time_seconds, nanoseconds)

def to_native(self) -> datetime:
"""Convert to a native Python :class:`datetime.datetime` value.
Expand Down