mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Fix caldav component handling missing dtend (#12562)
This commit is contained in:
parent
c898fb1f16
commit
722926b315
@ -166,7 +166,7 @@ class WebDavCalendarData(object):
|
|||||||
self.event = {
|
self.event = {
|
||||||
"summary": vevent.summary.value,
|
"summary": vevent.summary.value,
|
||||||
"start": self.get_hass_date(vevent.dtstart.value),
|
"start": self.get_hass_date(vevent.dtstart.value),
|
||||||
"end": self.get_hass_date(vevent.dtend.value),
|
"end": self.get_hass_date(self.get_end_date(vevent)),
|
||||||
"location": self.get_attr_value(vevent, "location"),
|
"location": self.get_attr_value(vevent, "location"),
|
||||||
"description": self.get_attr_value(vevent, "description")
|
"description": self.get_attr_value(vevent, "description")
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ class WebDavCalendarData(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def is_over(vevent):
|
def is_over(vevent):
|
||||||
"""Return if the event is over."""
|
"""Return if the event is over."""
|
||||||
return dt.now() > WebDavCalendarData.to_datetime(vevent.dtend.value)
|
return dt.now() > WebDavCalendarData.get_end_date(vevent)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_hass_date(obj):
|
def get_hass_date(obj):
|
||||||
@ -217,3 +217,17 @@ class WebDavCalendarData(object):
|
|||||||
if hasattr(obj, attribute):
|
if hasattr(obj, attribute):
|
||||||
return getattr(obj, attribute).value
|
return getattr(obj, attribute).value
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_end_date(obj):
|
||||||
|
"""Return the end datetime as determined by dtend or duration."""
|
||||||
|
if hasattr(obj, "dtend"):
|
||||||
|
enddate = obj.dtend.value
|
||||||
|
|
||||||
|
elif hasattr(obj, "duration"):
|
||||||
|
enddate = obj.dtstart.value + obj.duration.value
|
||||||
|
|
||||||
|
else:
|
||||||
|
enddate = obj.dtstart.value + timedelta(days=1)
|
||||||
|
|
||||||
|
return WebDavCalendarData.to_datetime(enddate)
|
||||||
|
@ -64,7 +64,49 @@ LOCATION:Hamburg
|
|||||||
DESCRIPTION:What a beautiful day
|
DESCRIPTION:What a beautiful day
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
|
""",
|
||||||
|
"""BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//Global Corp.//CalDAV Client//EN
|
||||||
|
BEGIN:VEVENT
|
||||||
|
UID:4
|
||||||
|
DTSTAMP:20171125T000000Z
|
||||||
|
DTSTART:20171127
|
||||||
|
SUMMARY:This is an event without dtend or duration
|
||||||
|
LOCATION:Hamburg
|
||||||
|
DESCRIPTION:What an endless day
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR
|
||||||
|
""",
|
||||||
|
"""BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//Global Corp.//CalDAV Client//EN
|
||||||
|
BEGIN:VEVENT
|
||||||
|
UID:5
|
||||||
|
DTSTAMP:20171125T000000Z
|
||||||
|
DTSTART:20171127
|
||||||
|
DURATION:PT1H
|
||||||
|
SUMMARY:This is an event with duration
|
||||||
|
LOCATION:Hamburg
|
||||||
|
DESCRIPTION:What a day
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR
|
||||||
|
""",
|
||||||
|
"""BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//Global Corp.//CalDAV Client//EN
|
||||||
|
BEGIN:VEVENT
|
||||||
|
UID:6
|
||||||
|
DTSTAMP:20171125T000000Z
|
||||||
|
DTSTART:20171127T100000Z
|
||||||
|
DURATION:PT1H
|
||||||
|
SUMMARY:This is an event with duration
|
||||||
|
LOCATION:Hamburg
|
||||||
|
DESCRIPTION:What a day
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR
|
||||||
"""
|
"""
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user