From cf32a6e39058e340816ae1e3ebd4a2c236b91964 Mon Sep 17 00:00:00 2001 From: Lukas Hetzenecker Date: Wed, 23 Oct 2019 03:11:26 +0200 Subject: [PATCH] Fix #28104 - CalDav support for floating datetimes Timzones are optional in CalDav It is possible that an entry contains neither a TZID, nor is an UTC time. When this is the case, it should be treated as a floating date-time value, which represent the same hour, minute, and second value regardless of which time zone is currently being observed. For Home-Assistant the correct timezone therefore is whatever is configured as local time in the settings. See https://www.kanzaki.com/docs/ical/dateTime.html --- homeassistant/components/caldav/calendar.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/caldav/calendar.py b/homeassistant/components/caldav/calendar.py index 2bbff2a6bc7..3dee2079700 100644 --- a/homeassistant/components/caldav/calendar.py +++ b/homeassistant/components/caldav/calendar.py @@ -262,9 +262,12 @@ class WebDavCalendarData: @staticmethod def is_over(vevent): """Return if the event is over.""" - return dt.now() >= WebDavCalendarData.to_datetime( - WebDavCalendarData.get_end_date(vevent) - ) + end_date = WebDavCalendarData.to_datetime(WebDavCalendarData.get_end_date(vevent)) + if end_date.tzinfo is None: + # floating value, not bound to any time zone in particular + # represent same time regardless of which time zone is currently being observed + end_date = end_date.astimezone(dt.DEFAULT_TIME_ZONE) + return dt.now() >= end_date @staticmethod def get_hass_date(obj):