diff --git a/CHANGES.rst b/CHANGES.rst index 72b7a4e..e18464e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,7 @@ Minor changes: - Add funding information - Update windows to olson conversion for Greenland Standard Time +- Extend examples in Usage with alarm and recurrence Breaking changes: diff --git a/docs/credits.rst b/docs/credits.rst index e3f8c54..6076c05 100644 --- a/docs/credits.rst +++ b/docs/credits.rst @@ -72,6 +72,7 @@ icalendar contributors - `NikEasY `_ - Matt Lewis - Felix Stupp +- Bastian Wegge Find out who contributed:: diff --git a/docs/usage.rst b/docs/usage.rst index 7d7aa0c..919d9f0 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -309,18 +309,38 @@ Add the event to the calendar:: >>> cal.add_component(event) +By extending the event with subcomponents, you can create multiple alarms:: + + >>> from icalendar import Alarm + >>> from datetime import timedelta + >>> alarm_1h_before = Alarm() + >>> alarm_1h_before.add('action', 'DISPLAY') + >>> alarm_1h_before.add('trigger', timedelta(hours=-1)) + >>> alarm_1h_before.add('description', 'Reminder: Event in 1 hour') + >>> event.add_component(alarm_1h_before) + + >>> alarm_24h_before = Alarm() + >>> alarm_24h_before.add('action', 'DISPLAY') + >>> alarm_24h_before.add('trigger', timedelta(hours=-24)) + >>> alarm_24h_before.add('description', 'Reminder: Event in 24 hours') + >>> event.add_component(alarm_24h_before) + +Or even recurrence:: + + >>> event.add('rrule', {'freq': 'daily'}) + Write to disk:: >>> import tempfile, os >>> directory = tempfile.mkdtemp() >>> f = open(os.path.join(directory, 'example.ics'), 'wb') >>> f.write(cal.to_ical()) - 522 + 733 >>> f.close() Print out the calendar:: - >>> print(cal.to_ical().decode("utf-8")) # doctest: +NORMALIZE_WHITESPACE + >>> print(cal.to_ical().decode('utf-8')) # doctest: +NORMALIZE_WHITESPACE BEGIN:VCALENDAR VERSION:2.0 PRODID:-//My calendar product//mxm.dk// @@ -330,11 +350,22 @@ Print out the calendar:: DTEND:20050404T100000Z DTSTAMP:20050404T001000Z UID:20050115T101010/27346262376@mxm.dk + RRULE:FREQ=DAILY ATTENDEE;CN="Max Rasmussen";ROLE=REQ-PARTICIPANT:MAILTO:maxm@example.com ATTENDEE;CN="The Dude";ROLE=REQ-PARTICIPANT:MAILTO:the-dude@example.com LOCATION:Odense\, Denmark ORGANIZER;CN="Max Rasmussen";ROLE=CHAIR:MAILTO:noone@example.com PRIORITY:5 + BEGIN:VALARM + ACTION:DISPLAY + DESCRIPTION:Reminder: Event in 1 hour + TRIGGER:-PT1H + END:VALARM + BEGIN:VALARM + ACTION:DISPLAY + DESCRIPTION:Reminder: Event in 24 hours + TRIGGER:-P1D + END:VALARM END:VEVENT END:VCALENDAR