From 90da11bcd3588f06416e50fb3aec6901363e51ca Mon Sep 17 00:00:00 2001 From: mrvladus Date: Wed, 22 May 2024 19:10:14 +0300 Subject: [PATCH] fix ical dates --- errands/lib/data.py | 6 ++++-- errands/lib/sync/providers/caldav.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/errands/lib/data.py b/errands/lib/data.py index f56714c3..7a3630e8 100644 --- a/errands/lib/data.py +++ b/errands/lib/data.py @@ -142,13 +142,15 @@ def to_ical(self, as_calendar: bool = False) -> str: ical += f"STATUS:{'COMPLETED' if self.completed else 'NEEDS-ACTION'}\n" ical += f"LAST-MODIFIED:{self.changed_at}\n" ical += f"DTSTAMP:{self.created_at}\n" - ical += f"DUE:{self.due_date}\n" + if self.due_date: + ical += f"DUE{';VALUE=DATE' if 'T' not in self.due_date else ''}:{self.due_date}\n" ical += f"X-ERRANDS-EXPANDED:{int(self.expanded)}\n" ical += f"DESCRIPTION:{self.notes}\n" ical += f"RELATED-TO:{self.parent}\n" ical += f"PERCENT-COMPLETE:{self.percent_complete}\n" ical += f"PRIORITY:{self.priority}\n" - ical += f"DTSTART:{self.start_date}\n" + if self.start_date: + ical += f"DTSTART{';VALUE=DATE' if 'T' not in self.due_date else ''}:{self.start_date}\n" ical += f"CATEGORIES:{','.join(self.tags)}\n" ical += f"SUMMARY:{self.text}\n" ical += f"X-ERRANDS-TOOLBAR-SHOWN:{int(self.toolbar_shown)}\n" diff --git a/errands/lib/sync/providers/caldav.py b/errands/lib/sync/providers/caldav.py index 93dc1641..dbb1a589 100644 --- a/errands/lib/sync/providers/caldav.py +++ b/errands/lib/sync/providers/caldav.py @@ -398,8 +398,12 @@ def __update_remote_task(self, calendar: Calendar, task: TaskData) -> None: todo: Todo = calendar.todo_by_uid(task.uid) if task.due_date: todo.icalendar_component["due"] = task.due_date + else: + del todo.icalendar_component["due"] if task.start_date: todo.icalendar_component["dtstart"] = task.start_date + else: + del todo.icalendar_component["dtstart"] if task.created_at: todo.icalendar_component["dtstamp"] = task.created_at if task.changed_at: