nominaldelta

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

commit
cb6c98f5d5a930ab393ab9fa50d9b38c3c1582fc
parent
1b0b36d742cdfbc82fa5cbbbcb5a53c5598f2217
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-08-31 01:25
rm years

cases like `NominalDelta(days=1000).years == 0` can be confusing

Diffstat

M nominaldelta.py 4 ----
M test.py 4 ----

2 files changed, 0 insertions, 8 deletions


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

@@ -87,10 +87,6 @@ class NominalDelta:
   87    87             f'seconds={self.seconds})'
   88    88         )
   89    89 
   90    -1     @property
   91    -1     def years(self: Self) -> int:
   92    -1         return self.months // 12
   93    -1 
   94    90     def __eq__(self, other: Self) -> Self:
   95    91         if isinstance(other, NominalDelta):
   96    92             return (

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

@@ -7,10 +7,6 @@ from nominaldelta import NominalDelta
    7     7 
    8     8 
    9     9 class TestNominalDelta(unittest.TestCase):
   10    -1     def test_years(self):
   11    -1         self.assertEqual(NominalDelta(years=3, months=15).years, 4)
   12    -1         self.assertEqual(NominalDelta(years=3, months=-1).years, 2)
   13    -1 
   14    10     def test_weeks(self):
   15    11         self.assertEqual(NominalDelta(weeks=2, days=2).days, 16)
   16    12         self.assertEqual(NominalDelta(weeks=2, days=-1).days, 13)