mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-03 18:24:12 +02:00
jsx/solid bundle
This commit is contained in:
parent
bffa6e81d9
commit
10ea8ddcbc
16 changed files with 458 additions and 44 deletions
18
script/time.ts
Normal file
18
script/time.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
export function formatDuration(input: number): string {
|
||||
if (!input) {
|
||||
return '0:00';
|
||||
}
|
||||
const hours = Math.floor(input / 3600);
|
||||
const minutes = Math.floor((input - (hours * 3600)) / 60);
|
||||
const seconds = Math.floor(input - (hours * 3600) - (minutes * 60));
|
||||
|
||||
const hourString = (hours < 10) ? "0" + hours : "" + hours;
|
||||
const minuteString = (minutes < 10) ? "0" + minutes : "" + minutes;
|
||||
const secondString = (seconds < 10) ? "0" + seconds : "" + seconds;
|
||||
|
||||
if (hourString !== '00') {
|
||||
return hourString + ':' + minuteString + ':' + secondString;
|
||||
} else {
|
||||
return minuteString + ':' + secondString;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue