【问题标题】:Office 365 API Calendar events time zone display in clients gets UTC客户端中的 Office 365 API 日历事件时区显示获取 UTC
【发布时间】:2019-09-25 07:28:10
【问题描述】:

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

当客户端尝试编辑此日历条目时,它似乎改为使用 UTC。 Image of how it appears in the client.

Mac 上 Outlook 客户端的第二个示例;此处它以 UTC 显示,但向用户发出警告,表明该事件实际上在计算机本地时区的 23:00 开始。 Image of second example on a 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 客户端中查看时出现问题。 Example of it looking correctly in the online outlook site.

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

【问题讨论】:

    标签: office365 office365api outlook-restapi outlook-calendar


    【解决方案1】:

    问题在于您在 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'
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多