Last active
August 29, 2015 14:00
-
-
Save OddBloke/11369094 to your computer and use it in GitHub Desktop.
Test of iCalendar UIDs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from datetime import date | |
from icalendar import Calendar, Event, vCalAddress, vText | |
def add_person(event): | |
person = vCalAddress('http://foo.bar.com/blah/') | |
person.params['cn'] = vText('Our Example Person') | |
event.add('attendee', person) | |
def add_event(cal, summary, start, end): | |
event = Event() | |
event.add('summary', summary) | |
event.add('dtstart', start) | |
event.add('dtend', end) | |
add_person(event) | |
cal.add_component(event) | |
def main(): | |
cal = Calendar() | |
# Important: end is non-inclusive: this is only a 2-day event | |
add_event(cal, 'Example event #1', date(2014, 5, 1), date(2014, 5, 3)) | |
add_event(cal, 'Example event #2', date(2014, 5, 7), date(2014, 5, 9)) | |
print cal.to_ical() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment