How I Clock In My Work Time

Sometimes I work with clients on per-hour basis. That means I need to keep track of the hours I worked and then generate an invoice based on that.

In my case I also have a separate rate for weekends and overtime.

The tool that worked best for me is the Emacs Org-mode clocking feature.

I keep track of my time in org documents, I usually create a separate document for each week and client.

Here is an example structure:

#+TITLE: Client Worklog W26

** Summary
#+BEGIN: clocktable :scope file :maxlevel 2 :properties ("Hourly rate" "Price" "Fraction") :formula ()
#+CAPTION: Clock summary at [2023-06-27 Tue 08:03]
| Hourly rate |  Price | Fraction | Headline                | Time |      |
|-------------+--------+----------+-------------------------+------+------|
|             | 206.00 |          | *Total time*              | *1:32* |      |
|-------------+--------+----------+-------------------------+------+------|
|         100 | 100.00 |     1.00 | \_  Update website UI   |      | 1:00 |
|         200 | 106.00 |     0.53 | \_  Migrate database x2 |      | 0:32 |
#+TBLFM: @3$3..@>$3=$6;t::@3$1..@>$1='(if (string-match "x2" $4) 200 100)::@3$2..@>$2=$3*$1;%0.2f::@2$2=vsum(@3$2..@>$2);%0.2f


** Update website UI
:LOGBOOK:
CLOCK: [2023-06-27 Tue 07:02]--[2023-06-27 Tue 08:02] =>  1:00
:END:

** Migrate database x2
:LOGBOOK:
CLOCK: [2023-06-27 Tue 06:30]--[2023-06-27 Tue 07:02] =>  0:32
:END

The idea here is to use the built in timer feature of the Org-mode.

To start tracking time you define a task as a header:

** Write an article

And then you put your cursor on this header line and press C-c C-x C-i – or in other words Ctrl+c Ctrl+x and then Ctrl+i.

This chord combination starts a timer and it looks like this:

** Write an article
:LOGBOOK:
CLOCK: [2023-10-12 Thu 12:35]
:END:

After you’ve completed the task you can press C-c C-x C-o to stop the timer:

** Test test
:LOGBOOK:
CLOCK: [2023-10-12 Thu 12:35]--[2023-10-12 Thu 12:41] =>  0:06
:END:

It will automatically calculate the task duration.

Then you can use this data to create a summary table. I usually add it in the beginning of the file

#+BEGIN: clocktable :scope file :maxlevel 2 :properties ("Hourly rate" "Price" "Fraction") :formula ()
#+CAPTION: Clock summary at [2023-06-24 Sat 08:55]
| Hourly rate | Price | Fraction | Headline   | Time |
|-------------+-------+----------+------------+------|
|             |       |          | *Total time* | *0:00* |
#+TBLFM: @3$3..@>$3=$6;t::@3$1..@>$1='(if (string-match "x2" $4) 200 100)::@3$2..@>$2=$3*$1;%0.2f::@2$2=vsum(@3$2..@>$2);%0.2f
#+END:

After I’m done with the tasks I first fill in the table with all the timers in the current document by pressing C-c C-c on the first line where it says #BEGIN: clocktable...

This populates the table with the time segments.

Then I can run the formula (The bottom line starting with #+TBLFM:).

To do this I move to this line and press C-c C-c two times. I need to do It two times because the formula calculates the values in the table sequentially – so If you have cell values that depend on other cells – you’ll have to run the formula for each dependency until the data propagates completely.

And that’s how I clock my time.