rwxrob-dot/scripts/sec2dur

16 lines
397 B
Plaintext
Raw Normal View History

2022-02-09 07:29:05 +00:00
#!/usr/bin/env bash
seconds="$1"
[[ -z "$seconds" ]] && echo "usage: $0 SECONDS" && exit 1
days=$((seconds/86400))
out=""
(( days > 0 )) && out="${days}."
(( seconds -= (days*86400) ))
hours=$((seconds/3600))
(( hours > 0 )) && out+="${hours}."
(( seconds -= (hours*3600) ))
minutes=$((seconds/60))
(( minutes > 0 )) && out+="${minutes}."
(( seconds -= (minutes*60) ))
out+="$seconds"
echo "$out"