[UI] Added formatDuration utility.

This commit is contained in:
Fabio Manganiello 2024-10-14 21:46:49 +02:00
parent 117dfad64e
commit 4f81a73fb9
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 19 additions and 0 deletions

View file

@ -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;

View file

@ -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>