forked from platypush/platypush
[UI] Added formatDuration utility.
This commit is contained in:
parent
117dfad64e
commit
4f81a73fb9
2 changed files with 19 additions and 0 deletions
|
@ -205,3 +205,6 @@ $tile-hover-bg-2: linear-gradient(90deg, rgb(71, 226, 179) 0%, rgb(81, 186, 210)
|
||||||
$tile-hover-bg-3: linear-gradient(90deg, rgb(41, 216, 63) 0%, rgb(9, 188, 138) 120%);
|
$tile-hover-bg-3: linear-gradient(90deg, rgb(41, 216, 63) 0%, rgb(9, 188, 138) 120%);
|
||||||
$tile-keyword-fg: #f8ff00;
|
$tile-keyword-fg: #f8ff00;
|
||||||
$tile-code-fg: #2a5ab7;
|
$tile-code-fg: #2a5ab7;
|
||||||
|
|
||||||
|
//// Misc
|
||||||
|
$info-header-bg: #f2f7f5;
|
||||||
|
|
|
@ -35,6 +35,22 @@ export default {
|
||||||
|
|
||||||
return `${this.formatDate(date, year)}, ${this.formatTime(date, seconds)}`
|
return `${this.formatDate(date, year)}, ${this.formatTime(date, seconds)}`
|
||||||
},
|
},
|
||||||
|
|
||||||
|
formatDuration(duration, seconds=true) {
|
||||||
|
if (duration == null)
|
||||||
|
return ''
|
||||||
|
|
||||||
|
let hours = Math.floor(duration / 3600)
|
||||||
|
let minutes = Math.floor((duration % 3600) / 60)
|
||||||
|
let secs = duration % 60
|
||||||
|
|
||||||
|
if (hours > 0)
|
||||||
|
return `${hours}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`
|
||||||
|
else if (minutes > 0)
|
||||||
|
return `${minutes}:${secs.toString().padStart(2, '0')}`
|
||||||
|
else
|
||||||
|
return seconds ? `0:${secs.toString().padStart(2, '0')}` : `0:00`
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue