diff --git a/maya/core.py b/maya/core.py index cdf018b..e66bbd3 100644 --- a/maya/core.py +++ b/maya/core.py @@ -806,4 +806,6 @@ def intervals(start, end, interval): while current_timestamp.epoch < end.epoch: yield current_timestamp - current_timestamp = current_timestamp.add(seconds=interval.seconds) + current_timestamp = current_timestamp.add( + seconds=interval.total_seconds() + ) diff --git a/tests/test_maya_interval.py b/tests/test_maya_interval.py index 1d040a4..1e1362b 100755 --- a/tests/test_maya_interval.py +++ b/tests/test_maya_interval.py @@ -570,3 +570,16 @@ def test_interval_from_iso8601_duration(): assert interval.start == s assert interval.end == e + + +def test_issue_168_regression(): + start = maya.now() + end = start.add(weeks=1) + gen = maya.intervals(start=start, end=end, interval=60 * 60 * 24) + # Since the bug causes the generator to never end, first sanity + # check that two results are not the same. + assert next(gen) != next(gen) + assert ( + len(list(maya.intervals(start=start, end=end, interval=60 * 60 * 24))) + == 7 + )