aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/ui.js')
-rw-r--r--src/js/ui.js26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/js/ui.js b/src/js/ui.js
index 1ad0c43a..d5d224a1 100644
--- a/src/js/ui.js
+++ b/src/js/ui.js
@@ -293,33 +293,15 @@ const ui = {
// Update the displayed time
updateTimeDisplay(target = null, time = 0, inverted = false) {
// Bail if there's no element to display or the value isn't a number
- if (!utils.is.element(target) || !utils.is.number(time)) {
+ if (!utils.is.element(target)) {
return;
}
- // Format time component to add leading zero
- const format = value => `0${value}`.slice(-2);
-
- // Helpers
- const getHours = value => parseInt((value / 60 / 60) % 60, 10);
- const getMinutes = value => parseInt((value / 60) % 60, 10);
- const getSeconds = value => parseInt(value % 60, 10);
-
- // Breakdown to hours, mins, secs
- let hours = getHours(time);
- const mins = getMinutes(time);
- const secs = getSeconds(time);
-
- // Do we need to display hours?
- if (getHours(this.duration) > 0) {
- hours = `${hours}:`;
- } else {
- hours = '';
- }
+ // Always display hours if duration is over an hour
+ const displayHours = utils.getHours(this.duration) > 0;
- // Render
// eslint-disable-next-line no-param-reassign
- target.textContent = `${inverted ? '-' : ''}${hours}${format(mins)}:${format(secs)}`;
+ target.textContent = utils.formatTime(time, displayHours, inverted);
},
// Handle time change event