nikolassv / bartib

A simple timetracker for the command line. It saves a log of all tracked activities as a plaintext file and allows you to create flexible reports.
GNU General Public License v3.0
670 stars 35 forks source link

Sanity check for activity start- and endtimes #15

Closed lukasdietrich closed 2 years ago

lukasdietrich commented 2 years ago

Hello Stranger from the internet,

with this pull request I propose a sanity check for the start- and endtimes of activities.

It checks for two things:

  1. The endtime of an activity may not precede the starttime.
  2. An activity may not start before the previous one ended.

Errors are reported in bartib check. Additionally a warning is printed whenever the list of activies is parsed.

Big thanks for the project und bis Morgen !

nikolassv commented 2 years ago

Thank you for your contribution!

The sanity check is a useful features. But as I have already mentioned in person, I still had some minor issues with the first implementation.

First, your implementation assumed that the activities in the file would be in chronological order. This in normally the case, especially if the file has never been touched by hand, but this has not been a hard requirement before. So we should not make this a requirement now.

Secondly, activities that overlap or have negative duration may contain logical errors, but these are definitely not parsing errors. So I would not check them during activity parsing and would not check for them in the check command which should only check for parsing errors.

I have modified your solution a little and moved the sanity checks into a new subcommand sanity. This command reports any activity with the logical errors.