diff --git a/.gitignore b/.gitignore index b7480daa..f1152e6f 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,7 @@ profile.html /wheelhouse /docs/site/* pyproject.lock + +# editor + +.vscode \ No newline at end of file diff --git a/pendulum/_extensions/helpers.py b/pendulum/_extensions/helpers.py index c8b57f34..0c07a9ee 100644 --- a/pendulum/_extensions/helpers.py +++ b/pendulum/_extensions/helpers.py @@ -282,10 +282,6 @@ def precise_diff(d1, d2): hour_diff += 24 d_diff -= 1 - if d1 > d2: - d1, d2 = d2, d1 - sign = -1 - y_diff = d2.year - d1.year m_diff = d2.month - d1.month d_diff += d2.day - d1.day diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 134892ca..9bb57f3a 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -115,6 +115,14 @@ def test_precise_diff_timezone(): days=1, hours=5 ) + # Issue238 + dt1 = timezone('UTC').datetime(2018, 6, 20, 1, 30) + dt2 = timezone('Europe/Paris').datetime(2018, 6, 20, 3, 40) # UTC+2 + diff = precise_diff(dt1, dt2) + assert_diff( + diff, + minutes=10 + ) def test_week_day(): assert 5 == week_day(2017, 6, 2)