Fix issue #168: intervals greater than one day were incorrect.

This commit is contained in:
Frank Tobia
2019-01-02 14:03:34 -05:00
parent bdf2bb332b
commit 2c2a8d03c8
2 changed files with 16 additions and 1 deletions
+3 -1
View File
@@ -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()
)
+13
View File
@@ -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
)