A module which unfolds ICalendar events.
Project description
ICal has some complexity to it: Events can be repeated, removed from the feed and edited later on. This tool takes care of these circumstances.
Let’s put our expertise together and build a tool that can solve this!
day light saving time (DONE)
recurring events (DONE)
recurring events with edits (DONE)
recurring events where events are omitted (DONE)
recurring events events where the edit took place later (DONE)
normal events (DONE)
recurrence of dates but not hours, minutes, and smaller (DONE)
endless recurrence (DONE)
ending recurrence (DONE)
events with start date and no end date (DONE)
events with start as date and start as datetime (DONE)
RRULE (DONE)
RDATE
EXRULE
EXDATE (DONE)
Installation
pip install python-recurring-ical-events
Example
import icalendar
import recurring_ical_events
import urllib.request
start_date = (2019, 3, 5)
end_date = (2019, 4, 1)
url = "http://tinyurl.com/y24m3r8f"
ical_string = urllib.request.urlopen(url).read()
calendar = icalendar.Calendar.from_ical(ical_string)
events = recurring_ical_events.of(calendar).between(start_date, end_date)
for event in events:
start = event["DTSTART"].dt
duration = event["DTEND"].dt - event["DTSTART"].dt
print("start {} duration {}".format(start, duration))
Output:
start 2019-03-18 04:00:00+01:00 duration 1:00:00
start 2019-03-20 04:00:00+01:00 duration 1:00:00
start 2019-03-19 04:00:00+01:00 duration 1:00:00
start 2019-03-07 02:00:00+01:00 duration 1:00:00
start 2019-03-08 01:00:00+01:00 duration 2:00:00
start 2019-03-09 03:00:00+01:00 duration 0:30:00
start 2019-03-10 duration 1 day, 0:00:00
Development
- Optional: Install virtualenv and Python3 and create a virtual environment.
virtualenv -p python3 ENV source ENV/bin/activate
- Install the packages.
pip install -r requirements.txt -r test-requirements.txt
- Run the tests
pytest
To release new versions, edit setup.py, the __version__ variable and run
python3 setup.py tag_and_deploy
Research
https://github.com/oberron/annum - https://stackoverflow.com/questions/28829261/python-ical-get-events-for-a-day-including-recurring-ones#28829401
https://stackoverflow.com/questions/20268204/ical-get-date-from-recurring-event-by-rrule-and-dtstart
https://stackoverflow.com/questions/46471852/ical-parsing-reoccuring-events-in-python
Project details
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
Hashes for recurring_ical_events-0.1.3a0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99037e3f50129dbf3ca9e8eef11c3c934a044e8065b5b8350ab9ac1981d3266d |
|
MD5 | 89da65bc3f838819aa91526fe6516ae5 |
|
BLAKE2b-256 | 196dc3833de25120182b65fd3a4469b7439d46cb6ec7e12757331ec06e5a54d2 |