ical2csv
ical2csv copied to clipboard
Handle all day events
One problem with the sort function before writing to csv is that there could be events that happen all day, hence their dtstart and dtend fields do not have time, and only dates. This makes the sorted() function unable to sort by dtstart, as raises the error "cannot compare datetime.datetime to datetime.date".
open_cal() now return the list of events as well as the calendar itself, so that you can get the field calendar.CALENDAR_TIMEZONE. This is used to convert the events that happen all day to a particular time, in a particular timezone. By default, the timezone is the calendar's timezone (determined by the line
This is useful in formatting events that happen for the entire day, as their start and end do not have start fields.
Also implemented format_events() so that all events start and end time are in datetime.datetime format, rather than datetime.date format. This allows sortedevents to run regardless of events are for a specified time or the whole day.