问题描述
我正在尝试确定日历在特定时间内是否可用.具体来说,当手动创建日历事件时,会有一个复选框,用于忙或免费:
I am trying to determine if a calendar has availability during a specific time. Specifically, when a calendar event is manually created, there's a checkbox for busy or free:
我想测试日历是否免费.我以为这是日历本身的属性,但是我没有在 Google日历类.(我一直在寻找类似于"isBusy"的属性).
I would like to test if the calendar is free or not. I assumed this would have been a property in the calendar itself, but I do not see one in the google calendar classes. (I was looking for some property along the lines of 'isBusy').
我的下一步是测试在请求的时间是否有事件,如果有,我再也没有看到测试事件设置是否忙的方法.有谁知道该怎么做?
My next step would be to test if there are events at the requested time, and if there are, I again don't see a method to test if an event's setting is busy or not. Does anyone know how to do this?
这就是我所拥有的:
function getAvailability(startTime,EndTime){
var myCalendar = CalendarApp.getDefaultCalendar();
//sample date to test availability
var aDate = new Date(2020,3,19);
var dayEvents = myCalendar.getEventsForDay(aDate);
//specific event captured:
var myEvent = dayEvents[0];
Logger.log(myEvent.getDescription());
//here is where I don't know what to do.
//How can I return if during this event's time if calendar is free?
}
推荐答案
您需要使用FreeBusy对象检查此详细信息.
You need to use the FreeBusy object to check this detail.
这可以通过创建类似于以下内容的查询来完成:
This can be done by creating a query similar to:
var check = {
items: [{id: calendarId, busy: 'Active'}],
timeMax: "2014-09-09T21:00:31-00:00",
timeMin: "2014-09-09T17:00:31-00:00"
};
并使用查询:
var response = Calendar.Freebusy.query(check);
以获取您要求检查的详细信息.
to get the details you have asked to check.
有关FreeBusy的API文档可在以下位置找到: https://developers.google.com/calendar/v3/reference/freebusy
API Documentation for FreeBusy can be found here: https://developers.google.com/calendar/v3/reference/freebusy
这篇关于如果Google日历时间或日历事件繁忙,该如何返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!