kopia lustrzana https://github.com/collective/icalendar
Merge pull request #613 from bastianwegge/add_alarms_and_recurrence_examples
Extend the existing example with alarms and recurrence-rulepull/615/head
commit
798ee4aa62
|
@ -8,6 +8,7 @@ Minor changes:
|
||||||
|
|
||||||
- Add funding information
|
- Add funding information
|
||||||
- Update windows to olson conversion for Greenland Standard Time
|
- Update windows to olson conversion for Greenland Standard Time
|
||||||
|
- Extend examples in Usage with alarm and recurrence
|
||||||
|
|
||||||
Breaking changes:
|
Breaking changes:
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ icalendar contributors
|
||||||
- `NikEasY <https://github.com/NikEasY>`_
|
- `NikEasY <https://github.com/NikEasY>`_
|
||||||
- Matt Lewis <git@semiprime.com>
|
- Matt Lewis <git@semiprime.com>
|
||||||
- Felix Stupp <felix.stupp@banananet.work>
|
- Felix Stupp <felix.stupp@banananet.work>
|
||||||
|
- Bastian Wegge <wegge@crossbow.de>
|
||||||
|
|
||||||
Find out who contributed::
|
Find out who contributed::
|
||||||
|
|
||||||
|
|
|
@ -309,18 +309,38 @@ Add the event to the calendar::
|
||||||
|
|
||||||
>>> cal.add_component(event)
|
>>> 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::
|
Write to disk::
|
||||||
|
|
||||||
>>> import tempfile, os
|
>>> import tempfile, os
|
||||||
>>> directory = tempfile.mkdtemp()
|
>>> directory = tempfile.mkdtemp()
|
||||||
>>> f = open(os.path.join(directory, 'example.ics'), 'wb')
|
>>> f = open(os.path.join(directory, 'example.ics'), 'wb')
|
||||||
>>> f.write(cal.to_ical())
|
>>> f.write(cal.to_ical())
|
||||||
522
|
733
|
||||||
>>> f.close()
|
>>> f.close()
|
||||||
|
|
||||||
Print out the calendar::
|
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
|
BEGIN:VCALENDAR
|
||||||
VERSION:2.0
|
VERSION:2.0
|
||||||
PRODID:-//My calendar product//mxm.dk//
|
PRODID:-//My calendar product//mxm.dk//
|
||||||
|
@ -330,11 +350,22 @@ Print out the calendar::
|
||||||
DTEND:20050404T100000Z
|
DTEND:20050404T100000Z
|
||||||
DTSTAMP:20050404T001000Z
|
DTSTAMP:20050404T001000Z
|
||||||
UID:20050115T101010/27346262376@mxm.dk
|
UID:20050115T101010/27346262376@mxm.dk
|
||||||
|
RRULE:FREQ=DAILY
|
||||||
ATTENDEE;CN="Max Rasmussen";ROLE=REQ-PARTICIPANT:MAILTO:maxm@example.com
|
ATTENDEE;CN="Max Rasmussen";ROLE=REQ-PARTICIPANT:MAILTO:maxm@example.com
|
||||||
ATTENDEE;CN="The Dude";ROLE=REQ-PARTICIPANT:MAILTO:the-dude@example.com
|
ATTENDEE;CN="The Dude";ROLE=REQ-PARTICIPANT:MAILTO:the-dude@example.com
|
||||||
LOCATION:Odense\, Denmark
|
LOCATION:Odense\, Denmark
|
||||||
ORGANIZER;CN="Max Rasmussen";ROLE=CHAIR:MAILTO:noone@example.com
|
ORGANIZER;CN="Max Rasmussen";ROLE=CHAIR:MAILTO:noone@example.com
|
||||||
PRIORITY:5
|
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:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
<BLANKLINE>
|
<BLANKLINE>
|
||||||
|
|
Ładowanie…
Reference in New Issue