tc-rpn − time calculator
tc-rpn [-V]
[--version] [-h] [--help]
[-e scriptexpression] [--expression=scriptexpression]
[-f scriptfile] [--file=scriptfile]
[file ...]
tc-rpn is a reverse-polish time calculator. Normally it reads the standart input, but may also accept arguments including filenames. All normal output is sent to standart output, all error output is to standart error.
A reverse-polish calculator stores numbers on a stack. Entering a number pushes it on the stack. Arithmetic operations pop arguments off the stack and push the results.
tc-rpn has synthax and behaviour similar to one of GNU dc reverse-polish desk calculator, so it would be familiar for the GNU dc users.
tc-rpn may be invoked with the following command-line options:
-V |
--version
Print out the version of tc-rpn that is being run and a copyright notice, then exit.
-h |
|||
--help |
Print a usage message briefly summarizing these command-line options and the bug-reporting address, then exit. |
-f script-file
--file=script-file
Add the commands contained in the file script-file to the set of commands to be run while processing the input.
-e script
--expression=script-file
Add the commands in script to the set of commands to be run while processing the input.
tc-rpn accepts two types of values: time and numbers.
Time synthax is normally as following: [[[HH:]]]MM[:SS[.MSS]] or [[[HH:]MM:]SS].MSS (where HH is hours, MM - minutes, SS - seconds and MSS - milliseconds).
If You only need to specify hours, minutes or seconds, You may specify time as HHh, MMm or SSs accordingly. For milliseconds only .MSS notation is sufficient.
Time values may be inconsistent. For example tc-rpn will automaticly convert "1:-10:20" to "0:50:20".
The hardest part is the milliseconds synthax. To specify exactly one millisecond You should put {...}.001, because {...}.1 is treated as 100 milliseconds. Milliseconds should be considered as seconds remainder, so due to mathimatical notation 0.1 seconds equals to 100 milliseconds.
tc-rpn accepts the following commands:
+ |
Pops two time values off the stack, adds them, and pushes the result. |
||
- |
Pops two time values, subtracts the first one popped from the second one popped, and pushes the result. |
||
* |
Pops two values, multiplies them, and pushes the result. First of the values must be time, the second one must be regular number. |
||
/ |
Pops two values, divides the second one popped from the first one popped, and pushes the result. First of the values must be time, the second one must be regular number. |
||
p |
Prints the value on the top of the stack, without altering the stack. A newline is printed after the value. | ||
q |
Makes tc-rpn exit. |
tc-rpn outputs the sane minimum of data.
The output string is composed as HH:MM[:SS[.MSS]] with seconds and milliseconds ommited if equal null.
So 00:01 reads as one hour and one minute.
tc-rpn is not very precise on divide commands. Each divide operation makes You loose up to half millisecond.
If You notice any other bugs, please don't hesitatte to send the report for czarkoff <at> gmail <dot> com.