Skip to content

Instantly share code, notes, and snippets.

@OddBloke
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OddBloke/11369094 to your computer and use it in GitHub Desktop.
Save OddBloke/11369094 to your computer and use it in GitHub Desktop.
Test of iCalendar UIDs
#!/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