Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: s2hms
Marc Chantreux wrote:
> you don't need the $data buffer as you can
> read directly in varibles. my (untested)
> version should be more like
local secs=${1?duration in seconds} it= out=
unknown file attribute
Also, what's with the strange chars: \240 two times?
> s2hms () {
> # clean error message when no argument passed
> local secs=${1?duration in seconds} it= out=
> local -a fields=( h m s )
> local -A duration
>
> # duration\[$^fields] is a short for
> # duration\[h]duration\[m] duration\[s]
>
> units -t $secs\s hms |
> IFS=\; read duration\[$^fields]
>
>
> # use mathematical context to do math
> # also: a value is 0 or >0 so just test if it's >0
>
> for it ($fields)
> (( duration[it])) && out+="$duration[$it]$it"
>
> print $out
> }
--
underground experts united
http://user.it.uu.se/~embe8573
Messages sorted by:
Reverse Date,
Date,
Thread,
Author