Why does Google API set +01 offset no matter input?

…衆ロ難τιáo~ 提交于 2019-12-11 07:05:23

问题


I'm using Google's API Explorer for their Calendar API on this page.

I am inserting an event { "end": { "dateTime": "2016-10-31T06:30:00Z" }, "start": { "dateTime": "2016-10-31T06:00:00Z" } } and have tried the following datetime formats:

2016-10-31T06:00:00Z
2016-10-31T06:00:00-00:00
2016-10-31T06:00:00+00:00

But no matter input format, Google chooses to add an hour when setting the datetime. The response is always:

"start": {
 "dateTime": "2016-10-31T07:00:00+01:00"
}

I'm currently in Stockholm, which has +2 hours offset. I've tried both setting the separate time_zone field and omitting the separate time_zone field.

Why is this happening? And, is there any "right way" or do I simply need to take this added hour into account when setting time?


回答1:


I suggest to use the timeZone property to specify the time zone properly.

Sample request using the "timeZone":"Europe/Stockholm":

{
 "end": {
  "dateTime": "2016-10-31T06:30:00",
  "timeZone": "Europe/Stockholm"
 },
 "start": {
  "dateTime": "2016-10-31T06:00:00",
  "timeZone": "Europe/Stockholm"
 }
}


来源:https://stackoverflow.com/questions/40213713/why-does-google-api-set-01-offset-no-matter-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!