summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2022-04-17 23:16:10 +0200
committercos <cos>2022-04-18 11:39:52 +0200
commit9cce59fb0878511be1a6dca92d994ca93a739d1f (patch)
tree72cb9a89a90de074c22fd6f976a5cffd48b4fa4a
parent0d34fa108f5669eabbe7df41c1431d203969183c (diff)
downloadcalendar-cli-9cce59fb0878511be1a6dca92d994ca93a739d1f.zip
Workaround bug with recurring events not expanding
Only one occurance gets showed in cases when the CalDAV server fails to expand recurring events. This is a known issue tracked by [issue157] in the caldav library's bug tracker, and would better be dealt with there. This change works around the issue, hammering the server with one query per occurance. Obviously not acceptable as a fix, but it gets the job done and serves as a temporary workaround. [issue157]: https://github.com/python-caldav/caldav/issues/157
-rwxr-xr-xcalendar-cli.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/calendar-cli.py b/calendar-cli.py
index 1891497..cec2e4d 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -553,8 +553,26 @@ def calendar_agenda(caldav_conn, args):
if not isinstance(dtstart, datetime):
dtstart = datetime(dtstart.year, dtstart.month, dtstart.day)
dtstart = _localize(dtstart, tzinfo)
-
- events.append({'dtstart': dtstart, 'instance': event})
+ if hasattr(event, "rrule"):
+ duration = event.dtend.value - event.dtstart.value
+ rrule = rrulestr(event.rrule.value, dtstart=event.dtstart.value, tzids=tzinfo)
+ dtstart_generator = rrule.xafter(search_dtstart)
+ for instance_dtstart in dtstart_generator:
+ repeated_events_ = find_calendar(caldav_conn, args).date_search(instance_dtstart, search_dtend, expand=True)
+ for event_cal_ in repeated_events_:
+ repeated_events__ = event_cal_.instance.components()
+ for instance in repeated_events__:
+ if instance.name != 'VEVENT':
+ continue
+ if not hasattr(instance, 'uid'):
+ continue
+ if getattr(instance, 'uid') != event.uid:
+ continue
+ instance.dtend.value = instance_dtstart + duration
+ events.append({'dtstart': instance_dtstart, 'instance': instance})
+ break
+ else:
+ events.append({'dtstart': dtstart, 'instance': event})
## changed to use the "key"-parameter at 2019-09-18, as needed for python3.
## this will probably cause regression on sufficiently old versions of python