0

当我使用 Office 365 API 创建日历事件时,我将时区指定为“W”。欧洲标准时间'并相应地格式化日期时间,例如;'2019-10-05T23:00:00+02:00'。

当客户端尝试编辑此日历条目时,它似乎改为使用 UTC。 它在客户端中的显示方式的图像。

Mac 上 Outlook 客户端的第二个示例;此处它以 UTC 显示,但会向用户发出警告,表明该事件实际上在计算机本地时区的 23:00 开始。Mac 上第二个示例的图像。

这是一个示例有效载荷:

    {'Attendees': [{'EmailAddress': {'Address': u'foo@bar.com',
        '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'}

我使用的 API URL 是:https ://outlook.office.com/api/v2.0/me/events

现在,客户帐户设置为与我们在挪威使用的时区相同的时区。当他们手动创建自己的日历条目时,他们永远不会看到这个问题。它仅适用于通过 API 创建的用户。

更令人困惑的是,在查看日历时这不是问题。它正确显示在每月视图以及 outlook.office365.com 站点中的“详细信息”视图中。主要是在在线套件中单击“编辑”时出现问题,以及在桌面 Outlook 客户端中查看时出现问题。它在在线 Outlook 站点中正确显示的示例。

任何帮助将不胜感激。谢谢!

4

1 回答 1

2

问题是您在 DateTime 字符串('2019-10-05T23:00:00 +02:00 ')中指定了时间偏移量。在这种情况下,TimeZone 参数被忽略并默认为 UTC。

如果您尝试这样做,它应该可以按预期工作:

 {
    'Attendees': [{
            'EmailAddress': {
                'Address': u 'foo@bar.com',
                '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'
}
于 2020-08-31T14:07:57.947 回答