mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-14 20:22:10 +00:00
feat: format play time in hours
This commit is contained in:
parent
f38f574d04
commit
1569c3eb73
1 changed files with 11 additions and 1 deletions
|
@ -62,12 +62,22 @@ export function HeroPanel({
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
updateLastTimePlayed();
|
updateLastTimePlayed();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
const formatPlayTime = (milliseconds: number) => {
|
||||||
|
const seconds = milliseconds / 1000
|
||||||
|
const minutes = seconds / 60
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [game?.lastTimePlayed, updateLastTimePlayed]);
|
}, [game?.lastTimePlayed, updateLastTimePlayed]);
|
||||||
|
if (minutes < 120) {
|
||||||
|
return minutes.toFixed(0) + " " + t("minutes")
|
||||||
|
}
|
||||||
|
|
||||||
|
const hours = minutes / 60
|
||||||
|
return hours.toFixed(0) + " " + t("hours")
|
||||||
|
}
|
||||||
|
|
||||||
const finalDownloadSize = useMemo(() => {
|
const finalDownloadSize = useMemo(() => {
|
||||||
if (!game) return "N/A";
|
if (!game) return "N/A";
|
||||||
|
@ -136,7 +146,7 @@ export function HeroPanel({
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
{t("play_time", {
|
{t("play_time", {
|
||||||
amount: formatDistance(0, game.playTimeInMilliseconds),
|
amount: formatPlayTime(game.playTimeInMilliseconds),
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue