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.htmlpull/28123/head
parent
dc3aa43f73
commit
cf32a6e390
homeassistant/components/caldav
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue