Fix datetime parameter validation for list events (#95778)
This commit is contained in:
parent
2f73be0e50
commit
4581c36648
2 changed files with 10 additions and 2 deletions
|
@ -67,6 +67,14 @@ class DemoCalendar(CalendarEntity):
|
|||
end_date: datetime.datetime,
|
||||
) -> list[CalendarEvent]:
|
||||
"""Return calendar events within a datetime range."""
|
||||
if start_date.tzinfo is None:
|
||||
start_date = start_date.replace(
|
||||
tzinfo=dt_util.get_time_zone(hass.config.time_zone)
|
||||
)
|
||||
if end_date.tzinfo is None:
|
||||
end_date = end_date.replace(
|
||||
tzinfo=dt_util.get_time_zone(hass.config.time_zone)
|
||||
)
|
||||
assert start_date < end_date
|
||||
if self._event.start_datetime_local >= end_date:
|
||||
return []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue