Fix: Keep showing events that already started, but have not finished yet
This commit is contained in:
parent
20ae18e064
commit
895a72a348
2 changed files with 16 additions and 3 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,6 +1,18 @@
|
|||
# iCalendar Timeseries Server Changelog
|
||||
|
||||
|
||||
<!-- BEGIN RELEASE v0.3 -->
|
||||
## Version 0.3
|
||||
|
||||
### Changes
|
||||
|
||||
<!-- BEGIN CHANGES 0.3 -->
|
||||
- Keep showing events that already started, but have not finished yet
|
||||
<!-- END CHANGES 0.3 -->
|
||||
|
||||
<!-- END RELEASE v0.3 -->
|
||||
|
||||
|
||||
<!-- BEGIN RELEASE v0.2 -->
|
||||
## Version 0.2
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue