使用谷歌日历 api 查找空闲时间 [英] Find free time with google calendar api

查看:23
本文介绍了使用谷歌日历 api 查找空闲时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查一下 Google 日历上的某个时间间隔内是否有空闲时间(没有活动).有一个 freebusy Google API,但它返回一个带日期的事件数组.

I want to check if there is a free time (without events) in some interval of time on Google Calendar. There is a freebusy Google API, but it returns an array of events with dates.

"busy": [
    {
         "start": "2015-10-08T16:00:00+02:00",
         "end": "2015-10-08T20:00:00+02:00"
    },
    {
        "start": "2015-10-09T15:00:00+02:00",
        "end": "2015-10-09T16:00:00+02:00"
    },
]

是否有任何简单的方法可以获取有关空闲时间的真/假"信息(google api 的某些功能)?如果没有,也许您知道一些简单的方法可以通过忙"数组手动迭代并检查事件之间是否有一些空白空间.

Is there any simple way to get 'true/false' information about free time (some feature to google api)? If no, maybe you know some easy way to manually iterate by "busy" array and check if there is some empty space between events.

推荐答案

Freebusy.query 支持 timeMintimeMax 值.设置这两个值以包含您感兴趣的时间段,如果响应在该时间段内返回零个事件,您就有空闲时间的答案.

Freebusy.query supports timeMin and timeMax values. Set those two values to encompass the timeslot you are interested in and if the response returns zero events in that timeslot you have the answer of free time.

{
  "timeMin": datetime,
  "timeMax": datetime,
}

这篇关于使用谷歌日历 api 查找空闲时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