python-o365
python-o365 copied to clipboard
all-day event exceeds from one day
When I'm going to create a new all-day event using the following lines it creates that for two days!
...
event = self.calendar.new_event()
event.subject = kwargs.get("summary", "Orangery")
event.location = kwargs.get("location", "Germany")
event.start = datetime.combine(start_date, datetime.min.time()) # coverts date to datetime
event.end = event.start + timedelta(hours=24)
event.is_all_day = True
print(event.start, event.end)
Out:
2022-09-30 00:00:00+03:00 2022-10-01 00:00:00+03:00
Screenshot:

Seems like a bug
This is the code on is_all_day:
@is_all_day.setter
def is_all_day(self, value):
self.__is_all_day = value
if value:
# Api requirement: start and end must be set to midnight
# is_all_day needs event.start included in the request on updates
# is_all_day needs event.end included in the request on updates
start = self.__start or dt.date.today()
end = self.__end or dt.date.today()
if (start + dt.timedelta(hours=24)) > end:
# Api requires that under is_all_day=True start and
# end must be at least 24 hours away
end = start + dt.timedelta(hours=24)
# set to midnight
start = dt.datetime(start.year, start.month, start.day)
end = dt.datetime(end.year, end.month, end.day)
self.start = start
self.end = end
self._track_changes.add(self._cc('isAllDay'))