Skip to content

Commit

Permalink
fix ical dates
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvladus committed May 22, 2024
1 parent 142c6fa commit 90da11b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions errands/lib/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions errands/lib/sync/providers/caldav.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 90da11b

Please sign in to comment.