Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Fix for MQTT remaining time 1 day+ #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Components/Stats/TimeStat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ const getTotalSeconds = (
result = parseInt(timeEntity.state) || 0;
} else {
if(timeEntity.state){
const [hours, minutes, seconds] = timeEntity.state.split(':');
result = (+hours) * 60 * 60 + (+minutes) * 60 + (+seconds);
if(timeEntity.state.includes(", ")){
const [days_string, time_string] = timeEntity.state.split(', ');
const [hours, minutes, seconds] = time_string.split(':');
const days = days_string.match(/\d+/)[0];
result = (+days) * 60 * 60 * 24 + (+hours) * 60 * 60 + (+minutes) * 60 + (+seconds);
} else {
const [hours, minutes, seconds] = timeEntity.state.split(':');
result = (+hours) * 60 * 60 + (+minutes) * 60 + (+seconds);
}

} else {
result = 0;
Expand Down