I just bought a RPi ZeroW and an InkypHAT and was planning to show some information on it.
The weather should be no problem, the date should also be no problem but…
The one thing that I’m not sure how to show are the calendar appointments for a Google Calendar account. If those are multiple appointments I’d like to show them in a scrolling textbox. How can I achieve this?
Many thanks for your help!
I looked briefly into this and determined the easiest short-term way would be to export the ical file and use that. It could, in theory, be done with the Google calendar API but it’s not exactly user-friendly if you’re not used to dealing with APIs and authentication: https://developers.google.com/google-apps/calendar/quickstart/python
I decided to go onto the download ICS file route. But I’m stuck at making a script that shows all appointments for a day with their starting hour…
I think the problem lies in the fact that there are events that are ‘whole day’ events and events that have a start time and an end time.
I get the error “can’t compare datetime.datetime to datetime.date” And I’m guessing that has something to do with the fact that sometimes the DTSTART of an event is sometimes a date and sometimes a datetime type…
Since one includes information about the time, they cannot be meaningfully compared with normal operators:
>>> x = datetime.date.today()
>>> y = datetime.datetime.now()
>>> x == y
False
>>> x > y
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't compare datetime.datetime to datetime.date
You have to be specific about what you want to compare:
Thank you very much for your post, very clear. Now I’m hitting the next problem: when I create a repeating event, I cannot test if the start or end date match the current day. Is there a way around this?
So I guess how you check depends rather heavily on what the “FREQ” is set to. If it’s daily then you just need to verify that it’s between the start/end dates and the start/end times separately.
Weekly could be trickier- what if it’s a two day event? :D
Oh bugger me with a fishfork, this whole project is getting a bit over my head I’m afraid…
Still, I get the distinct feeling that I’m reinventing the wheel here: surely somebody must have tackled this problem a long time ago?