Converting seconds to human readable time duration.
By default, to install to /usr/local
, run:
$ make install
Or to /usr
:
$ make install PREFIX=/usr
Or to your home:
$ make install PREFIX=$HOME
To uninstall, use uninstall
target with PREFIX
if supplied during installation.
The basic usage:
$ ./td.sh 123
2 minutes 3 seconds
You can source the script to have print_td
function for better performance:
$ source td.sh
$ print_td 123
2 minutes 3 seconds
$ ./td.sh 1 2 60 61
1 second
2 seconds
1 minute
1 minute 1 second
$ ./td.sh -p -P 1 2 60 61
1 second
2 seconds
1 minute
1 minute 1 second
$ ./td.sh -p -P -a 1 2 60 61
0 days 0 hours 0 minutes 1 second
0 days 0 hours 0 minutes 2 seconds
0 days 0 hours 1 minute 0 seconds
0 days 0 hours 1 minute 1 second
-a prints all number even they are zeros.
-p[X] padding for numbers. 'X' is the padding character, default is ' '.
-P padding for unit strings.
-a
will prints all numbers and units even the numbers are zeros.-p
prints out like1 second
or-p0
for01 second
or07 seconds
.-P
prints out like1 minute 12 seconds
, note there is additional space afterminute
.
There is a script named td-test.sh
for testing, you can also run make test
.
- Author's posts:
This project is licensed under the MIT License.
Copyright (c) 2010, 2012 Yu-Jie Lin