Fix - 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
pull/28123/head
Lukas Hetzenecker 2019-10-23 03:11:26 +02:00
parent dc3aa43f73
commit cf32a6e390
1 changed files with 6 additions and 3 deletions
homeassistant/components/caldav

View File

@ -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):