diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-11 19:52:05 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-11 19:52:05 +0200 |
commit | 6e57b6d76c25968bb66f11a655c3bd1d20c33041 (patch) | |
tree | d3c10997ba9eec4f8d7ad5ec6bc8bad6ac1cf9bd /.local/share/bin/timesum | |
parent | 3bb5f72a369cb2825a2d68e536103470b7426d58 (diff) |
add more time.txt scripts
Diffstat (limited to '.local/share/bin/timesum')
-rwxr-xr-x | .local/share/bin/timesum | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/.local/share/bin/timesum b/.local/share/bin/timesum index 448515d..6284ca4 100755 --- a/.local/share/bin/timesum +++ b/.local/share/bin/timesum @@ -1,58 +1,4 @@ #!/bin/sh -grep -o '\<\([0-9]\+h\)\?\([0-9]\{1,2\}m\)\?\([0-9]\{1,2\}s\)\?\>' "$@" |\ - awk ' -BEGIN { - sum = 0 -} - -{ - temp = 0 - num = 0 - multiplier = 60 - - split($0, char, "") - for (i=1; i <= length($0); i++) { - if (char[i] == "h") { - temp += num * 60 * 60 - multiplier = 60 - num = 0 - continue - } - if (char[i] == "m") { - temp += num * 60 - multiplier = 1 - num = 0 - continue - } - if (char[i] == "s") { - temp += num - multiplier = 0 - num = 0 - continue - } - - num *= 10 - num += char[i] - } - if (num > 0) { - temp += num * multiplier - } - - # printf("%10s -> %d\n", $0, temp) - sum += temp -} - -END { - seconds = sum % 60 - sum = (sum - seconds) / 60 - minutes = sum % 60 - sum = (sum - minutes) / 60 - hours = sum - - if (hours > 0) printf("%dh", hours) - printf("%02dm", minutes) - if (seconds > 0) printf("%02ds", seconds) - printf("\n") -} -' +TAB="$(printf '\t')" +time2tsv "$@" | cut -d"$TAB" -f3 | paste -sd+ - | bc | timefmt |