mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
feat: format play time in hours
This commit is contained in:
@@ -62,12 +62,22 @@ export function HeroPanel({
|
||||
const interval = setInterval(() => {
|
||||
updateLastTimePlayed();
|
||||
}, 1000);
|
||||
const formatPlayTime = (milliseconds: number) => {
|
||||
const seconds = milliseconds / 1000
|
||||
const minutes = seconds / 60
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}
|
||||
}, [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(() => {
|
||||
if (!game) return "N/A";
|
||||
@@ -136,7 +146,7 @@ export function HeroPanel({
|
||||
<>
|
||||
<p>
|
||||
{t("play_time", {
|
||||
amount: formatDistance(0, game.playTimeInMilliseconds),
|
||||
amount: formatPlayTime(game.playTimeInMilliseconds),
|
||||
})}
|
||||
</p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user