diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-06-12 12:20:19 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-06-12 12:20:19 +0300 |
commit | 452202e36d3e20755b099a718a92d3f7b80fabb8 (patch) | |
tree | 5cc8bd9c5d810a645f44f515c4310731fa01785f /app/assets/javascripts/lib | |
parent | d25f6fcf629bd773ccac49a799393479c48f4673 (diff) |
Improve Job detail view to make it refreshed in real-time instead of reloading
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/datetime_utility.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/datetime_utility.js b/app/assets/javascripts/lib/utils/datetime_utility.js index 40eadd9396c..54c0da3fc9c 100644 --- a/app/assets/javascripts/lib/utils/datetime_utility.js +++ b/app/assets/javascripts/lib/utils/datetime_utility.js @@ -146,3 +146,24 @@ window.dateFormat = dateFormat; }; })(window); }).call(window); + +/** + * Port of ruby helper time_interval_in_words. + * + * @param {Number} seconds + * @return {String} + */ +// eslint-disable-next-line import/prefer-default-export +export function timeIntervalInWords(intervalInSeconds) { + const secondsInteger = parseInt(intervalInSeconds, 10); + const minutes = Math.floor(secondsInteger / 60); + const seconds = secondsInteger - (minutes * 60); + let text = ''; + + if (minutes >= 1) { + text = `${minutes} ${gl.text.pluralize('minute', minutes)} ${seconds} ${gl.text.pluralize('second', seconds)}`; + } else { + text = `${seconds} ${gl.text.pluralize('second', seconds)}`; + } + return text; +} |