diff --git a/src/main/services/process-watcher.ts b/src/main/services/process-watcher.ts index b17a594f..5bc81d26 100644 --- a/src/main/services/process-watcher.ts +++ b/src/main/services/process-watcher.ts @@ -96,7 +96,7 @@ export const watchProcesses = async () => { const runningGames = Array.from(gamesPlaytime.entries()).map((entry) => { return { id: entry[0], - sessionDurationInMillis: entry[1].firstTick - performance.now(), + sessionDurationInMillis: performance.now() - entry[1].firstTick, }; }); diff --git a/src/renderer/src/hooks/use-date.ts b/src/renderer/src/hooks/use-date.ts index 9b60a4a0..01f55610 100644 --- a/src/renderer/src/hooks/use-date.ts +++ b/src/renderer/src/hooks/use-date.ts @@ -53,7 +53,7 @@ export function useDate() { } }, - formatDistanceInMillis: ( + formatDiffInMillis: ( millis: number, baseDate: string | number | Date, options?: FormatDistanceOptions diff --git a/src/renderer/src/pages/user/user-content.tsx b/src/renderer/src/pages/user/user-content.tsx index 31e68328..98aad705 100644 --- a/src/renderer/src/pages/user/user-content.tsx +++ b/src/renderer/src/pages/user/user-content.tsx @@ -42,7 +42,7 @@ export function UserContent({ }); }, [i18n.language]); - const { formatDistance, formatDistanceInMillis } = useDate(); + const { formatDistance, formatDiffInMillis } = useDate(); const formatPlayTime = () => { const seconds = userProfile.libraryGames.reduce( @@ -160,9 +160,9 @@ export function UserContent({ {t("playing_for", { - amount: formatDistanceInMillis( + amount: formatDiffInMillis( runningGame.sessionDurationInMillis, - new Date().getTime() + new Date() ), })}