Skip to content
This repository was archived by the owner on Aug 27, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions custom_components/o365/calendar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import logging
import copy
from operator import attrgetter, itemgetter
from datetime import timedelta, datetime
from datetime import timedelta, datetime, tzinfo
from pytz import timezone
import pytz
from homeassistant.util import Throttle, dt
from homeassistant.components.calendar import (
CalendarEventDevice,
Expand Down Expand Up @@ -191,8 +193,12 @@ async def async_get_events(self, hass, start_date, end_date):
event_list = []
for event in vevent_list:
data = format_event_data(event, self.calendar.calendar_id)
data["start"] = self.get_hass_date(data["start"])
data["end"] = self.get_hass_date(data["end"])
if not data["is_all_day"]:
data["start"] = self.get_hass_date(data["start"])
data["end"] = self.get_hass_date(data["end"])
else:
data["start"] = self.get_hass_date(data["start"].astimezone(pytz.utc).date())
data["end"] = self.get_hass_date((data["end"].astimezone(pytz.utc).date()))
event_list.append(data)

return event_list
Expand Down Expand Up @@ -249,8 +255,9 @@ def to_datetime(obj):
if obj.tzinfo is None:
return obj.replace(tzinfo=dt.DEFAULT_TIME_ZONE)
return obj
return dt.as_local(dt.dt.datetime.combine(obj, dt.dt.time.min))

return dt.dt.datetime.combine(obj, dt.dt.time.min).replace(
tzinfo=dt.DEFAULT_TIME_ZONE
)
@staticmethod
def get_end_date(obj):
if hasattr(obj, "end"):
Expand Down