nominaldelta

nominal difference of date/datetime
git clone https://git.ce9e.org/nominaldelta.git

commit
e52e0cfdc2016e89eac20862d93d2dfe6441249c
parent
04c42b2137211fc1b49503ea53c9b016f29b9ace
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-08-31 08:36
fix; avoid negative seconds in diff()

Diffstat

M nominaldelta.py 3 +++

1 files changed, 3 insertions, 0 deletions


diff --git a/nominaldelta.py b/nominaldelta.py

@@ -62,6 +62,9 @@ def dt_diff(a, b):
   62    62         return -dt_diff(b, a)
   63    63     delta = date_diff(a, b)
   64    64     seconds = b.timestamp() - (a + delta).timestamp()
   -1    65     if seconds < 0:
   -1    66         delta -= NominalDelta(days=1)
   -1    67         seconds = b.timestamp() - (a + delta).timestamp()
   65    68     return delta + NominalDelta(seconds=seconds)
   66    69 
   67    70