]> git.neil.brown.name Git - plato.git/commitdiff
ical: avoid returning invalid dates for MONTHLY lists.
authorNeilBrown <neilb@suse.de>
Mon, 30 Dec 2013 03:44:47 +0000 (14:44 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 30 Dec 2013 03:44:47 +0000 (14:44 +1100)
If a MONTHLY list starts on the 31st of the month, we mustn't
return e.g. 31st June.

lib/ical.py

index c4afe36c2a399b913893cf42b876ff6d255493f7..5081d1b444174a8a3aca1815caecd94a3598f3ed 100644 (file)
@@ -216,7 +216,7 @@ class date_seq:
         else:
             return None
         self.now.set_wday()
-        return self.now
+        return self.now, self.now.day <= daysin(self.now.mon, self.now.yr)
 
 # Each BY* is filter which will discards moments, or generates sub-moments.
 # e.g. BYMONTH will discard non-matching MONTHLY, WEEKLY etc moments, and
@@ -652,7 +652,9 @@ def make_dates(start, rr):
         if n1:
             last = n1[-1]
             ret.extend(n1)
-        last = s.next()
+        last, valid = s.next()
+        while not valid and 'BYDAY' not in rr.bylist and 'BYMONTHDAY' not in rr.bylist:
+            last, valid = s.next()
     if rr.count:
         ret = ret[:rr.count]
     if rr.end: