diff options
author | Devaev Maxim <[email protected]> | 2020-06-20 11:29:06 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-06-20 11:29:06 +0300 |
commit | cf2f763d1bd23170cb82e0df9eff363931cc66dc (patch) | |
tree | 541f6cd3b498d2a6ccde3e0921639a588535fdba /web/share/js/tools.js | |
parent | 490e5b352ef569ef5b3f5211523d21bbd5ed0e1c (diff) |
user macro
Diffstat (limited to 'web/share/js/tools.js')
-rw-r--r-- | web/share/js/tools.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/web/share/js/tools.js b/web/share/js/tools.js index 8212b62f..e3fa3892 100644 --- a/web/share/js/tools.js +++ b/web/share/js/tools.js @@ -64,6 +64,17 @@ export var tools = new function() { } }; + this.formatDuration = function(duration) { + let millis = parseInt((duration % 1000) / 100); + let secs = Math.floor((duration / 1000) % 60); + let mins = Math.floor((duration / (1000 * 60)) % 60); + let hours = Math.floor((duration / (1000 * 60 * 60)) % 24); + hours = (hours < 10 ? "0" + hours : hours); + mins = (mins < 10 ? "0" + mins : mins); + secs = (secs < 10 ? "0" + secs : secs); + return `${hours}:${mins}:${secs}.${millis}`; + }; + /************************************************************************/ this.getCookie = function(name) { |