# Function to calculate elapsed build time. runtime takes the $SECONDS variable as an argument. $SECONDS is an
# environment variable set by bash to show the number of whole seconds the shell has been running.
runtime() {
   [ -z "$1" ] && return 1

   local D=$(( $1 / 86400 ))
   local H=$(( ($1 - ($D * 86400)) / 3600 ))
   local M=$(( ($1 - ($D * 86400) - ($H * 3600)) / 60 ))
   local S=$(( $1 - ($D * 86400) - ($H * 3600) - ($M * 60) ))

   if [ "$D" -gt "0" ]; then
     echo -n "${D}d, ${H}h ${M}m ${S}s"
   else
     echo -n "${H}h, ${M}m ${S}s"
   fi
   return 0
}

