mirror of
https://github.com/kennethreitz/maya.git
synced 2026-06-05 14:50:19 +00:00
Fix issue #168: intervals greater than one day were incorrect.
This commit is contained in:
+3
-1
@@ -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()
|
||||
)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user