optimised the frontend method that handles the display of transition times in HH:MM format

This commit is contained in:
lrdossan 2024-08-02 11:22:14 +02:00
parent 0d035aad05
commit e476c671d1

View file

@ -283,17 +283,13 @@ function validateCO2Form() {
}
function displayTransitionTimesHourFormat(start, stop) {
var minutes_start = ((start % 1) * 60).toPrecision(2);
var minutes_stop = ((stop % 1) * 60).toPrecision(2);
return (
Math.floor(start) +
":" +
(minutes_start != "0.0" ? minutes_start : "00") +
" - " +
Math.floor(stop) +
":" +
(minutes_stop != "0.0" ? minutes_stop : "00")
);
const formatTime = (time) => {
const hours = Math.floor(time);
const minutes = Math.round((time % 1) * 60);
return `${hours}:${minutes.toString().padStart(2, '0')}`;
};
return `${formatTime(start)} - ${formatTime(stop)}`;
}
function displayFittingData(json_response) {