+# Convert UNIX time stamp to date text.
+time_t_to_date() {
+ t="$1"
+ shift
+ if ! date -d @"$t" "$@" 2>/dev/null; then
+ # "date -d @<time_t>" (GNU variant) failed!
+ date -r "$t" "$@"
+ fi
+}
+
+time_t_to_duration() {
+ s="$1"
+ if [[ "$s" -ge 60 ]]; then
+ m=$((s / 60))
+ s=$((s % 60))
+ if [[ "$m" -ge 60 ]]; then
+ h=$((m / 60))
+ m=$((m % 60))
+ if [[ "$h" -ge 24 ]]; then
+ d=$((h / 24))
+ h=$((h % 24))
+ echo "${d}d${2}${h}h${2}${m}m${2}${s}s"
+ else
+ echo "${h}h${2}${m}m${2}${s}s"
+ fi
+ else
+ echo "${m}m${2}${s}s"
+ fi
+ else
+ echo "${s}s"
+ fi
+}
+