python-o365 icon indicating copy to clipboard operation
python-o365 copied to clipboard

All Day Events returned as UTC

Open RogerSelwyn opened this issue 4 years ago • 2 comments

I'm looking at why All Day Events are displayed incorrectly in Home Assistant. They currently show as offset by the difference from UTC. I think this is because All Day Events are returned by the module at UTC because of the Prefer header in this:

        response = self.con.get(url, params=params,
                                headers={'Prefer': 'outlook.timezone="UTC"'})

Is it your intent that the calling code handles the 'conversion' of all day events to the right time period, or is your code intended to handle that. I can see that your re doing some time conversion when returning the event, but because the MS responses shows it as always UTC timezone, this conversion is wrong.

For instance when I create an event in the UK (which is currently at +1 because of daylight saving), I would expect this to display as n all day event, instead it shows as starting at 1am.

To test this when send a timezone of "America/Los Angeles" as part of the setup to python-o355, it then returns the event converted to the LA timezone, but because it has been treated as UTC instead of +1, it then is out by 1 hour.

So, I'd either expect you to always return a time of 00:00 for start and end of an all day event, or to handle some mechanism for identifying the correct timezone to convert from. I don't know the Graph API at all, so I don't know if any timezone is stored for all day events but I can see through a bit of googling that one can be sent to the API when then event is created, but not sure if it is stored.

If I know what is meant to happen, I'll then try and handle at the HA end.

RogerSelwyn avatar Sep 25 '21 17:09 RogerSelwyn

This is something that was originally coded as it is now but we know produces errors... See #368

alejcas avatar Oct 11 '21 07:10 alejcas

From what I can see after further research, an All Day event should be passed as a Date rather than a Datetime, and without any translation. I recognise that you probably have a lot of apps depending on your module, so it may not be easy to correct. For me, I've handled it by always requesting UTC from your module which then does no translation on all day events (I believe), and the front end display then does translation to user timezone.

RogerSelwyn avatar Oct 11 '21 07:10 RogerSelwyn