pimutils / todoman

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

Missing time on --start error #523

Open mstmob opened 1 year ago

mstmob commented 1 year ago

todo list --start before 2023-03-01 results in the following error:

Traceback (most recent call last):
  File "/usr/bin/todo", line 8, in <module>
    sys.exit(cli())
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/todoman/cli.py", line 38, in wrapper
    return f(*a, **kw)
  File "/usr/lib/python3.10/site-packages/todoman/cli.py", line 658, in list
    click.echo(ctx.formatter.compact_multiple(todos, hide_list))
  File "/usr/lib/python3.10/site-packages/todoman/formatters.py", line 69, in compact_multiple
    for todo in todos:
  File "/usr/lib/python3.10/site-packages/todoman/model.py", line 795, in todos
    dt = dt.timestamp()
AttributeError: 'datetime.date' object has no attribute 'timestamp'. Did you mean: 'fromtimestamp'?

It works as expected if the time is specified, i.e.: todo list --start before 2023-03-01T10:00

Proposal: The start parameter should fallback to a default time, i.e. "00:00:00".

Furthermore the --start parameter should be documented correctly: Currently no [before|after] is described in the documentation and zsh completion.

Version: todoman, version 4.2.1

WhyNotHugo commented 1 year ago

Indeed, we should allow dates here. I think _validate_start_date_param should return Tuple[bool, datetime] | Tuple[bool, date] | None (it currently returns Tuple[bool, datetime] | None).

The docs should also definitely reflect the before/after usage.