fix: update exit time handling in calculateDay function to ensure proper assignment

This commit is contained in:
2025-10-30 18:21:33 +01:00
parent e84a700a8b
commit 9bb7a71d86

View File

@@ -153,14 +153,24 @@ function calculateDay(day) {
// const exitTimes = [...day.exitTime]
// If there's one more entry than exits, it means the user is currently clocked in.
if (day.entryTime.length > 0 && day.entryTime.length === day.exitTime.length + 1) {
const now = new Date()
const hh = String(now.getHours()).padStart(2, '0')
const mm = String(now.getMinutes()).padStart(2, '0')
const ss = String(now.getSeconds()).padStart(2, '0')
// Add the current time as the "exit" for the last entry.
day.exitTime.push(`${hh}:${mm}:${ss}`)
for (let i = 0; i < day.entryTime.length; i++) {
if (!day.exitTime[i] || typeof day.exitTime[i] !== 'string' || day.exitTime[i].trim() === '') {
const now = new Date()
const hh = String(now.getHours()).padStart(2, '0')
const mm = String(now.getMinutes()).padStart(2, '0')
const ss = String(now.getSeconds()).padStart(2, '0')
day.exitTime[i] = `${hh}:${mm}:${ss}`
}
}
// if (day.entryTime.length > 0 && day.entryTime.length === day.exitTime.length + 1) {
// const now = new Date()
// const hh = String(now.getHours()).padStart(2, '0')
// const mm = String(now.getMinutes()).padStart(2, '0')
// const ss = String(now.getSeconds()).padStart(2, '0')
// // Add the current time as the "exit" for the last entry.
// day.exitTime.push(`${hh}:${mm}:${ss}`)
// }
if (day.entryTime.length === 0) {
day.workedHours = 0