Skip to content

Commit

Permalink
fix: leaderboard decimal places
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 authored Feb 29, 2024
1 parent f5c03b5 commit 8de4c43
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const getFormattedTime = (milliseconds: number | undefined, precise = tru
const totalSeconds = milliseconds / 1000;
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = precise ? (totalSeconds % 60).toFixed(3) : Math.floor(totalSeconds % 60);
const seconds = totalSeconds % 60;

let formattedTime = '';
if (hours) {
Expand All @@ -16,7 +16,7 @@ export const getFormattedTime = (milliseconds: number | undefined, precise = tru
if (!precise && (hours || minutes)) {
return formattedTime;
}
formattedTime += `${seconds}s`;
formattedTime += `${minutes >= 1 ? Math.floor(seconds) : seconds.toFixed(3)}s`;

return formattedTime;
};

0 comments on commit 8de4c43

Please sign in to comment.