Receiving the next or previous iteration always affects the current iteration
Fliens opened this issue · 7 comments
I want to get the previous or next iteration without affecting the current iteration that can be received with get_current() function.
Is there a way to get this behaviour?
Otherwise a simple if statement above line 363 with some function parameters could introduce this functionality.
Would reverse next/prev the same to undo the consumed iterations solve your problem ?
eg if you
>>> iter.get_next(datetime)
>>> iter.get_next(datetime)
>>> iter.get_next(datetime)
Then, if you do
>>> iter.get_prev(datetime)
>>> iter.get_prev(datetime)
>>> iter.get_prev(datetime)
you should be in same state, and such one function is easy to write.
Thank you for the response but this seems like an extremely hacky solution.
Thank you for the response but this seems like an extremely hacky solution.
Why so, croniter is an iterator, every iteration is reproducible.
I do understand that but the current implementation requires some extra steps for example to calculate a time period:
start_time = cron.get_prev(datetime)
cron.get_next(datetime) # unnecessary call that requires some computing
period = cron.get_current(datetime) - start_time
By adding an extra argument to get_next(update_cur=False) / get_prev(update_cur=False), this additional call would no longer be necessary, resulting in cleaner code overall.
Yes absolutelty!