s365b.modules.exchange.ics

iCalendar (.ics) export of backed-up events and tasks.

Events become VEVENT and tasks VTODO components (RFC 5545), which Outlook, Apple Calendar, Google Calendar and Thunderbird import.

Graph stores times in UTC (Prefer: outlook.timezone is not sent), with the zone the organizer used (originalStartTimeZone, usually a Windows name such as “Pacific Standard Time”). Times are written in that zone, as an IANA name with its VTIMEZONE, so a weekly 09:00 meeting stays at 09:00 across daylight saving time. All-day events and due dates are plain dates.

Not in the export: single occurrences of a recurring meeting that were changed or cancelled (Graph’s backup has the series only), attachments, and To Do checklist steps as separate items (they are listed in the description).

Attributes

Functions

zone(name) → zoneinfo.ZoneInfo

The IANA zone for a Graph time zone name (Windows or IANA); UTC if unknown.

rrule(recurrence, start) → dict[str, Any] | None

A Graph patternedRecurrence as an iCalendar RRULE.

event_component(event) → icalendar.Event

A backed-up event as a VEVENT.

task_component(task) → icalendar.Todo

A backed-up To Do task as a VTODO.

to_ics(items[, name]) → bytes

Events and tasks as one iCalendar file.

Module Contents

s365b.modules.exchange.ics.PRODID = '-//Mail Safehouse//Backup export//EN'[source]
s365b.modules.exchange.ics.DAYS[source]
s365b.modules.exchange.ics.POSITION[source]
s365b.modules.exchange.ics.PARTSTAT[source]
s365b.modules.exchange.ics.ROLE[source]
s365b.modules.exchange.ics.TODO_STATUS[source]
s365b.modules.exchange.ics.PRIORITY[source]
s365b.modules.exchange.ics.zone(name: str | None) → zoneinfo.ZoneInfo[source]

The IANA zone for a Graph time zone name (Windows or IANA); UTC if unknown.

Parameters:

name – E.g. “Pacific Standard Time” or “Europe/Paris”.

Returns:

The zone.

s365b.modules.exchange.ics.rrule(recurrence: dict[str, Any] | None, start: datetime.datetime | datetime.date) → dict[str, Any] | None[source]

A Graph patternedRecurrence as an iCalendar RRULE.

Parameters:
  • recurrence – The recurrence from Graph.

  • start – The first occurrence (a date for all-day events and tasks).

Returns:

The rule’s parts, or None if there is no (supported) recurrence.

s365b.modules.exchange.ics.event_component(event: dict[str, Any]) → icalendar.Event[source]

A backed-up event as a VEVENT.

Parameters:

event – The event as Graph returned it.

Returns:

The component.

s365b.modules.exchange.ics.task_component(task: dict[str, Any]) → icalendar.Todo[source]

A backed-up To Do task as a VTODO.

Parameters:

task – The task as Graph returned it (with checklistItems if any).

Returns:

The component.

s365b.modules.exchange.ics.to_ics(items: list[tuple[str, dict[str, Any]]], name: str | None = None) → bytes[source]

Events and tasks as one iCalendar file.

Parameters:
  • items – (item type, Graph JSON) pairs; types other than event and task are left out.

  • name – Calendar name shown by some programs (e.g. the calendar’s).

Returns:

The .ics file.