Undoing what has been done

Sometimes you need to take a step back...

In the previous section, you used time information to track your activities more precisely. However, your last command to start a new time tracking was erroneous:

$ timew summary :ids

^[[4mWk^[[0m ^[[4mDate      ^[[0m ^[[4mDay^[[0m ^[[4mID^[[0m ^[[4mTags         ^[[0m ^[[4m   Start^[[0m ^[[4m     End^[[0m ^[[4m   Time^[[0m ^[[4m  Total^[[0m
W8 2025-02-23 Sun @9 SPORT          8:05:21  8:22:56 0:17:35
                  @8 PREPARATION    8:31:07  9:20:02 0:48:55
                  @7 HOME           9:23:00  9:54:28 0:31:28
                  @6 ERRANDS       10:00:00 10:48:00 0:48:00
                  @5 CLIENT        11:02:13 11:14:56 0:12:43
                  @4 CLIENT, PHONE 11:14:56 11:19:22 0:04:26
                  @3 CLIENT        11:19:22 11:34:07 0:14:45
                  @2 SPORT         11:39:00 12:00:00 0:21:00
                  @1 HOMEWORK      13:00:00        - 0:05:23 3:24:15
                                                             ^[[4m       ^[[0m
                                                             3:24:15

$ ▒

You intended to start tracking at 12:00 but mistakenly entered 13:00. How can you correct this?

Let’s have a look at three commands (cancel, undo, and delete), how they can be applied to fix this situation, and where they differ.

Cancel current time tracking

One way to remove your erroneous interval is to abort the current time tracking. For this, you can use the cancel command:

$ timew cancel
Canceled active time tracking.
$ ▒

The cancel command removes the current open interval from the Timewarrior database. It therefore only works when there is active time tracking.

A successive call of the cancel command will then only inform you that there is nothing more to cancel:

$ timew cancel
There is no active time tracking.
$ ▒

Undo recent changes

Another way to correct recent mistakes is the undo command. As the name implies, it undoes the last command you entered.

$ timew undo
Undo
$ ▒

Timewarrior keeps a journal of the database changes, which the undo command uses to revert them. With each call of undo you go one step back in the history of those database changes.

Be aware that Timewarrior also erases the journal entry for each change it reverts. If you want to redo it, you will have to re-enter the command that caused it (you might have to rely on your shell history for this).

In your case, calling the undo command reverts the creation of the open interval from previous start command – just like the cancel command would have done.

Delete previous time tracking

A third option to remove the erroneous interval from the database is the delete command, which allows you to delete one or more intervals by their IDs.

To delete the latest interval, you call it with the interval ID @1 (which always points to the latest interval):

$ timew delete @1
Deleted @1
$ ▒

In contrast to commands cancel which only removes active time tracking, and undo which reverses the last command, the delete command can be used to remove any interval from the database by specifying its ID.

Wrapping up…

Whatever option you have chosen, looking at our current time tracking again, you see that the erroneous time tracking is gone:

$ timew summary :ids

^[[4mWk^[[0m ^[[4mDate      ^[[0m ^[[4mDay^[[0m ^[[4mID^[[0m ^[[4mTags         ^[[0m ^[[4m   Start^[[0m ^[[4m     End^[[0m ^[[4m   Time^[[0m ^[[4m  Total^[[0m
W8 2025-02-23 Sun @8 SPORT          8:05:21  8:22:56 0:17:35
                  @7 PREPARATION    8:31:07  9:20:02 0:48:55
                  @6 HOME           9:23:00  9:54:28 0:31:28
                  @5 ERRANDS       10:00:00 10:48:00 0:48:00
                  @4 CLIENT        11:02:13 11:14:56 0:12:43
                  @3 CLIENT, PHONE 11:14:56 11:19:22 0:04:26
                  @2 CLIENT        11:19:22 11:34:07 0:14:45
                  @1 SPORT         11:39:00 12:00:00 0:21:00 3:18:52
                                                             ^[[4m       ^[[0m
                                                             3:18:52

$ ▒

However, you notice that for some intervals the start and end times are not correct.

Do you now have to undo/delete all those commands and re-enter them correctly? No! Luckily, Timewarrior offers some more commands to modify your recorded intervals.

In the next section, you will learn how to modify the datetime properties of your recorded intervals.

Or you return to the Tutorial section and pick another topic of interest.