Module format : ajout d’une fonction de formatage des dates
This commit is contained in:
parent
958f4a22ce
commit
3e66e82f8e
|
@ -177,3 +177,27 @@ fn list {|&with-header=$true &csep=' ' &hsep='-' &recompute=$true props data|
|
|||
echo (line &sep=$csep $props $d)
|
||||
} $data
|
||||
}
|
||||
|
||||
fn size {|size|
|
||||
var u = 0
|
||||
var m = [
|
||||
&10=Kio
|
||||
&20=Mio
|
||||
&30=Gio
|
||||
]
|
||||
while (< $u 30) {
|
||||
var p = (math:pow 2 (+ $u 10))
|
||||
if (< $size $p) {
|
||||
break
|
||||
}
|
||||
set u = (to-string (+ $u 10))
|
||||
}
|
||||
if (== $u 0) {
|
||||
put $size
|
||||
} else {
|
||||
var p = (math:pow 2 (+ $u 10))
|
||||
var e = (/ $size $p)
|
||||
printf '%.1f%s' $e $m[$u]
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue