Skip to content

Commit

Permalink
Merge pull request #110 from filips123/fix-current-time
Browse files Browse the repository at this point in the history
Change current times behaviour
  • Loading branch information
filips123 authored Oct 30, 2024
2 parents 793f258 + 31bf54a commit 12d04f2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions website/src/utils/times.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ export function getCurrentTime(): number {

let timeIndex = 0

for (const [startTime, endTime] of lessonTimes) {
const startTimes = startTime.split(':').map(Number)
const endTimes = endTime.split(':').map(Number)
for (let i = 0; i < lessonTimes.length; i++) {
// Current time starts at the end of the previous lesson (except for pre-lessons)
// and ends on the end of the current lesson
const startTimes = lessonTimes[i > 0 ? i - 1 : i][i > 0 ? 1 : 0].split(':').map(Number)
const endTimes = lessonTimes[i][1].split(':').map(Number)

startDateTime.setHours(startTimes[0], startTimes[1], 0)
endDateTime.setHours(endTimes[0], endTimes[1] + 5, 0)
endDateTime.setHours(endTimes[0], endTimes[1], 0)

if (startDateTime <= time && time <= endDateTime) return timeIndex
timeIndex++
Expand Down

0 comments on commit 12d04f2

Please sign in to comment.