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.
This commit is contained in:
Aaron Godfrey 2020-08-28 14:43:40 -07:00 committed by GitHub
parent 755ddf1a94
commit 16ad8cf720
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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