pimutils / todoman

✅ A simple, standards-based, cli todo (aka: task) manager.
https://todoman.readthedocs.io
ISC License
483 stars 78 forks source link

Due date specified as DATE is changed to DATETIME with year 1900 #430

Closed fwc closed 3 years ago

fwc commented 3 years ago

I have a todo with due date 21.04, specified as DUE;VALUE=DATE:20210421 in the .ics-file.

When I open this todo with todo edit <id> and save it again directly, without changes, the due date is changed to DUE;VALUE=DATE-TIME:19000420T230000Z.

So my todo is now due on 21.04.1900.

.ics-file before editing with todoman

BEGIN:VCALENDAR
VERSION:2.0
PRODID:+//IDN tasks.org//android-110903//EN
BEGIN:VTODO
DTSTAMP:20210420T111823Z
UID:3643130479634528538
CREATED:20210420T105907Z
LAST-MODIFIED:20210420T111805Z
SUMMARY:Test
X-APPLE-SORT-ORDER:608725011
DUE;VALUE=DATE:20210421
END:VTODO
END:VCALENDAR

.ics-file after editing with todoman

BEGIN:VCALENDAR
VERSION:2.0
PRODID:+//IDN tasks.org//android-110903//EN
BEGIN:VTODO
CREATED;VALUE=DATE-TIME:20210420T105907Z
DTSTAMP;VALUE=DATE-TIME:20210420T111823Z
DUE;VALUE=DATE-TIME:19000420T230000Z
LAST-MODIFIED;VALUE=DATE-TIME:20210420T112108Z
SEQUENCE:2
STATUS:NEEDS-ACTION
SUMMARY:Test
UID:3643130479634528538
X-APPLE-SORT-ORDER:608725011
END:VTODO
END:VCALENDAR
fwc commented 3 years ago

for reproducing, set date_format in the configuration to date_format = "%d.%m.".

The initial date (2021-04-21) is then displayed in this format ("21.04."), and 'parsed back' into a datetime-object when saving, but the year is lost during the process.

When re-parsing the date, we run into the following code in interactive.py:

    def _save_inner(self):
        # ...
        self.todo.due = self.formatter.parse_datetime(self.due)
        # ...