mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Improve timer string
This commit is contained in:
parent
733d6c8c7b
commit
6b006e78e5
@ -198,10 +198,15 @@ const ProgressText = (props: Stylable) => {
|
||||
);
|
||||
};
|
||||
|
||||
const toTimerString = (timer?: number, duration?: number) => {
|
||||
export const toTimerString = (timer?: number, duration?: number) => {
|
||||
if (!duration) duration = timer;
|
||||
if (timer === undefined || duration === undefined || isNaN(duration) || isNaN(timer))
|
||||
return "??:??";
|
||||
if (duration >= 3600) return new Date(timer * 1000).toISOString().substring(11, 19);
|
||||
return new Date(timer * 1000).toISOString().substring(14, 19);
|
||||
const h = Math.floor(timer / 3600);
|
||||
const min = Math.floor((timer / 60) % 60);
|
||||
const sec = Math.round(timer % 60);
|
||||
const fmt = (n: number) => n.toString().padStart(2, "0");
|
||||
|
||||
if (duration >= 3600) return `${fmt(h)}:${fmt(min)}:${fmt(sec)}`;
|
||||
return `${fmt(min)}:${fmt(sec)}`;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user