aboutsummaryrefslogtreecommitdiff
path: root/core/lib
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-03-12 09:02:24 +0100
committerlonkaars <loek@pipeframe.xyz>2024-03-12 09:02:24 +0100
commitd3b396b17602ad71a62cbc2eaf595a1d94579c4a (patch)
tree3be5e49c5d9081ac3de4cd34b64b47ada23e9a22 /core/lib
parente6c1cacb60010ec75e02cf72acf34278417670fd (diff)
make state update atomic and clean up some code
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
+# }
+