summaryrefslogtreecommitdiff
path: root/nocompile/bin/elapsedtime
blob: f17d32646aa9b62abd7f5b6d4f487681529a61be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
if [ "_$1" != "_" ];then
 time=$1
else
 read time
fi

partials=$(echo $time | grep "\." | cut -d. -f2)
wholes=$(echo $time | cut -d. -f1)
seconds=$(( wholes % 60 ))
minutes=$(( wholes/60 % 60 ))
hours=$(( wholes/60/60 % 24 ))
days=$(( wholes/60/60/24 ))
#days=$(( wholes/60/60/24 % 7 ))
#weeks=$(( wholes/60/60/24/7 ))
#echo $weeks weeks $days days $hours:$minutes:$seconds.$partials
if [ "_$days" != "_0" ];then
 printf '%d days ' "$days"
fi
printf "%02d:%02d:%02d" "$hours" "$minutes" "$seconds"
if [ "_$partials" != "_" ];then
 echo .$partials
else
 echo
fi
if read time;then
 elapsedtime $time
fi