From: Jérôme Benoit Date: Sat, 18 Sep 2021 11:16:32 +0000 (+0200) Subject: Simplify calculation at duration formatting X-Git-Tag: v1.1.3~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d10397af9d19f1607a187c749eefd160c9ef7392;p=e-mobility-charging-stations-simulator.git Simplify calculation at duration formatting Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index fb5c88c5..f6565cc5 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -20,8 +20,8 @@ export default class Utils { public static formatDurationMilliSeconds(duration: number): string { duration = Utils.convertToInt(duration); const hours = Math.floor(duration / (3600 * 1000)); - const minutes = Math.floor((duration - (hours * (3600 * 1000))) / (60 * 1000)); - const seconds = (duration - (hours * 3600 * 1000) - (minutes * 60 * 1000)) / 1000; + const minutes = Math.floor((duration / 1000 - (hours * 3600)) / 60); + const seconds = duration / 1000 - (hours * 3600) - (minutes * 60); let hoursStr: string = hours.toString(); let minutesStr: string = minutes.toString(); let secondsStr: string = seconds.toString();