如何从Google Calendar API获取当前事件? [英] How to get current events from google calendar API?
问题描述
我正在尝试使用Google Calendar API方法 gapi.client.calendar.events.list 检索日历 now 上的事件.
I'm trying to use the Google Calendar API method gapi.client.calendar.events.list to retrieve events on the calendar now.
我可以成功过滤开始日期和结束日期.但是,如果某个事件是昨天开始并且仍在进行中,那么对今天开始的事情进行过滤并不会对我有帮助.
I can successfully filter on start date and end date. But, filtering on things that start today doesn't help me if an event started yesterday and is still on-going.
var request = gapi.client.calendar.events.list({
'calendarId': 'my calendar id',
// shows things that have not yet started
'timeMin': (new Date()).toISOString(),
'showDeleted': false,
'singleEvents': true,
'orderBy': 'startTime'
});
如何找到日历上当前正在进行的事情的列表?
How do I find the list of things on a calendar that are currently going on?
(显然)我想避免拉动一周的活动并对其进行解析.
I'd (obviously) like to avoid pulling a week's worth of events and parsing through it.
推荐答案
没有直接查询当前事件的方法,但是您可以给它指定最小和最大时间,因此您只能少量事件可供搜索.如果您的活动是有规律的并且持续时间可预测,那么您可以做到这一点.
There isn't a way of querying for the current event directly, but you can certainly give it a limited min and max time, so you'll only have a small number of events to search through. If your events are regular and of predictable duration, you may be able to make it just give you one.
events = client.events().list(calendarId='primary',
timeMin='2011-12-22T09:00:00Z',
timeMax='2011-12-22T22:00:00Z').execute()
有关更多信息,请阅读Google Calendar API的官方文档: https://developers.google.com/google-apps/calendar/?csw=1
For more information, please read the Official Documentation of Google Calendar API: https://developers.google.com/google-apps/calendar/?csw=1
这篇关于如何从Google Calendar API获取当前事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!