Time Tracking Like a Nerd

Good ol' plain text.

Tagged with: tools

Published on

Tracking the time I spend on projects is often necessary but always annoying. In my professional life I have worked with various tools to accomplish this daunting task. They ranged from shiny web apps to desktop apps that were so complicated to use that it was easier to keep track of time in a separate Excel file and copy data over to the app every couple of days. If you look online for applications to track time you will find a myriad of results and each one has a ton of features that will probably never be used by the likes of me. I was looking for a solution that allows me to quickly and easily enter data while keeping everything stored locally. Luckily I did not have to look far. I’m already using hledger to keep track of my finances in plain text and recently learned that it has support to read and report on two different plain text time logging formats: timeclock and timedot.

Timeclock originates from the Emacs timeclock.el. It’s a bit harder for humans to read and write but allows logging the start and end of a task with second precision. Each line that starts with an i marks the start of a task. The next line that isn’t a comment (lines starting with #, ; or *) or blank must start with o which marks the end of the task. After an i or an o comes a date and time. The date and time in starting lines has to be followed by an account or project name. Separated by two spaces from the account optional comments and tags can be added.

i 2024-03-15 07:00:00 blogging  writing about time tracking after 2 spaces ; optional comment, tags:
o 2024-03-15 07:30:00
i 2024-03-15 07:30:00 eating  breakfast with coffee
o 2024-03-15 08:00:00

By running hledger commands with the above sample a number of reports can be generated. For example to get an overview over the hours tracked to each account the balance command can be used.

$ hledger -f sample.timeclock balance
               0.50h  blogging
               0.50h  eating

To get a detailed list of all the logged hours in a specific month the register command with the --period option comes in handy.

$ hledger -f sample.timeclock register --period 2024-03
2024-03-15 writing about time tracking after 2 spaces  (blogging)  0.50h   0.50h
2024-03-15 breakfast with coffee                       (eating)    0.50h   1.00h

In order to get a report of all the hours that were logged to each account per month the register command in combination with the -M option can be used.

$ hledger -f sample.timeclock register -M
2024-03  blogging    1.00h    1.00h
         eating      0.50h    1.50h

In contrast to the timeclock format the timedot format is a bit easier to read for humans. It achieves this by removing the exact timestamps that mark the start and end of a task. Instead, it simply adds blocks of time to accounts on a day. There are multiple types of blocks but the one that gives the timedot format its name is the period . which is interpreted as 15 minutes. To illustrate this look at the following timedot example that tracks the same amount of time as the timeclock example above.

blogging  ....
eating    ..

All the same commands that can be used with timeclock files can also be used with timedot files.

I’m still undecided which format I like more. At the moment I lean more towards the timedot format because I seldomly need to know the start and end times of the work I keep track of. In my experience time tracking is a very emotional topic and I don’t know many people that like it. I think that by using a plain text file to keep track of the time I spend on projects I am less distracted from the many features most time tracking applications offer and spend more time on the actual problems I try to solve.