fix: game session duration calculation

This commit is contained in:
Zamitto 2024-06-20 11:48:26 -03:00
parent e092d701b4
commit f019820458
3 changed files with 5 additions and 5 deletions

View File

@ -96,7 +96,7 @@ export const watchProcesses = async () => {
const runningGames = Array.from(gamesPlaytime.entries()).map((entry) => { const runningGames = Array.from(gamesPlaytime.entries()).map((entry) => {
return { return {
id: entry[0], id: entry[0],
sessionDurationInMillis: entry[1].firstTick - performance.now(), sessionDurationInMillis: performance.now() - entry[1].firstTick,
}; };
}); });

View File

@ -53,7 +53,7 @@ export function useDate() {
} }
}, },
formatDistanceInMillis: ( formatDiffInMillis: (
millis: number, millis: number,
baseDate: string | number | Date, baseDate: string | number | Date,
options?: FormatDistanceOptions options?: FormatDistanceOptions

View File

@ -42,7 +42,7 @@ export function UserContent({
}); });
}, [i18n.language]); }, [i18n.language]);
const { formatDistance, formatDistanceInMillis } = useDate(); const { formatDistance, formatDiffInMillis } = useDate();
const formatPlayTime = () => { const formatPlayTime = () => {
const seconds = userProfile.libraryGames.reduce( const seconds = userProfile.libraryGames.reduce(
@ -160,9 +160,9 @@ export function UserContent({
</div> </div>
<small> <small>
{t("playing_for", { {t("playing_for", {
amount: formatDistanceInMillis( amount: formatDiffInMillis(
runningGame.sessionDurationInMillis, runningGame.sessionDurationInMillis,
new Date().getTime() new Date()
), ),
})} })}
</small> </small>