diff options
author | Kjetil Ørbekk <kj@orbekk.com> | 2020-10-18 13:59:23 +0000 |
---|---|---|
committer | KJ Oerbekk <orbekk@google.com> | 2020-10-18 14:00:30 +0000 |
commit | 7952033da2d8a90cb0f9a30150cf6a45c6492b8d (patch) | |
tree | 1e223e4cdbaa440c27ba535ff9e75d3abe2d571b /old/config/fish/functions/__format_time.fish | |
parent | 5441276b4545772d62fe21aef542f57ab646125b (diff) |
Remove unused dotfiles
Diffstat (limited to 'old/config/fish/functions/__format_time.fish')
-rw-r--r-- | old/config/fish/functions/__format_time.fish | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/old/config/fish/functions/__format_time.fish b/old/config/fish/functions/__format_time.fish new file mode 100644 index 0000000..298e4cb --- /dev/null +++ b/old/config/fish/functions/__format_time.fish @@ -0,0 +1,27 @@ +function __format_time -d "Format milliseconds to a human readable format" + set -l milliseconds $argv[1] + set -l seconds (math "$milliseconds / 1000 % 60") + set -l minutes (math "$milliseconds / 60000 % 60") + set -l hours (math "$milliseconds / 3600000 % 24") + set -l days (math "$milliseconds / 86400000") + set -l time + set -l threshold 5 + + if test $days -gt 0 + set time (command printf "$time%sd " $days) + end + + if test $hours -gt 0 + set time (command printf "$time%sh " $hours) + end + + if test $minutes -gt 0 + set time (command printf "$time%sm " $minutes) + end + + if test $seconds -gt $threshold + set time (command printf "$time%ss " $seconds) + end + + echo -e $time +end |