开发者

Google Calendar Python API: Create event with specified start and end timezones

开发者 https://www.devze.com 2023-03-06 01:42 出处:网络
Say I got the following start and end times for an event I want to create: import pytz import datetime start_zone = pytz.timezone(\'Europe/L开发者_JAVA技巧ondon\')

Say I got the following start and end times for an event I want to create:

import pytz
import datetime

start_zone = pytz.timezone('Europe/L开发者_JAVA技巧ondon')
end_zone = pytz.timezone('Europe/Oslo')

start_time = datetime.datetime(2011,5,13,15,0, tzinfo=start_zone)
end_time = datetime.datetime(2011,5,13,19,0, tzinfo=end_zone)

Can I create an event with the start and end times in the respective timezones?

In the Google Calendar web GUI this is possible by pressing Time Zone -> separate start/end time zones on the edit event page. When I try this code however,

event = gdata.calendar.CalendarEventEntry()
event.when.append(gdata.calendar.When(start_time=start_time.isoformat(), end_time=end_time.isoformat()))

no timezone information is added even though start_time.isoformat() contains information about the timezone.

EDIT: Forgot to add that the event is created from 16:00 to 19:00 in a calendar set to GMT+0 (London).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号