1.10. ics

This module provides functionality for creating RFC 5545 compliant iCalendar invite files.

1.10.1. Data

DAY_ABBREVIATIONS[source]

The abbreviations of day names for use in icalendar.vRecur instances.

zoneinfo_path[source]

The path to the directory which holds the IANA timezone data files.

1.10.2. Functions

get_timedelta_for_offset(offset)[source]

Take a POSIX environment variable style offset from UTC and convert it into a timedelta instance suitable for use with the icalendar.

Parameters:offset (str) – The offset from UTC such as “-5:00”
Returns:The parsed offset.
Return type:datetime.timedelta
get_tz_posix_env_var(tz_name)[source]

Get the timezone information in the POSIX TZ environment variable format from the IANA timezone data files included in the pytz package.

Parameters:tz_name (str) – The name of the timezone to get the environment variable for such as “America/New_York”.
Returns:The TZ environment variable string, if it is specified in the timezone data file.
Return type:str
parse_tz_posix_env_var(posix_env_var)[source]

Get the details regarding a timezone by parsing the POSIX style TZ environment variable.

Parameters:posix_env_var (str) – The POSIX style TZ environment variable.
Returns:The parsed TZ environment variable.
Return type:TimezoneOffsetDetails

1.10.3. Classes

class Calendar(organizer_email, start, summary, organizer_cn=None, description=None, duration='1h', location=None)[source]

Bases: icalendar.cal.Calendar

An icalendar formatted event for converting to an ICS file and then sending in an email.

__init__(organizer_email, start, summary, organizer_cn=None, description=None, duration='1h', location=None)[source]
Parameters:
  • organizer_email (str) – The email of the event organizer.
  • start (datetime.datetime) – The start time for the event.
  • summary (str) – A short summary of the event.
  • organizer_cn (str) – The name of the event organizer.
  • description (str) – A more complete description of the event than what is provided by the summary parameter.
  • duration (int, str, timedelta, DurationAllDay) – The events scheduled duration.
  • location (str) – The location for the event.
add_attendee(email, cn=None, rsvp=True)[source]

Add an attendee to the event. If the event is being sent via an email, the recipient should be added as an attendee.

Parameters:
  • email (str) – The attendee’s email address.
  • cn (str) – The attendee’s common name.
  • rsvp (bool) – Whether or not to request an RSVP response from the attendee.
to_ical(encoding='utf-8', **kwargs)[source]

Convert the calendar object to a string in the iCalendar format.

Returns:The string representation of the data.
Return type:str
class DurationAllDay(days=1)[source]

Bases: object

A representation of a duration that can be used for an event to indicate that it takes place all day.

__init__(days=1)[source]

Initialize self. See help(type(self)) for accurate signature.

class Timezone(tz_name=None)[source]

Bases: icalendar.cal.Timezone

An icalendar formatted timezone with all properties populated for the specified zone.

__init__(tz_name=None)[source]
Parameters:tz_name (str) – The timezone to represent, if not specified it defaults to the local timezone.
class TimezoneOffsetDetails(offset, offset_dst, dst_start, dst_end)[source]

Bases: tuple

A named tuple describing the details of a timezone’s UTC offset and DST occurrence.

dst_end[source]

Alias for field number 3

dst_start[source]

Alias for field number 2

offset[source]

Alias for field number 0

offset_dst[source]

Alias for field number 1