Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readable time output #66

Merged
merged 1 commit into from
Jul 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/commands/run.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ function _zunit_run_usage() {
# Format a ms timestamp in a human-readable format
###
function _zunit_human_time() {
local ms=$1
local tmp=$(( $1 / 1000 ))
local days=$(( tmp / 60 / 60 / 24 ))
local hours=$(( tmp / 60 / 60 % 24 ))
local minutes=$(( tmp / 60 % 60 ))
local seconds=$(( tmp % 60 ))
local ms=$(( $1 % 1000 ))
(( $days > 0 )) && print -n "${days}d "
(( $hours > 0 )) && print -n "${hours}h "
(( $minutes > 0 )) && print -n "${minutes}m "
(( $seconds > 5 )) && print -n "${seconds}s "
(( $seconds < 30 )) && (( $seconds > 5 )) && print -n "$(( ms - $((seconds*1000)) ))ms"
(( $tmp <= 5 )) && print -n "${1}ms"
(( $seconds < 30 )) && (( $seconds > 5 )) && print -n "${ms}ms"
(( $seconds <= 5 )) && print -n "${1}ms"
}

###
Expand Down