Brille
Brille

Reputation: 1

Office 365 API Calendar events time zone display in clients gets UTC

When I create calendar events using the Office 365 API, I specify timezone to be 'W. Europe Standard Time' and format the datetime accordingly, eg; '2019-10-05T23:00:00+02:00'.

When the clients try to edit this calendar entry, it appears to be in UTC instead. Image of how it appears in the client.

Second example from the Outlook client on a Mac; Here it displays in UTC but gives a warning to the user that the event actually starts at 23:00 in the computers local timezone. Image of second example on a Mac.

Here is an example payload:

    {'Attendees': [{'EmailAddress': {'Address': u'[email protected]',
        'Name': u'John Doe'},
       'Type': 'Required'}],
     'Body': {'Content': u'The content',
      'ContentType': 'HTML'},

     'Start': {'DateTime': '2019-10-05T23:00:00+02:00',
      'TimeZone': 'W. Europe Standard Time'},

     'End': {'DateTime': '2019-10-06T00:00:00+02:00',
      'TimeZone': 'W. Europe Standard Time'},

     'Location': {'Address': None,
     'DisplayName': 'Some display name'},

     'Subject': u'Some subject'}

The API URL I am using is: https://outlook.office.com/api/v2.0/me/events

Now the clients accounts are set to the same timezone as we use this one in Norway. When they create their own calendar entries manually, they never see this problem. It is only for those created through the API.

To confuse things a bit further, this is not a problem when viewing the calendar as such. It appears correctly in the monthly view as well as the "detail" view in the outlook.office365.com site. It is mainly a problem when clicking "Edit" in the online suite, as well as when viewing it in the desktop Outlook client. Example of it looking correctly in the online outlook site.

Any help would be greatly appreciated. Thanks!

Upvotes: 0

Views: 465

Answers (1)

csc
csc

Reputation: 21

The issue is that you specify a time offset in your DateTime string ('2019-10-05T23:00:00 +02:00'). In that case the TimeZone argument is ignored and defaults to UTC.

If you try this it should work as expected:

 {
    'Attendees': [{
            'EmailAddress': {
                'Address': u '[email protected]',
                'Name': u 'John Doe'
            },
            'Type': 'Required'
        }
    ],
    'Body': {
        'Content': u 'The content',
        'ContentType': 'HTML'
    },

    'Start': {
        'DateTime': '2019-10-05T23:00:00',
        'TimeZone': 'W. Europe Standard Time'
    },

    'End': {
        'DateTime': '2019-10-06T00:00:00',
        'TimeZone': 'W. Europe Standard Time'
    },

    'Location': {
        'Address': None,
        'DisplayName': 'Some display name'
    },

    'Subject': u 'Some subject'
}

Upvotes: 2

Related Questions