【问题标题】:Google doesn't return time zone for some calendarsGoogle 不会返回某些日历的时区
【发布时间】:2017-08-02 13:32:27
【问题描述】:

我正在使用 Google Calendar API V3,在处理 Google 提供的时区时遇到了一些困难。 在日历的文档中:Calendars Overview

据说日历的时区是可选字段:

时区
字符串
日历的时区。 (格式化为 IANA 时区数据库 名称,例如“欧洲/苏黎世”。)可选。 但是,它在 CalendarList (https://developers.google.com/google-apps/calendar/v3/reference/calendarList) 中也是可选的。

如果在这两种情况下都没有指定时区,Google 会假设时区是什么?

【问题讨论】:

    标签: java google-api calendar google-calendar-api


    【解决方案1】:

    时区假定为日历本身中设置的时区。

    请求:

    获取https://www.googleapis.com/calendar/v3/calendars/primary

    回应

    {
     "kind": "calendar#calendar",
     "etag": "\"LOjlc76YTigzSZVQwSEE/E756z8zuickcYzaOnj8krCN4-Pk\"",
     "id": "xxxx@gmail.com",
     "summary": "xxx@gmail.com",
     "timeZone": "Europe/Copenhagen"
    }
    

    在不设置时区的情况下创建新日历

    {
     "kind": "calendar#calendar",
     "etag": "\"W8S50vTLOjlc76YTigzSZVQwSEE/cBQwQ2pDeiLoQ406eiNPZrDEINc\"",
     "id": "ddd5qep4g260mm7fgq8vtgp18@group.calendar.google.com",
     "summary": "testone",
     "timeZone": "UTC"
    }
    

    【讨论】:

    • 感谢您的回答。据说是可选的。如果未设置,Google 使用哪个时区? developers.google.com/google-apps/calendar/v3/reference/…
    • 新建日历时不设置怎么办?世界标准时间。创建事件时,其区域设置在日历本身中。你知道,如果你自己测试而不是问问题,它几乎会更快:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-27
    • 1970-01-01
    • 2015-02-13
    • 2020-06-03
    • 2018-12-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多