In the last learning phase I tried to use Examtime to create my study plan in a celandar. After the exam I wanted to check how much time I’ve used for each lecture to prepare. So I wrote a small Python script and exported an iCalendar from Examtime.
##Parsing the .ical
To calculate the used time I have to get all the calendar events and count their time together.
In the iCal format the VEVENT Block marks an event subcomponent with properties like start time DTSTART and end time DTEND.
The iCalendar library makes parsing a breeze. You can iterate over all components of a certain type by using the walk function.
I struggled at first with getting the time of the event but you simply have to call the dt attribute and you get a normal datetime object.
The lecturize function searches for the lecture names in the event summary and then uses that lecture name as a key.
Now we have the data in a usable format.
##Calculating the used time
We group the records by it’s lecture name and simply yield the sum of the timedeltas.
Now we have the used_time foreach lecture and the total_time and are done.
In my case that returned the time used while I was learning during December and January:
I created a Gist with the code in case you’re interested.