google日历python API库忽略timeMin
我正试图通过Google calendar API v3(python库)获取日历事件 问题是它忽略了我对timeMax和timeMin的查询: 代码段:google日历python API库忽略timeMin,python,google-calendar-api,google-api-python-client,Python,Google Calendar Api,Google Api Python Client,我正试图通过Google calendar API v3(python库)获取日历事件 问题是它忽略了我对timeMax和timeMin的查询: 代码段: service = gcal.service first = datetime.datetime.now(pytz.timezone('Europe/Paris')).replace(microsecond=0) last = first + datetime.timedelta(hours=4) sfirst = first.isoform
service = gcal.service
first = datetime.datetime.now(pytz.timezone('Europe/Paris')).replace(microsecond=0)
last = first + datetime.timedelta(hours=4)
sfirst = first.isoformat()
slast = last.isoformat()
events = service.events().list(
calendarId='primary', timeMax=slast, timeMin=sfirst, maxResults=10,
singleEvents=True,
orderBy='startTime'
).execute()
print("First: {}".format(sfirst))
print("Last: {}".format(slast))
for i in events['items']:
print (i['start'])
输出:
First: 2016-09-14T16:46:44+02:00
Last: 2016-09-14T20:46:44+02:00
{'date': '2016-09-14'}
{'dateTime': '2016-09-14T13:30:00+02:00'}
如您所见,第二个事件的开始时间超出了查询的边界
我在stackoverflow上看到了类似的问题(在其他lanugages中),但仍然不知道到底出了什么问题。
似乎遵循文档,使用时区等,甚至删除微秒
欢迎任何意见 查看,您的dateformat似乎没有使用utcnow()。你能试着用日期格式吗?我只是按照上面写的。时区在那里,UTC只是一个特殊情况。顺便说一句,我最后做的只是过滤掉代码中具有“错误”开始时间的结果项,但这不是它应该如何工作……我看到了相同的行为。在“Try this API”面板中,一切都很好,但是通过
google API python client
程序包调用似乎不尊重timeMin。看看,您的dateformat似乎没有使用utcnow()。你能试着用日期格式吗?我只是按照上面写的。时区在那里,UTC只是一个特殊情况。顺便说一句,我最后做的只是过滤掉代码中具有“错误”开始时间的结果项,但这不是它应该如何工作……我看到了相同的行为。在“trythisapi”面板中,一切都很好,但是通过googleapi python客户端调用
包似乎并不尊重timeMin。