Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change current times behaviour #110

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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