GeekTool (UNIX) counter leading zeros

115 views Asked by At

I'm trying to make a timing counter for a running race through GeekTool on Mac (UNIX based) and have the following:

expr `date -j -f "%d/%m/%Y %H:%M:%S" "05/09/2012 07:41:15" "+%s"` - `date "+%s"` | awk '{ if( int( 0$1/86400 ) < 0 ) printf "" , int( 0$1/86400 ) ; if( int( 0$1/86400 ) < 0 || int( $1%86400/3600 ) < 0 ) printf "%d:" , int( $1%86400/3600 ) ; if( int( $1/86400 ) < 0 || int( $1%86400/3600 ) < 0 || int( $1%3600/60 ) < 0) printf "%d:" ,  int( $1%3600/60 ) ; if( int( $1/86400 ) < 0 || int( $1%86400/3600 ) < 0 || int( $1%3600/60 ) < 0 || $1%60 < 0 ) printf "%d" , $1%60 ; else printf "Hello!" }' | sed -E 's/-/ /' | sed -E 's/-/ /' | sed -E 's/-/ /' | sed -E 's/-/ /'

The problem is that when either the minutes or second are less than 10 there is no leading zero (i.e. 1:7 instead of 01:07). How do I add leading zeros to this so that it will look like a standard timing clock?

1

There are 1 answers

1
AudioBubble On

Use M and S:

$ date +"%H:%M:%S"
14:54:00