Add a helper function for processing a unix timestamp
This commit is contained in:
parent
9c9b1231bd
commit
dda262bddb
1 changed files with 26 additions and 0 deletions
26
rowbot
26
rowbot
|
@ -100,6 +100,32 @@ run_callbacks() {
|
|||
return "$status"
|
||||
}
|
||||
|
||||
# The variables are checked dynamically
|
||||
# shellcheck disable=SC2034
|
||||
seconds() {
|
||||
local day hour minute second span time
|
||||
(( day = $1 / 60 / 60 / 24 ))
|
||||
(( hour = $1 / 60 / 60 % 24 ))
|
||||
(( minute = $1 / 60 % 60 ))
|
||||
(( second = $1 % 60 ))
|
||||
|
||||
for span in day hour minute second; do
|
||||
if (( ${!span} )); then
|
||||
if [[ $time ]]; then
|
||||
time+=", "
|
||||
fi
|
||||
|
||||
time+="${!span} $span"
|
||||
|
||||
if (( ${!span} > 1 )); then
|
||||
time+=s
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
printf -- %s "$time"
|
||||
}
|
||||
|
||||
url() {
|
||||
if [[ ${config[tls]} = no ]]; then
|
||||
printf irc://
|
||||
|
|
Loading…
Reference in a new issue