Skip to content

Commit

Permalink
Fix crash on tasks with no due date
Browse files Browse the repository at this point in the history
  • Loading branch information
tsbarnes committed Oct 13, 2021
1 parent 016a0b3 commit d519412
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions libs/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
def sort_by_date(obj: dict):
"""
Sort the events or tasks by date
:param obj: dict containing sumary and start/due date
:param obj: dict containing summary and start/due date
:return: the same object, with time added if needed
"""
if obj.get("start"):
Expand All @@ -32,15 +32,13 @@ def sort_by_date(obj: dict):
return timezone.localize(obj["start"])
return obj["start"]
elif obj.get("due"):
if not obj["due"]:
return datetime.fromisocalendar(4000, 1, 1)
if isinstance(obj["due"], date) and not isinstance(obj["due"], datetime):
return datetime.combine(obj["due"], datetime.min.time(), timezone)
if not obj["due"].tzinfo:
return timezone.localize(obj["due"])
return obj["due"]
else:
return datetime.max
return timezone.localize(datetime.fromisocalendar(4000, 1, 1))


class Calendar(threading.Thread):
Expand Down

0 comments on commit d519412

Please sign in to comment.