diff options
author | Regis <boudinot.regis@yahoo.com> | 2017-01-09 11:25:30 -0700 |
---|---|---|
committer | Regis <boudinot.regis@yahoo.com> | 2017-01-09 11:25:30 -0700 |
commit | cf84c09ad270dae9a31d80d57588e5b7023454d4 (patch) | |
tree | b41ae3e47e7a210922a009a307eb1c931d51a322 | |
parent | 6625f479f857aefde855f45d3e2c820bfbb872e3 (diff) | |
download | gitlab-ce-cf84c09ad270dae9a31d80d57588e5b7023454d4.tar.gz |
format duration in vue: time_ago computed property in a dynamic fashion
-rw-r--r-- | app/assets/javascripts/vue_pipelines_index/time_ago.js.es6 | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/app/assets/javascripts/vue_pipelines_index/time_ago.js.es6 b/app/assets/javascripts/vue_pipelines_index/time_ago.js.es6 index 7e6d17d4e13..655110feba1 100644 --- a/app/assets/javascripts/vue_pipelines_index/time_ago.js.es6 +++ b/app/assets/javascripts/vue_pipelines_index/time_ago.js.es6 @@ -31,8 +31,17 @@ }, duration() { const { duration } = this.pipeline.details; - if (duration === 0) return '00:00:00'; - if (duration !== null) return duration; + const date = new Date(duration * 1000); + + let hh = date.getUTCHours(); + let mm = date.getUTCMinutes(); + let ss = date.getSeconds(); + + if (hh < 10) hh = `0${hh}`; + if (mm < 10) mm = `0${mm}`; + if (ss < 10) ss = `0${ss}`; + + if (duration !== null) return `${hh}:${mm}:${ss}`; return false; }, }, |