From 18b959ecc5bdb6fe45ad41ae64588c8b423a7590 Mon Sep 17 00:00:00 2001 From: Yannik Hampe Date: Tue, 8 Dec 2020 20:31:42 +0100 Subject: [PATCH] simplify chargeDecimalTime --- src/utils/general.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/general.js b/src/utils/general.js index 1a2461a..b0410f4 100644 --- a/src/utils/general.js +++ b/src/utils/general.js @@ -25,9 +25,7 @@ export default { chargeDecimalTime(car, socDisplay, socBMS, batteryPower) { const capacity = cars[car].CAPACITY; const soc = socDisplay || socBMS; - const amountToCharge = capacity - parseFloat( - capacity * ((soc === 100) ? 1 : '0.' + ((soc < 10) ? ('0' + parseInt(soc)) : parseInt(soc))) - ).toFixed(2) || 0; + const amountToCharge = capacity * (1 - (soc / 100)) || 0; const decimalTime = parseFloat( amountToCharge / (Math.abs(batteryPower) || cars[car].FAST_SPEED) ).toFixed(2);