Skip to content

Commit 2b53dd6

Browse files
committed
timetable - changed time slot calculation to for end of day at 00:00
1 parent 92139ee commit 2b53dd6

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

library/src/components/timetable/timeTableUtils.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ function calculateTimeSlotsHoursView(
3535
startDate: Dayjs,
3636
) {
3737
if (!Number.isFinite(timeSlotsPerDay)) {
38+
console.log(
39+
"TimeTable - timeSlotsPerDay is not finite",
40+
timeSlotsPerDay,
41+
)
42+
return null
43+
}
44+
45+
if (daysDifference <= 0) {
46+
console.log(
47+
"TimeTable - daysDifference is not greater than 0",
48+
daysDifference,
49+
)
3850
return null
3951
}
4052

@@ -113,7 +125,8 @@ function calculateTimeSlotPropertiesForHoursView(
113125
)
114126
return { timeFrameDay, slotsArray: [], timeSlotMinutes: 0 }
115127
}
116-
if (endDate.hour() > 0 || (endDate.hour() === 0 && endDate.minute() > 0)) {
128+
//if (endDate.hour() > 0 || (endDate.hour() === 0 && endDate.minute() > 0)) {
129+
if (daysDifference === 0) {
117130
daysDifference++
118131
}
119132

@@ -131,22 +144,20 @@ function calculateTimeSlotPropertiesForHoursView(
131144
return { timeFrameDay, slotsArray: [], timeSlotMinutes: 0 }
132145
}
133146

134-
let endDateUsed = endDate
135-
if (endDateUsed.hour() === 0 && endDateUsed.minute() === 0) {
136-
endDateUsed = endDateUsed.subtract(1, "minute")
137-
}
138-
139-
const timeDiff = dayjs()
147+
let timeDiff = dayjs()
140148
.startOf("day")
141-
.add(endDateUsed.hour(), "hours")
142-
.add(endDateUsed.minute(), "minutes")
149+
.add(endDate.hour(), "hours")
150+
.add(endDate.minute(), "minutes")
143151
.diff(
144152
dayjs()
145153
.startOf("day")
146154
.add(startDate.hour(), "hours")
147155
.add(startDate.minute(), "minutes"),
148156
"minutes",
149157
)
158+
if (timeDiff === 0) {
159+
timeDiff = 24 * 60
160+
}
150161

151162
timeSlotsPerDay = Math.floor(Math.abs(timeDiff) / timeStepsMinute)
152163

0 commit comments

Comments
 (0)