aboutsummaryrefslogtreecommitdiff
path: root/core/lib
diff options
context:
space:
mode:
Diffstat (limited to 'core/lib')
-rw-r--r--core/lib19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/lib b/core/lib
index 9892663..21c64f9 100644
--- a/core/lib
+++ b/core/lib
@@ -16,3 +16,22 @@ err() {
# debug:
# bc() { tee /dev/stderr | /usr/bin/bc ; }
+fmt_time() {
+ ss="$(echo "$1 / 1" | bc)"
+ mm="$(echo "$ss / 60" | bc)"
+ ss="$(echo "$ss % 60" | bc)"
+ hh="$(echo "$mm / 60" | bc)"
+ mm="$(echo "$mm % 60" | bc)"
+ _time_fmt
+}
+
+_time_fmt() { # [HH:]MM:SS
+ [ $hh -gt 0 ] && printf '%02d:' $hh
+ printf "%02d:%02d\n" $mm $ss
+}
+
+# _time_fmt() { # [HHh]MMmSSs
+# [ $hh -gt 0 ] && printf '%02dh' $hh
+# printf "%02dm%02ds\n" $mm $ss
+# }
+