timecard-rs
This is a program I make whenever I want to learn the intricacies of a language. I've done this before in Python, Kotlin/JVM, Kotlin/Native, and Kotlin/JS, now it's in Rust. However, it is also meant to be useful to myself, so maybe you can find some use in it, too.
timecard is a library that makes it easy to build applications that keep track of time,
such as timecard-cli.
Install
Install the terminal application with Cargo:
Add the library to your project with Cargo:
Ensure Cargo binaries are in your path by adding this to your ~/.bashrc:
Then restart your terminal or run source ~/.bashrc.
Usage
Clocking In & Out
You start time entries by clocking in, and finish them by clocking out. You can only clock in/out at the current time, or at a time in the past.
A variety of time formats are accepted, including, but not limited to:
- An integer, representing minutes in the past. (e.g. timecard out 5 will clock out 5 minutes ago)
- An RFC 3339 datetime that is in the past, such as
2026-03-08T11:15 - An intuitive humantime string representing a duration in the past, such as
1hr7minor10minutes. - A human-readable time that is earlier today, e.g.
15:37,3:37:53 PM,3PM - A human-readable datetime that is in the past, e.g.
20260308T3PM
Undo
You can remove the last time log by running the undo command:
Log
You can see a log of all your time entries for the day:
You can see other days by providing a date, similar to the formats used for clocking in or out:
# Assuming today is 2026-03-08
You can also see logs for a date range by providing the --from-date and --to-date options:
# Assuming today is 2026-03-08
You can even combine these two methods to get the log for the date range provided, as well for a single day's log.
Using the --all flag will ignore everything and just spit all of your time entries
into the console.
You can also use the --csv flag to output in CSV format.
You can then pipe the output to a file to save it.
If you pass an argument to the --csv flag, it will be used as the column separator:
;
;
Configuration
The config file location depends on what OS you're on:
| OS | Location |
|---|---|
| Windows | %APPDATA%\timecard\timecard-cli.toml |
| macOS | $HOME/Library/Application Support/timecard/timecard-cli.toml |
| Linux/UNIX | $XDG_CONFIG_HOME/timecard/timecard-cli.toml OR $HOME/.config/timecard/timecard-cli.toml |
The default file that is generated is self-explanatory.
If you don't have any comments explaining how the config works,
either delete or rename the file, then just run timecard.
The newly generated file will contain comments explaining each field.
Duration Format
The duration_fmt config field uses a custom format defined below:
| Specifier | Example | Description |
|---|---|---|
%ht |
2.8 |
Hours, rounded to the nearest tenth |
%hq |
2.75 |
Hours, rounded to the nearest quarter |
%hh |
2.5 |
Hours, rounded to the nearest half |
%HR |
2 |
Hours, rounded to the nearest whole hour |
%HH |
2 |
Whole hours |
%MM |
30 |
Whole minutes |
>>H |
02 |
Whole hours, padded with zeros |
>>M |
09 |
Whole minutes, padded with zeros |