Finally simplify the time calculations!

According to

   http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html

a shell must be able to do modulus (=remainder). Zsh, bash and dash
confirm this and thus I can save another line and get rid of a very
ugly one.

Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
This commit is contained in:
Nico Schottelius 2009-11-01 16:15:00 +01:00
parent 545158b56f
commit f630bef3b5

View file

@ -560,14 +560,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do
fi fi
fi fi
# Calculation #
# Time calculation
#
end_s="$(${SDATE})" end_s="$(${SDATE})"
full_seconds="$((${end_s} - ${begin_s}))" full_seconds="$((${end_s} - ${begin_s}))"
hours="$((${full_seconds} / 3600))" hours="$((${full_seconds} / 3600))"
seconds="$((${full_seconds} - (${hours} * 3600)))" minutes="$(((${full_seconds} % 3600) / 60))"
minutes="$((${seconds} / 60))" seconds="$((${full_seconds} % 60))"
seconds="$((${seconds} - (${minutes} * 60)))"
_techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)"
) | add_name ) | add_name