This works, as in it will add and subtract as requested. However, AWK is removing the starting digit 0 on the output. I need to keep this as my script is adding and subtracting time.
The two issues I am facing is AWK removing the starting 0 and also if I add '1' to the "time" 1159 my way of counting time will output 1160, where as I would like it to read 1200.
Any help would be met would the greatest of appreciation.
awk isn't that easy in respect to either of your questions.
if "expr can be represented ... as an exact integer then it is converted to sprintf("%d", expr)." (cf man awk ) So you can't use OFMT or CONVFMT immediately, you need to play dirty tricks with them or use formatted printing of each field.
if you want a "carry flag" to apply at a value of 60, again you need to take the scenic route.
How about making the values slightly deviate from an integer so the CONVFMT applies, and to use a conditional assignment for the carry over? Try
Please be aware of the non-integer values if you need to use $1 and $2 in further arithmetics.
The "carry under" for $1 is left as an exercise to the reader. Of course the operations on every single field can be combined into one statement.
Thanks RudiC, I love how your brain went there to "trick" CONVFMT and I never knew a carry flag. I have tried your suggestion and it works brilliantly. My input file works in tandem with your suggestion and always will. Many Many thanks.