Duffer Derek

Current Path : /var/www/api-mk-planner.bitkit.dk/httpdocs/Frontend/src/utils/
Upload File :
Current File : /var/www/api-mk-planner.bitkit.dk/httpdocs/Frontend/src/utils/calculateSubtaskTotal.js

const calculateSubtaskTotal = (subtasksOnDay) => {
    return subtasksOnDay.reduce((subtaskTotal, subtask) => {
        // Remove leading zeros from time value
        const timeWithoutLeadingZeros = subtask.time.replace(/^0+/, "");
        // Split the time into hours and minutes
        const [hours, minutes] = timeWithoutLeadingZeros.split(":").map(Number);
        // Calculate the total time in hours with one decimal point
        const totalTimeInHours = parseFloat((hours + minutes / 60).toFixed(1));
        return subtaskTotal + totalTimeInHours;
    }, 0); // Convert the total to have one decimal point
};
export default calculateSubtaskTotal;

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists