From: NeilBrown Date: Mon, 30 Dec 2013 22:14:04 +0000 (+1100) Subject: ical.py: clear up confusion with 'last' and 'next'. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=59f7cb2a10c78b78be64d220a34a53ac794c6fcd;p=plato.git ical.py: clear up confusion with 'last' and 'next'. The value stored in 'last' was being over-written. This could lead to the end condition failing sometimes. 'last' is the last value added. we stop when that exceeds the end point. 'next' is the next value to add. --- diff --git a/lib/ical.py b/lib/ical.py index 5081d1b..1f5204b 100644 --- a/lib/ical.py +++ b/lib/ical.py @@ -613,9 +613,10 @@ byaction = { def make_dates(start, rr): ret = [] last = start + next = last s = date_seq(start, rr.interval, rr.step) while (rr.count != None and len(ret) < rr.count) or (rr.end != None and last.before(rr.end)): - n1 = [ copy.copy(last) ] + n1 = [ copy.copy(next) ] for bn in byorder: if bn not in rr.bylist: continue @@ -652,9 +653,9 @@ def make_dates(start, rr): if n1: last = n1[-1] ret.extend(n1) - last, valid = s.next() + next, valid = s.next() while not valid and 'BYDAY' not in rr.bylist and 'BYMONTHDAY' not in rr.bylist: - last, valid = s.next() + next, valid = s.next() if rr.count: ret = ret[:rr.count] if rr.end: