如何仅从Google Calendar API获得空闲时间?

时间:2020-06-01 14:34:10

标签: google-calendar-api

我在API中仅找到忙忙碌碌的方法,并且它仅返回事件的开始和结束。但是除了工作时间外,我只需要一个工作日的空闲时间,我该如何安排呢?(例如,从10:00 am到3pm,从4pm到6pm,从8pm到9pm)。

总而言之,我有这个

# start = f0
# close = s0
# times = [f0,s1,f1,s2,f2,s3,f3,s0]
# empty = []
def time_generation(times):
    empty = []
    i = 0
    while i < len(times):
        if times[i+1] == times[i]:
            i+=2
            continue
        else:
            empty.append(times[i])
            empty.append(times[i+1])
            i+=2
            continue
    return empty

总而言之,我有这个

# start = f0
# close = s0
# times = [f0,s1,f1,s2,f2,s3,f3,s0]
# empty = []
def time_generation(times):
    empty = []
    i = 0
    while i < len(times):
        if times[i+1] == times[i]:
            i+=2
            continue
        else:
            empty.append(times[i])
            empty.append(times[i+1])
            i+=2
            continue
    return empty

0 个答案:

没有答案
相关问题