pimutils / todoman

✅ Simple, standards-based, command line todo (aka: task) manager.
https://todoman.readthedocs.io
ISC License
487 stars 80 forks source link

Datetime difference failure with `list` #370

Open privong opened 4 years ago

privong commented 4 years ago

I'm running todoman v3.7.0 and have been experiencing an issue where attempting to list tasks results in a crash and the following error:

$ todo -v DEBUG list personal
debug: No colour for list /home/george/.calendars/travel
debug: No colour for list /home/george/.calendars/work                              
debug: No colour for list /home/george/.calendars/school                            
debug: No colour for list /home/george/.calendars/contact_birthdays                 
debug: No colour for list /home/george/.calendars/personal                          
debug: File already in cache: /home/george/.calendars/travel/GJE8F3ZLQ0UPYSR5FWZ2NIR1QM6PS7Q4O6JZ.ics
[...several thousand more file already in cache notices...]
debug:
debug:               SELECT todos.*, files.list_name, files.path
debug:                 FROM todos, files
debug:                WHERE todos.file_path = files.path AND status IN (?, ?) AND files.list_n
ame IN (?)
debug:             ORDER BY
debug:                 completed_at DESC,
debug:                 priority IS NOT NULL, priority DESC,
debug:                 due IS NOT NULL, due DESC,
debug:                 created_at ASC
debug:
debug:
debug: ['NEEDS-ACTION', 'IN-PROCESS', 'personal']
Traceback (most recent call last):
  File "/usr/bin/todo", line 11, in <module>
    load_entry_point('todoman==3.7.0', 'console_scripts', 'todo')()
  File "/usr/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/todoman/cli.py", line 34, in wrapper
    return f(*a, **kw)
  File "/usr/lib/python3.7/site-packages/todoman/cli.py", line 645, in list
    click.echo(ctx.formatter.compact_multiple(todos))
  File "/usr/lib/python3.7/site-packages/todoman/formatters.py", line 68, in compact_multiple
    due = self.format_datetime(todo.due)
  File "/usr/lib/python3.7/site-packages/todoman/formatters.py", line 219, in format_datetime
    rv = humanize.naturaltime(self.now - dt)
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'datetime.date'

Running todo list on other task lists succeeds, which leads me to believe that there's some issue with a specific task in that list, but I haven't been able to identify which (if any) tasks are causing this problem.

In case it's helpful, I'm running this on Arch Linux with kernel version 5.3.8-arch1-1.

privong commented 4 years ago

I've been able to reproduce this by creating a task (on my iPhone) which only has a date deadline and not a time deadline:

2019-11-11 14-01-41-1

The resulting ICS file is:

BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Apple Inc.//iOS 13.2.2//EN
VERSION:2.0
BEGIN:VTODO
CREATED:20191111T190030Z
DTSTAMP:20191111T190037Z
DTSTART;VALUE=DATE:20191112
DUE;VALUE=DATE:20191112
LAST-MODIFIED:20191111T190036Z
STATUS:NEEDS-ACTION
SUMMARY:Test
UID:4A55070D-34BF-4B59-A039-81E4F38C6D4F
END:VTODO
END:VCALENDAR

I guess the issue is the "DUE;" line which lacks a time.

WhyNotHugo commented 4 years ago

This is something that we should support.

Thanks for narrowing it down. The ICS file is perfect for debugging this, I'll try to look at it soonish.

privong commented 4 years ago

@WhyNotHugo Do you have a guess at when it might be possible to address this? No huge rush, but I intermittently have to work around this issue, so I was curious.

chrpinedo commented 4 years ago

I have exactly this issue if i don't provide a due time to the due date. If I set due to "2020/01/18" it breaks todoman, If i set due to "2020/01/18 23:59:59", there is no problem.