API

Calendar

class ics.icalendar.Calendar(imports=None, events=None, todos=None, creator=None)[source]

Represents an unique rfc5545 iCalendar.

__eq__(other)[source]

x.__eq__(y) <==> x==y

__init__(imports=None, events=None, todos=None, creator=None)[source]

Instantiates a new Calendar.

Parameters:
  • imports (string or list of lines/strings) – data to be imported into the Calendar(),
  • events (list of Event) – :class:`ics.event.Event`s to be added to the calendar
  • todos (list of Todo) – :class:`ics.event.Todo`s to be added to the calendar
  • creator (string) – uid of the creator program.

If imports is specified, every other argument will be ignored.

__iter__()[source]

Returns: iterable: an iterable version of __str__, line per line (with line-endings).

Example

Can be used to write calendar to a file:

>>> c = Calendar(); c.append(Event(name="My cool event"))
>>> open('my.ics', 'w').writelines(c)
__ne__(other)[source]

x.__ne__(y) <==> x!=y

__urepr__()[source]
Returns:representation (__repr__) of the calendar.
Return type:unicode

Should not be used directly. Use self.__repr__ instead.

clone()[source]
Returns:an exact deep copy of self
Return type:Calendar
creator

Get or set the calendar’s creator.

Will return a string.
May be set to a string.
Creator is the PRODID iCalendar property.
It uniquely identifies the program that created the calendar.

Event

class ics.event.Event(name=None, begin=None, end=None, duration=None, uid=None, description=None, created=None, location=None, url=None, transparent=False, alarms=None, categories=None)[source]

A calendar event.

Can be full-day or between two instants. Can be defined by a beginning instant and a duration or end instant.

__and__(other, *args, **kwarg)

Create a new event which covers the time range of two intersecting events

All extra parameters are passed to the Event constructor.

Parameters:other – the other event
Returns:a new Event instance
__eq__(other)[source]

Two events are considered equal if they have the same uid.

__ge__(other)[source]

x.__ge__(y) <==> x>=y

__gt__(other)[source]

x.__gt__(y) <==> x>y

__hash__()[source]
Returns:hash of self. Based on self.uid.
Return type:int
__init__(name=None, begin=None, end=None, duration=None, uid=None, description=None, created=None, location=None, url=None, transparent=False, alarms=None, categories=None)[source]

Instantiates a new ics.event.Event.

Parameters:
  • name (string) – rfc5545 SUMMARY property
  • begin (Arrow-compatible) –
  • end (Arrow-compatible) –
  • duration (datetime.timedelta) –
  • uid (string) – must be unique
  • description (string) –
  • created (Arrow-compatible) –
  • location (string) –
  • url (string) –
  • transparent (Boolean) –

