]> git.neil.brown.name Git - plato.git/commitdiff
ical.py: clear up confusion with 'last' and 'next'.
authorNeilBrown <neilb@suse.de>
Mon, 30 Dec 2013 22:14:04 +0000 (09:14 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 30 Dec 2013 22:14:04 +0000 (09:14 +1100)
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.

lib/ical.py

index 5081d1b444174a8a3aca1815caecd94a3598f3ed..1f5204b35f577e255f44de074055c4559d6ad7c3 100644 (file)
@@ -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: