icalendar 6.1.2
pip install icalendar
Released:
iCalendar parser/generator
Navigation
Verified details
These details have been verified by PyPIMaintainers
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: BSD License (License)
- Author: Plone Foundation
- Maintainer: Christian Geier
- Tags calendar, calendaring, event, ical, icalendar, journal, recurring, rfc5545, todo
- Requires: Python >=3.8
-
Provides-Extra:
test
Classifiers
- Development Status
- Intended Audience
- License
- Operating System
- Programming Language
Project description
The icalendar package is a RFC 5545 compatible parser/generator for iCalendar files.
- Homepage:
- Community Discussions:
- Issue Tracker:
- Code:
- Dependencies:
python-dateutil and tzdata.
- License:
Quick start guide
icalendar enables you to create, inspect and modify calendaring information with Python.
To install the package, run:
pip install icalendar
Inspect Files
You can open an .ics file and see all the events:
>>> import icalendar
>>> from pathlib import Path
>>> ics_path = Path("src/icalendar/tests/calendars/example.ics")
>>> calendar = icalendar.Calendar.from_ical(ics_path.read_bytes())
>>> for event in calendar.events:
... print(event.get("SUMMARY"))
New Year's Day
Orthodox Christmas
International Women's Day
Modify Content
Such a calendar can then be edited and saved again.
>>> calendar["X-WR-CALNAME"] = "My Modified Calendar" # modify
>>> print(calendar.to_ical()[:129]) # save modification
BEGIN:VCALENDAR
VERSION:2.0
PRODID:collective/icalendar
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:My Modified Calendar
Create Events, TODOs, Journals, Alarms, …
icalendar supports the creation and parsing of all kinds of objects in the iCalendar (RFC 5545) standard.
>>> icalendar.Event() # events
VEVENT({})
>>> icalendar.FreeBusy() # free/busy times
VFREEBUSY({})
>>> icalendar.Todo() # Todo list entries
VTODO({})
>>> icalendar.Alarm() # Alarms e.g. for events
VALARM({})
>>> icalendar.Journal() # Journal entries
VJOURNAL({})
Have a look at more examples.
Use timezones of your choice
With icalendar, you can localize your events to take place in different timezones. zoneinfo, dateutil.tz and pytz are compatible with icalendar. This example creates an event that uses all of the timezone implementations with the same result:
>>> import pytz, zoneinfo, dateutil.tz # timezone libraries
>>> import datetime, icalendar
>>> e = icalendar.Event()
>>> tz = dateutil.tz.tzstr("Europe/London")
>>> e["X-DT-DATEUTIL"] = icalendar.vDatetime(datetime.datetime(2024, 6, 19, 10, 1, tzinfo=tz))
>>> tz = pytz.timezone("Europe/London")
>>> e["X-DT-USE-PYTZ"] = icalendar.vDatetime(datetime.datetime(2024, 6, 19, 10, 1, tzinfo=tz))
>>> tz = zoneinfo.ZoneInfo("Europe/London")
>>> e["X-DT-ZONEINFO"] = icalendar.vDatetime(datetime.datetime(2024, 6, 19, 10, 1, tzinfo=tz))
>>> print(e.to_ical()) # the libraries yield the same result
BEGIN:VEVENT
X-DT-DATEUTIL;TZID=Europe/London:20240619T100100
X-DT-USE-PYTZ;TZID=Europe/London:20240619T100100
X-DT-ZONEINFO;TZID=Europe/London:20240619T100100
END:VEVENT
Version 6 with zoneinfo
Version 6 of icalendar switches the timezone implementation to zoneinfo. This only affects you if you parse icalendar objects with from_ical(). The functionality is extended and is tested since 6.0.0 with both timezone implementations pytz and zoneinfo.
By default and since 6.0.0, zoneinfo timezones are created.
>>> dt = icalendar.Calendar.example("timezoned").walk("VEVENT")[0]["DTSTART"].dt
>>> dt.tzinfo
ZoneInfo(key='Europe/Vienna')
If you would like to continue to receive pytz timezones in parse results, you can receive all the latest updates, and switch back to earlier behavior:
>>> icalendar.use_pytz()
>>> dt = icalendar.Calendar.example("timezoned").walk("VEVENT")[0]["DTSTART"].dt
>>> dt.tzinfo
<DstTzInfo 'Europe/Vienna' CET+1:00:00 STD>
Version 6 is on branch main. It is compatible with Python versions 3.8 - 3.13, and PyPy3. We expect the main branch with versions 6+ to receive the latest updates and features.
Related projects
icalevents. It is built on top of icalendar and allows you to query iCal files and get the events happening on specific dates. It manages recurrent events as well.
recurring-ical-events. Library to query an icalendar.Calendar object for events and other components happening at a certain date or within a certain time.
x-wr-timezone. Library and command line tool to make icalendar.Calendar objects and files from Google Calendar (using the non-standard X-WR-TIMEZONE property) compliant with the standard (RFC 5545).
ics-query. Command line tool to query iCalendar files for occurrences of events and other components.
icalendar-compatibility - access to event data compatible with RFC5545 and different implementations
Further Reading
You can find out more about this project:
Project details
Verified details
These details have been verified by PyPIMaintainers
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: BSD License (License)
- Author: Plone Foundation
- Maintainer: Christian Geier
- Tags calendar, calendaring, event, ical, icalendar, journal, recurring, rfc5545, todo
- Requires: Python >=3.8
-
Provides-Extra:
test
Classifiers
- Development Status
- Intended Audience
- License
- Operating System
- Programming Language
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file icalendar-6.1.2.tar.gz
.
File metadata
- Download URL: icalendar-6.1.2.tar.gz
- Upload date:
- Size: 151.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 152423b5611602374467b195f63818230ea25602acf76077d903bf5919ddf0c6 |
|
MD5 | 27e7aa9e51e303b030740e51be078545 |
|
BLAKE2b-256 | c0040ca754a6da85c09e0edc704e38a661995c493c6a019e51c7465911431fb8 |
File details
Details for the file icalendar-6.1.2-py3-none-any.whl
.
File metadata
- Download URL: icalendar-6.1.2-py3-none-any.whl
- Upload date:
- Size: 206.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c5fda4dd563e603a360c095f841aa0dfa4fdad0b7202e722ba25290189c39d6 |
|
MD5 | 45d9c653b70705b625a1e99af4511768 |
|
BLAKE2b-256 | be858188101c2b4253a22ce843e9690abca3ae58f11a0f854db19dc9bf67e3a5 |