2013-10-30 138 views
0

當我創建的日曆與谷歌日曆API(Python)的,我將其添加到該請求消息中設置時區到:如何在使用Google Calendar API時設置時區的「國家/地區」字段?

calendar = { 
     'summary': 'My Title', 
     'description': 'My Description', 
     'timeZone': 'China/Shanghai' 
    } 
    gService = build('calendar', 'v3', http=self.http, developerKey='XXXXXXXX') 
    gService.calendars().insert(body=calendar).execute() 

所創建的日曆得到了正確的時區。這部分是好的。但是當我查看日曆設置http://calendar.google.com時,TimeZone配置中的國家/地區字段始終爲「美國」,即使所選時區爲「中國時間 - 北京」。

有什麼方法可以糾正這種行爲嗎?

回答

0

看起來你應該添加一行寫着

'location': 'China', 

'description': 'My Description', 
'timeZone': 'China/Shanghai' 

之間 我立足這一關一般API v3 documentation

+0

這似乎不正確。位置字段完全不影響TimeZone - Country字段。實際上,您可以將任何文本放入此字段,而Google根本不會解析它。謝謝! –

0

可能是因爲中國只有一個時區,谷歌不支持中國城市的這種標記。他們也沒有日光節約,所以你不必擔心這一點。

我會嘗試與上海的座標設定

'timeZone': 'China/Shanghai' 

"timeZone" : "China Standard Time" 

我從谷歌時區API(https://developers.google.com/maps/documentation/timezone/)輸出立足這樣的:

https://maps.googleapis.com/maps/api/timezone/json?location=31.224546,121.401215&timestamp=1331161200&sensor=false

它給出了輸出:

{ 
    "dstOffset" : 0, 
    "rawOffset" : 28800, 
    "status" : "OK", 
    "timeZoneId" : "Asia/Chongqing", 
    "timeZoneName" : "China Standard Time" 
} 
+0

這不起作用。可以通過https://developers.google.com/google-apps/calendar/v3/reference/calendars/insert輕鬆進行測試 –

相關問題