mirror of
https://github.com/brmlab/BLIT.git
synced 2025-06-07 03:14:00 +02:00
seconds_to_time.sh added
This commit is contained in:
parent
36735dfaa2
commit
d32a9cb746
1 changed files with 15 additions and 0 deletions
15
seconds_to_time.sh
Executable file
15
seconds_to_time.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
function displaytime {
|
||||
local T=$1
|
||||
local D=$((T/60/60/24))
|
||||
local H=$((T/60/60%24))
|
||||
local M=$((T/60%60))
|
||||
local S=$((T%60))
|
||||
[[ $D > 0 ]] && printf '%d days ' $D
|
||||
[[ $H > 0 ]] && printf '%d hours ' $H
|
||||
[[ $M > 0 ]] && printf '%d minutes ' $M
|
||||
[[ $D > 0 || $H > 0 || $M > 0 ]] && printf 'and '
|
||||
printf '%d seconds\n' $S
|
||||
}
|
||||
displaytime $1
|
Loading…
Add table
Add a link
Reference in a new issue