我正在创建dict obj,并将其发送到googlecalendar,就像google在API文档上的示例一样。我读取了一个mssql数据库,然后生成了一个csv结果文件。然后我使用cdv信息来编写事件。在
我的代码片段。在
def count_leaveduration(sdate, fdate):
try:
date_format = "%Y.%m.%d"
cmp_sdate = datetime.strptime(sdate, date_format)
cmp_fdate = datetime.strptime(fdate, date_format)
delta = cmp_fdate - cmp_sdate
return delta.days, cmp_sdate, cmp_fdate
except Exception as e:
input_logging('error', 'Cannot Count Leave Duration - Exception: %s' % e)
duration, sdate, fdate = count_leaveduration(line['FIRSTDAYOFABSENCE'], line['LASTDAYOFABSENCE'])
event['summary'] = '%s - Leave' % line['NAME1']
event['location'] = 'Out Of Office'
# date type here instead because all day event for duration.
event['start'] = {'date': '%s' % sdate.strftime('%Y-%m-%d')}
event['end'] = {'date': '%s' % fdate.strftime('%Y-%m-%d')}
event['attendees'] = [{'email': line['ELECTRONICMAILADDRESS']}]
appbuildobj.events().insert(calendarId=robj, body=event).execute()
一般来说,条目工作正常,但是如果持续时间超过一天,那么即使日期应该是提交给日历事件dict的完成日期,它似乎也会将日历条目缩短一天这:在
^{pr2}$不过,我想知道是否有人知道发生这种事的原因?在
它藏起来了,但我找到了:
https://developers.google.com/google-apps/calendar/concepts
这样的活动从startDate开始,在endDay的前一天结束。例如,一天事件的开始日期应设置为天,结束日期应设置为天+1。在
所以我已经修好了有:在
相关问题 更多 >
编程相关推荐