File size: 585 Bytes
3b9a6b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import icalendar

from pathlib import Path


def test_calendar_operations():
    ics_path = Path("tests/data/calendar.ics")

    calendar = icalendar.Calendar.from_ical(ics_path.read_bytes())

    for event in calendar.events:
        print(event.get("summary"))

        def to_iso(val):
            if hasattr(val, "dt"):
                dt = val.dt
                if hasattr(dt, "isoformat"):
                    return dt.isoformat()
                return str(dt)
            return str(val)

        print(to_iso(event.get("dtstart")))
        print(to_iso(event.get("dtend")))