VladimirMarkelov / ttdl

TTDL - Terminal Todo List Manager
MIT License
202 stars 17 forks source link

Time spent in human readable format #83

Closed aniketgm closed 1 year ago

aniketgm commented 1 year ago

Current behavior

As shown in the image below (td is my alias to ttdl), the time spent is shown in numbers only (Todo # 1) spent:87. It doesn't mention seconds/minutes, I figured later, it must be seconds.

Expectation

Can we have the spent in first command output in human readable format like in the 'Spent' column shown after running stats which shows output in minutes/hours format.

TTDL Version: Terminal Todo List Manager(TTDL) Version 3.9.0 Platform: Windows

image

VladimirMarkelov commented 1 year ago

Yes, spent is the number of seconds.

A subject is always printed as-is. Adding a formatting(and an extra option to enable/disable the feature because not everybody needs it) for every tag seems too much. But, there are a couple of ways to display those seconds in a human-friendly way:

  1. Hard way

You can create a shell script that gets a JSON, convert a tag value from int to a string and puts the new value back to the JSON. See, Custom formatting section in README.md. I cannot make up a simple script to do this quickly. The only advantage of this way is that you can format seconds in a human-friendly way in any way you want. The way is powerful but it may take much time to get the first result.

  1. Easy way

You can show a separate column for spent. The column shows the duration in human-friendly way always. Advantages:

Drawbacks:

Example for easy way. Let's assume we have the following todo.txt:

test1 due:2023-05-17 more text spent:78
test2 due:2023-06-15 spent:40

Default output:

> ttdl list
# D P Created    Finished   Due        Subject
-----------------------------------------------
1                           2023-05-17 test1 due:2023-05-17 more text spent:78
2                           2023-06-15 test2 due:2023-06-15 spent:40

Show the separate column for spent:

> ttdl list --fields=pri,spent
# P Spent  Subject
-------------------
1   1.3m   test1 due:2023-05-17 more text spent:78
2   40s    test2 due:2023-06-15 spent:40

Duplication of spent in column and in the subject does not look good. Let's hide spent in the subject:

> ttdl list --fields=pri,spent --clean-subject=tags
# P Spent  Subject
-------------------
1   1.3m   test1 due:2023-05-17 more text
2   40s    test2 due:2023-06-15

Both, the list of columns to display and what to remove from the subject is configurable via ttdl.toml.

For list of column names, see README.md section Extra features. For removing spent from the subject, see the section Hide duplicated info.

aniketgm commented 1 year ago

Thanks for the detailed explanation.