zsh: treewide: minor fixes/style
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-ts-to-human() {
|
||||
local t=$1
|
||||
local s=$(( int(t) ))
|
||||
local ns=$(( int((t - s) * (10**9)) ))
|
||||
local t s ns d h m f x
|
||||
|
||||
t=$1
|
||||
s=$(( int(t) ))
|
||||
ns=$(( int((t - s) * (10**9)) ))
|
||||
t=$s
|
||||
|
||||
local d=0 h=0 m=0
|
||||
d=0 h=0 m=0
|
||||
if [ $t -ge 86400 ] ; then
|
||||
d=$(( t / 86400 ))
|
||||
t=$(( t % 86400 ))
|
||||
@@ -20,10 +22,10 @@ z-ts-to-human() {
|
||||
t=$(( t % 60 ))
|
||||
fi
|
||||
|
||||
local f='%s.%6.'
|
||||
f='%s.%6.'
|
||||
f=$(strftime "$f" $t $ns)
|
||||
|
||||
local x=3
|
||||
x=3
|
||||
## keep math in sync with format above
|
||||
case "$2" in
|
||||
0) x=7 ;;
|
||||
@@ -35,5 +37,6 @@ z-ts-to-human() {
|
||||
[ $s -ge 60 ] && f="${m}m:$f"
|
||||
[ $s -ge 3600 ] && f="${h}h:$f"
|
||||
[ $s -ge 86400 ] && f="${d}d:$f"
|
||||
|
||||
echo "$f"
|
||||
}
|
||||
|
Reference in New Issue
Block a user