dotfiles

<-- duh.
git clone https://hhvn.uk/dotfiles
git clone git://hhvn.uk/dotfiles
Log | Files | Refs | Submodules | LICENSE

secs2cst (459B)


      1 #!/bin/sh
      2 #
      3 # seconds to colon-seperated-time
      4 
      5 # DONOTUSE: cannot handle hours yet
      6 
      7 [ -z $1 ] || [ "$1" = "-h" ] && echo "usage: secs2cst <n>" && exit 1
      8 
      9 awk -v "n=$1" '{
     10 		for (i=0;; i++) {
     11 			if (n > 60) {
     12 				result[i] = int(n / 60)
     13 				n = n - (result[i] * 60)
     14 			} else {
     15 				result[i] = n
     16 				break
     17 			}
     18 		}
     19 		elements = i
     20 		for (i=0; i <= elements; i++)
     21 			if (i != elements)
     22 				printf("%02d:", result[i])
     23 			else
     24 				printf("%02d\n", result[i])
     25 	}'
     26