aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fietsboek/util.py2
-rw-r--r--tests/unit/test_util.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/fietsboek/util.py b/fietsboek/util.py
index c507cf1..02981c0 100644
--- a/fietsboek/util.py
+++ b/fietsboek/util.py
@@ -91,7 +91,7 @@ def round_timedelta_to_multiple(
"""
lower = value.total_seconds() // multiples.total_seconds() * multiples.total_seconds()
second_offset = value.total_seconds() - lower
- if second_offset < multiples.total_seconds() // 2:
+ if second_offset <= multiples.total_seconds() // 2:
# Round down
return datetime.timedelta(seconds=lower)
# Round up
diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py
index 949acb5..0ac5c33 100644
--- a/tests/unit/test_util.py
+++ b/tests/unit/test_util.py
@@ -30,6 +30,11 @@ def test_fix_iso_timestamp(timestamp, fixed):
@pytest.mark.parametrize('delta, multiple, expected', [
(
+ timedelta(seconds=0),
+ timedelta(seconds=1),
+ timedelta(seconds=0),
+ ),
+ (
timedelta(minutes=42),
timedelta(minutes=15),
timedelta(minutes=45),