Codebox Software

Time Arithmetic Utility

A simple command-line utility for performing time arithmetic. I wrote this for use in a shell script that trimmed a specified number of seconds off the beginning and end of an audio file - maybe someone else will find it useful for something. The utility is written in C, and as usual you can find the source code on GitHub.

The utility expects two arguments:
  • a string containing a time, formatted as follows: HH:MM:SS
  • an integer number of seconds to add to the specified time (the value can be either positive or negative)
The utility prints the resulting time to stdout. Examples:
timeadd 00:23:49 15
> 00:24:04

timeadd 00:10:00 -605
> -00:00:05