Skip to content

Instantly share code, notes, and snippets.

@xicalango
Last active August 29, 2015 14:25
Show Gist options
  • Save xicalango/4816e664ceba08926f9f to your computer and use it in GitHub Desktop.
Save xicalango/4816e664ceba08926f9f to your computer and use it in GitHub Desktop.
Decimal time formatter
#!/usr/bin/env bash
DATE=( $(date +'%_H %_M %_S') )
totalSec=$(( ${DATE[2]} + (${DATE[1]}*60) + (${DATE[0]}*3600) ))
totalDSec=$(( (1000 * totalSec) / 864 ))
dHrs=$(( totalDSec / 10000 ))
dMin=$(( (totalDSec % 10000) / 100 ))
dSec=$(( totalDSec % 100 ))
printf '%02d:%02d:%02d\n' $dHrs $dMin $dSec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment