Search code examples
pythongoogle-calendar-apirrule

parsing recurrence Google Calendar API


I'm trying to create small web app which will work with user Google Calendar data. Everything works fine except getting start datetime for events with 'recurrence' in item.keys().

Question: How can I get start time of event from given data:

{'kind': 'calendar#event', 
'sequence': 0, 
'htmlLink': 'link', 
'creator': {my info}, 
'location': '...', 
'summary': '...', 
'etag': '"etag"', 
'organizer': {org_info}, 
'status': 'confirmed', 
'reminders': {'useDefault': True}, 
'created': '2016-09-18T07:02:56.000Z', 
'id': event_id, 
'iCalUID': 'iCalUID', 
'start': {'timeZone': 'Europe/Moscow', 'dateTime': '2016-09-07T14:35:00+03:00'}, 
'updated': '2016-09-18T07:02:56.612Z', 
'description': '...', 
'recurrence': ['RRULE:FREQ=WEEKLY;WKST=SU;INTERVAL=2;BYDAY=WE'], 
'end': {'timeZone': 'Europe/Moscow', 'dateTime': '2016-09-07T16:10:00+03:00'}}

My idea was to parse somehow RRULE, I've found way to get list of datetimes from it, but how to get this event start time is still question for me.

I'm getting data with service.events().list(...).execute()

I know that in the new API (i found this only today) item has nice called originStartTime, but old events don't have thing.


Solution

  • StackOverflow magic: I was trying to find solution for 2 days, only after posting the question I've found method or function which does exactly what I needed events().instances()