Skip to content

Commit

Permalink
made two dumb changes to not crash on recurring events set by GCalendar
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTheNerd committed Dec 9, 2024
1 parent 2711a14 commit 53a4123
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions plugins/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def update(self):
until_date = datetime.datetime.strptime(until, "%Y%m%dT%H%M%SZ").date()
until_date = datetime.datetime.combine(until_date, datetime.time(0, tzinfo=self.local_tz))
else:
until_date = datetime.datetime.now(tzinfo=self.local_tz) + datetime.timedelta(days=400)
until_date = datetime.datetime.now(self.local_tz) + datetime.timedelta(days=400)
if freq == "DAILY":
rrule_set = dateutil.rrule.rrule(dateutil.rrule.DAILY, interval=interval, dtstart=event_start, until=until_date)
elif freq == "WEEKLY":
Expand All @@ -90,8 +90,15 @@ def update(self):
'SU': dateutil.rrule.SU,
}
weekdays = []
for weekday_str in byweekday.split(','):
weekdays.append(weekday_mapping[weekday_str.upper()])
if byweekday:
for weekday_str in byweekday.split(','):
weekdays.append(weekday_mapping[weekday_str.upper()])
else:
# we have no choice but to assume it's the day of week in the current occurrence
weekday_of_event = event_start.weekday()
recurrence_weekday = list(weekday_mapping.values())[weekday_of_event]
weekdays.append(recurrence_weekday)

rrule_set = dateutil.rrule.rrule(dateutil.rrule.WEEKLY, interval=interval, dtstart=event_start, byweekday=weekdays, until=until_date)
elif freq == "MONTHLY":
rrule_set = dateutil.rrule.rrule(dateutil.rrule.MONTHLY, interval=interval, dtstart=event_start, until=until_date)
Expand Down

0 comments on commit 53a4123

Please sign in to comment.