ical_date_utility.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:lagendacommun 作者: ecreall 项目源码 文件源码
def generate_ical_rec(event, schedule, start_date,
                      end_date, to_exclude=[], tzinfo=pytz.UTC):
    ical_events = []
    periods = list_date_to_dates(start_date, True, tzinfo)[1]
    end_dates = list_date_to_dates(end_date, True, tzinfo)[1]
    until = end_dates[-1]['end']
    exdate = [datetime.datetime(l[0], l[1], l[2], tzinfo=tzinfo)
              for l in to_exclude]
    for index, period in enumerate(periods):
        ical_event = Event()
        ical_event.add('summary', event.title)
        ical_event.add('dtstart', period['start'])
        ical_event.add('dtend', period['end'])
        ical_event.add('rrule', {'freq': 'daily', 'until': until})
        if exdate:
            ical_event.add('exdate', exdate)

        ical_event['uid'] = str(get_oid(schedule)) + str(index) + '/' + 'lac.org'
        ical_events.append(ical_event)

    return ical_events
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号