mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
fix: game session duration calculation
This commit is contained in:
parent
e092d701b4
commit
f019820458
@ -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,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -53,7 +53,7 @@ export function useDate() {
|
||||
}
|
||||
},
|
||||
|
||||
formatDistanceInMillis: (
|
||||
formatDiffInMillis: (
|
||||
millis: number,
|
||||
baseDate: string | number | Date,
|
||||
options?: FormatDistanceOptions
|
||||
|
@ -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({
|
||||
</div>
|
||||
<small>
|
||||
{t("playing_for", {
|
||||
amount: formatDistanceInMillis(
|
||||
amount: formatDiffInMillis(
|
||||
runningGame.sessionDurationInMillis,
|
||||
new Date().getTime()
|
||||
new Date()
|
||||
),
|
||||
})}
|
||||
</small>
|
||||
|
Loading…
Reference in New Issue
Block a user