From 16ad8cf720ee8b115d06610f0d62a0f38f622307 Mon Sep 17 00:00:00 2001 From: Aaron Godfrey Date: Fri, 28 Aug 2020 14:43:40 -0700 Subject: [PATCH] Fix todoist calendar events (#39197) Updated the calendar event dict to contain a `summary` key so that the title will display on the calendar panel. Also update the start/end date to not include time information if the event is all day so that it renders as an all day event on the calendar panel. --- homeassistant/components/todoist/calendar.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/todoist/calendar.py b/homeassistant/components/todoist/calendar.py index 014dbd37a4e..548cac6da92 100644 --- a/homeassistant/components/todoist/calendar.py +++ b/homeassistant/components/todoist/calendar.py @@ -503,12 +503,19 @@ class TodoistProjectData: continue due_date = _parse_due_date(task["due"]) if start_date < due_date < end_date: + if due_date.hour == 0 and due_date.minute == 0: + # If the due date has no time data, return just the date so that it + # will render correctly as an all day event on a calendar. + due_date_value = due_date.strftime("%Y-%m-%d") + else: + due_date_value = due_date.isoformat() event = { "uid": task["id"], "title": task["content"], - "start": due_date.isoformat(), - "end": due_date.isoformat(), + "start": due_date_value, + "end": due_date_value, "allDay": True, + "summary": task["content"], } events.append(event) return events