Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
s2hms
- X-seq: zsh-users 22944
- From: Emanuel Berg <moasen@xxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: s2hms
- Date: Thu, 19 Oct 2017 00:21:55 +0200
- Cancel-lock: sha1:eMjQ8ObIcX387DxGzc35DrYABgY=
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mail-copies-to: never
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
I just wrote a small interface to units(1).
Does it look good to you?
Try for example
$ s2hms 500
8m 20s
Sounds about right...
s2hms () {
local secs=$1
local time_string
time_string=$(units -t "$secs s" hms)
local -a data
data=("${(@s/;/)time_string}")
local h=$data[1]
local m=$data[2]
local s=$data[3]
local out
[[ $h > 0 ]] && out ="${h}h "
[[ $m > 0 ]] && out+="${m}m "
[[ $s > 0 ]] && out+="${s}s"
echo $out
}
--
underground experts united
http://user.it.uu.se/~embe8573
Messages sorted by:
Reverse Date,
Date,
Thread,
Author