From ca29df97ea91e777b87fdf59dc22e526d00f858b Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Fri, 26 Sep 2025 22:02:43 +0200 Subject: [PATCH] Add hours Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- front/src/lib/utils.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/front/src/lib/utils.ts b/front/src/lib/utils.ts index fb8be92..1186da3 100644 --- a/front/src/lib/utils.ts +++ b/front/src/lib/utils.ts @@ -21,20 +21,27 @@ export function convertNanoSeconds(nanoseconds: number): string { const ONE_MS_IN_NS = 1e6; const ONE_S_IN_NS = 1e9; const ONE_MIN_IN_NS = 6e10; + const ONE_HOUR_IN_NS = 3.6e12; if (nanoseconds < ONE_MS_IN_NS) { - return `${nanoseconds} ns`; // Garde la sortie en ns pour les très petites valeurs + return `${nanoseconds} ns`; } else if (nanoseconds < ONE_S_IN_NS) { const ms = Math.round(nanoseconds / ONE_MS_IN_NS); return `${ms} ms`; } else if (nanoseconds < ONE_MIN_IN_NS) { const s = Math.round(nanoseconds / ONE_S_IN_NS); return `${s} s`; - } else { + } else if (nanoseconds < ONE_HOUR_IN_NS) { const totalSeconds = Math.round(nanoseconds / ONE_S_IN_NS); const minutes = Math.floor(totalSeconds / 60); const seconds = totalSeconds % 60; return `${minutes}m${seconds}s`; + } else { + const totalMinutes = Math.round(nanoseconds / ONE_MIN_IN_NS); + const hours = Math.floor(totalMinutes / 60); + const minutes = totalMinutes % 60; + + return `${hours}h${minutes}m`; } }