Skip to content

Commit

Permalink
fix: game session duration calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
zamitto committed Jun 20, 2024
1 parent e092d70 commit f019820
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/services/process-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
});

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/hooks/use-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function useDate() {
}
},

formatDistanceInMillis: (
formatDiffInMillis: (
millis: number,
baseDate: string | number | Date,
options?: FormatDistanceOptions
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/src/pages/user/user-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function UserContent({
});
}, [i18n.language]);

const { formatDistance, formatDistanceInMillis } = useDate();
const { formatDistance, formatDiffInMillis } = useDate();

const formatPlayTime = () => {
const seconds = userProfile.libraryGames.reduce(
Expand Down Expand Up @@ -160,9 +160,9 @@ export function UserContent({
</div>
<small>
{t("playing_for", {
amount: formatDistanceInMillis(
amount: formatDiffInMillis(
runningGame.sessionDurationInMillis,
new Date().getTime()
new Date()
),
})}
</small>
Expand Down

0 comments on commit f019820

Please sign in to comment.