From 895a72a348c7ac55619536117b067b333691dbf5 Mon Sep 17 00:00:00 2001 From: s3lph Date: Sat, 21 Sep 2019 14:43:48 +0200 Subject: [PATCH] Fix: Keep showing events that already started, but have not finished yet --- CHANGELOG.md | 12 ++++++++++++ icalendar_timeseries_server/cal.py | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7ae123..168bb2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # iCalendar Timeseries Server Changelog + +## Version 0.3 + +### Changes + + +- Keep showing events that already started, but have not finished yet + + + + + ## Version 0.2 diff --git a/icalendar_timeseries_server/cal.py b/icalendar_timeseries_server/cal.py index 434e250..8db89b5 100644 --- a/icalendar_timeseries_server/cal.py +++ b/icalendar_timeseries_server/cal.py @@ -66,12 +66,13 @@ def _scrape_calendar(name: str, config: CalendarConfig, start: datetime, end: da for element in calendar.walk(): if element.name == "VEVENT": dtstart = element.get('dtstart').dt - if isinstance(dtstart, date): + # Apparently datetime is a subclass of date... + if isinstance(dtstart, date) and not isinstance(dtstart, datetime): dtstart = datetime(dtstart.year, dtstart.month, dtstart.day, tzinfo=start.tzinfo) # Process either end timestamp or duration, if present if 'dtend' in element: evend = element.get('dtend').dt - if isinstance(evend, date): + if isinstance(evend, date) and not isinstance(evend, datetime): evend = datetime(evend.year, evend.month, evend.day, tzinfo=start.tzinfo) duration = evend - dtstart elif 'duration' in element: @@ -83,7 +84,7 @@ def _scrape_calendar(name: str, config: CalendarConfig, start: datetime, end: da else: occurences = [dtstart] for occurence in occurences: - if start <= occurence < end: + if start <= occurence + duration and occurence < end: events.append(Event(name, element, occurence, occurence + duration)) with _SCRAPE_CACHE_LOCK: _SCRAPE_CACHE[name] = events