:param alarms (ics.alarm.Alarm: :param categories: :type categories: set of string

Raises:ValueError – if end and duration are specified at the same time
__le__(other)[source]

x.__le__(y) <==> x<=y

__lt__(other)[source]

x.__lt__(y) <==> x<y

__urepr__()[source]

Should not be used directly. Use self.__repr__ instead.

Returns:a unicode representation (__repr__) of the event.
Return type:unicode
clone()[source]
Returns:an exact copy of self
Return type:Event
has_end()[source]
Returns:self has an end
Return type:bool
join(other, *args, **kwarg)[source]

Create a new event which covers the time range of two intersecting events

All extra parameters are passed to the Event constructor.

Parameters:other – the other event
Returns:a new Event instance
make_all_day()[source]

Transforms self to an all-day event.

The event will span all the days from the begin to the end day.

all_day

**Return* – bool* – self is an all-day event

begin

Get or set the beginning of the event.

Will return an Arrow object.
May be set to anything that Arrow.get() understands.
If an end is defined (not a duration), .begin must not be set to a superior value.
duration

Get or set the duration of the event.

Will return a timedelta object.
May be set to anything that timedelta() understands.
May be set with a dict ({“days”:2, “hours”:6}).
If set to a non null value, removes any already existing end time.
end

Get or set the end of the event.

Will return an Arrow object.
May be set to anything that Arrow.get() understands.
If set to a non null value, removes any already existing duration.
Setting to None will have unexpected behavior if begin is not None.
Must not be set to an inferior value than self.begin.

Alarm

class ics.alarm.Alarm(trigger=None, repeat=None, duration=None)[source]

A calendar event VALARM base class

__eq__(other)[source]

Two alarms are considered equal if they have the same type and base values.

__extra_urepr__()[source]

Should not be used directly. Used with self.__repr__.

Returns:a unicode representation (__repr__) of the alarm.
Return type:unicode
__init__(trigger=None, repeat=None, duration=None)[source]

Instantiates a new ics.alarm.Alarm.

Adheres to RFC5545 VALARM standard: http://icalendar.org/iCalendar-RFC-5545/3-6-6-alarm-component.html

Parameters:
  • trigger (datetime.timedelta OR datetime.datetime) – Timespan to alert before parent action, or absolute time to alert
  • repeat (integer) – How many times to repeat the alarm
  • duration (datetime.timedelta) – Duration between repeats
Raises:

ValueError – If trigger, repeat, or duration do not match the RFC spec.

__ne__(other)[source]

x.__ne__(y) <==> x!=y

__urepr__()[source]

Should not be used directly. Use self.__repr__ instead.

Returns:a unicode representation (__repr__) of the alarm.
Return type:unicode
clone()[source]
Returns:an exact copy of self
Return type:Alarm
action

VALARM action to be implemented by concrete classes

duration

Duration between alarm repeats

Returns a timedelta object
Timespan must return positive total_seconds() value
repeat

Number of times to repeat alarm

Returns an integer for number of alarm repeats
Value must be >= 0
trigger

The trigger condition for the alarm

Returns either a timedelta or datetime object
Timedelta must have positive total_seconds()
Datetime object is also allowed.

DisplayAlarm

class ics.alarm.DisplayAlarm(description=None, **kwargs)[source]

A calendar event VALARM with DISPLAY option.

__extra_urepr__()[source]

Should not be used directly. Used with self.__repr__.

Returns:a unicode representation (__repr__) of the alarm.
Return type:unicode
__init__(description=None, **kwargs)[source]

Instantiates a new ics.alarm.DisplayAlarm.

Adheres to RFC5545 VALARM standard: http://icalendar.org/iCalendar-RFC-5545/3-6-6-alarm-component.html

Parameters:

AudioAlarm

class ics.alarm.AudioAlarm(attach=None, attach_params=None, **kwargs)[source]

A calendar event VALARM with AUDIO option.

__extra_urepr__()[source]

Should not be used directly. Used with self.__repr__.

Returns:a unicode representation (__repr__) of the alarm.
Return type:unicode
__init__(attach=None, attach_params=None, **kwargs)[source]

Instantiates a new ics.alarm.AudioAlarm.

Adheres to RFC5545 VALARM standard: http://icalendar.org/iCalendar-RFC-5545/3-6-6-alarm-component.html

Parameters:
  • attach (string) – RFC5545 ATTACH property, pointing to an audio object
  • attach_params (dict) – RFC5545 attachparam values
  • kwargs (dict) – Args to ics.alarm.Alarm.__init__()

Timeline

class ics.timeline.Timeline(calendar)[source]
__init__(calendar)[source]

Instanciates a new Timeline. (You should not have to instanciate a new timeline by yourself)

Parameters:calendarics.icalendar.Calendar
__iter__()[source]

Iterates on every event from the ics.icalendar.Calendar in chronological order

Note :
  • chronological order is defined by the comparaison operators in ics.event.Event
  • Events with no begin will not appear here. (To list all events in a Calendar use Calendar.events)
at(instant)[source]

Iterates (in chronological order) over all events that are occuring during instant.

Parameters:instant (Arrow object) –
included(start, stop)[source]

Iterates (in chronological order) over every event that is included in the timespan between start and stop

Parameters:
  • start – (Arrow object)
  • stop – (Arrow object)
now()[source]

Iterates (in chronological order) over all events that occurs now

on(day, strict=False)[source]

Iterates (in chronological order) over all events that occurs on day

Parameters:
  • day (Arrow object) –
  • strict (bool) – if True events will be returned only if they are strictly included in day.
overlapping(start, stop)[source]

Iterates (in chronological order) over every event that has an intersection with the timespan between start and stop

Parameters:
  • start – (Arrow object)
  • stop – (Arrow object)
start_after(instant)[source]

Iterates (in chronological order) on every event from the ics.icalendar.Calendar in chronological order. The first event of the iteration has a starting date greater (later) than instant

Parameters:instant – (Arrow object) starting point of the iteration
today(strict=False)[source]

Iterates (in chronological order) over all events that occurs today

Parameters:strict (bool) – if True events will be returned only if they are strictly included in day.
__weakref__

list of weak references to the object (if defined)