【问题标题】:Google-Calendar API - get offset of the default calendarGoogle-Calendar API - 获取默认日历的偏移量
【发布时间】:2018-11-24 06:46:23
【问题描述】:

我想根据日历的时区使用其 API 将开始时间设置为 14:00-15:00 在 Google 日历中创建一个事件。在此reference 之后,我可以创建约会,但我必须传递根据RFC3339 格式化的日期时间。它要求知道日历时区的偏移量。

因此,按照这个reference,我得到了默认日历实例,但它的名称为timeZone,没有偏移量。

根据默认日历的时区,在14:00-15:00 的特定日期创建事件的方法是什么?

【问题讨论】:

    标签: google-calendar-api


    【解决方案1】:

    使用默认日历时区将使用Zulu timezone,这意味着它“与协调世界时 (UTC) 没有偏移”- +8 UTC 之类的东西。

    来自Events: insert Try-it的示例:

    {
      "end": {
        "dateTime": "2018-06-15T15:00:00Z"
      },
      "start": {
        "dateTime": "2018-06-15T14:00:00Z"   
      },
      "description": "test"
    }
    

    但如果反过来,您想使用特定时区,请删除 Z 并添加 timeZone 属性

     {
          "end": {
            "dateTime": "2018-06-15T15:00:00",
            "timeZone": "Singapore"
          },
          "start": {
            "dateTime": "2018-06-15T14:00:00",
            "timeZone": "Singapore"
          },
          "description": "Singapore"
        }
    

    希望这个小样本有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多