From 1633f31b336f35ffb13cff52cc123006c37cc444 Mon Sep 17 00:00:00 2001 From: Michito Date: Wed, 23 Oct 2024 15:16:55 +0200 Subject: [PATCH] Fix rendering of timeslots spanning two days (#493) closes #328 --- newdle/client/src/components/answer/Calendar.js | 2 +- newdle/client/src/util/date.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/newdle/client/src/components/answer/Calendar.js b/newdle/client/src/components/answer/Calendar.js index d2654fe2..ca9024c5 100644 --- a/newdle/client/src/components/answer/Calendar.js +++ b/newdle/client/src/components/answer/Calendar.js @@ -38,7 +38,7 @@ function calculateHeight(start, end, minHour, maxHour) { endMins = end.hours() * 60 + end.minutes(); } else if (end.day() !== start.day()) { // the end of the slot is on another day so we will allow the slot to overflow - endMins = maxHour * 60 + end.minutes(); + endMins = MAX_HOUR * 60 + end.hour() * 60 + end.minutes(); } if (startMins < minHour * 60) { diff --git a/newdle/client/src/util/date.js b/newdle/client/src/util/date.js index fb0173ff..a671ee21 100644 --- a/newdle/client/src/util/date.js +++ b/newdle/client/src/util/date.js @@ -46,6 +46,8 @@ export function getHourSpan(input) { } else if (minTimelineHour < defaultMinHour) { // shift return [minTimelineHour, minTimelineHour + defaultHourSpan]; + } else if (maxTimelineHour > defaultMaxHour) { + return [defaultMinHour, maxTimelineHour]; } else { return [defaultMinHour, defaultMaxHour]; } @@ -66,7 +68,7 @@ export function hourRange(start, end, step = 1, extendToNextDay = true) { if (extendToNextDay) { hours.push(it - 24); } - break; + continue; } hours.push(it);