dominikbraun / timetrace

A simple CLI for tracking your working time.
Apache License 2.0
702 stars 76 forks source link

Beautify durations displayed on `timetrace status` #6

Closed dominikbraun closed 3 years ago

dominikbraun commented 3 years ago

At the moment, the output of timetrace status looks as follows:

+-----------------+--------------------+-----------------+
| CURRENT PROJECT | WORKED SINCE START |  WORKED TODAY   |
+-----------------+--------------------+-----------------+
| make-coffee     | 8h25m26.147239s    | 8h25m26.147239s |
+-----------------+--------------------+-----------------+

Displaying durations like 8h25m26.147239s is precise, but unnecessary und unreadable. It should rather look something like 8h 25min.

sachindavra commented 3 years ago

Hi @dominikbraun, May i know in which language it is written?

dominikbraun commented 3 years ago

Hi, timetrace is written in Go. For example, this is the place where the table shown above is being printed:

https://github.com/dominikbraun/timetrace/blob/16b10a97b594a7e73145096e84b6fb9672048df2/cli/status.go#L32-L46

sachindavra commented 3 years ago

Sorry @dominikbraun, i am not much familiar with Go. I know python only.

dominikbraun commented 3 years ago

Nevermind 😄

KonstantinGasser commented 3 years ago

How should seconds be handled? if timetrace status is triggered while the duration is still under 1 minute should the time displayed be for example 12sec or displayed as 0h 0min until the duration is >= 60 seconds? Also if no full hour is reached yet would the output then be 0h 24min or only 24min?

dominikbraun commented 3 years ago

should the time displayed be for example 12sec or displayed as 0h 0min until the duration is >= 60 seconds?

In general, timetrace's smalles unit are minutes. A record started at 12:00:05 will be the same file as a record started at 12:00:40. But perhaps it would make sense to display the seconds for convenience in this case. Maybe 0h 0m 12s if duration < 60s and otherwise just 0h 1m?

Also if no full hour is reached yet would the output then be 0h 24min or only 24min?

I'd suggest 0h 24m in that case.

KonstantinGasser commented 3 years ago

I mean probably not many will do a status right away but 0h 0m 12s would then stick to the other conventions. If > 60 seconds I agree dropping the seconds to only have 0h 1min makes sense!

Ok I will have a look at the functions and what needs to be done.

dominikbraun commented 3 years ago

Closed by #20.