Feat: Convert hours > 24 to days

pull/3462/head
poolitzer 2024-06-19 21:46:04 +02:00
parent 75a26826f3
commit 54b1f3fcd7
1 changed files with 7 additions and 3 deletions

View File

@ -118,8 +118,10 @@ function batteryString(){
if (settings.batt_hours) { if (settings.batt_hours) {
var batt_usage = 200000/E.getPowerUsage().total; var batt_usage = 200000/E.getPowerUsage().total;
let rounded; let rounded;
if (batt_usage > 99) { if (batt_usage > 24) {
rounded = Math.round(batt_usage); var days = Math.floor(batt_usage/24);
var hours = Math.round((batt_usage/24 - days) * 24);
stringToInsert = '\n' + days + ((days < 2) ? 'd' : 'ds') + ' ' + hours + ((hours < 2) ? 'h' : 'hs');
} }
else if (batt_usage > 9) { else if (batt_usage > 9) {
rounded = Math.round(200000/E.getPowerUsage().total * 10) / 10; rounded = Math.round(200000/E.getPowerUsage().total * 10) / 10;
@ -127,8 +129,10 @@ function batteryString(){
else { else {
rounded = Math.round(200000/E.getPowerUsage().total * 100) / 100; rounded = Math.round(200000/E.getPowerUsage().total * 100) / 100;
} }
if (batt_usage < 24) {
stringToInsert = '\n' + rounded + ' ' + ((batt_usage < 2) ? 'h' : 'hs'); stringToInsert = '\n' + rounded + ' ' + ((batt_usage < 2) ? 'h' : 'hs');
} }
}
else{ else{
stringToInsert = ' ' + E.getBattery() + '%'; stringToInsert = ' ' + E.getBattery() + '%';
} }