diff --git a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue index 174f2f2c2d..e2e814e1b3 100644 --- a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue @@ -109,6 +109,10 @@ const calculateNewDates = useMemoize( endDate = startDate.clone().add(15, 'minutes') } + if (endDate.diff(startDate, 'minute') === 60) { + endDate = startDate.clone().add(59, 'minutes') + } + // If the start date is before the opened date, we use the schedule start as the start date // This is to ensure the generated style of the record is not outside the bounds of the calendar if (startDate.isSameOrBefore(scheduleStart)) { diff --git a/packages/nc-gui/components/smartsheet/calendar/MonthView.vue b/packages/nc-gui/components/smartsheet/calendar/MonthView.vue index 7ce4da5d67..14028b6d76 100644 --- a/packages/nc-gui/components/smartsheet/calendar/MonthView.vue +++ b/packages/nc-gui/components/smartsheet/calendar/MonthView.vue @@ -261,11 +261,15 @@ const recordsToDisplay = computed<{ }) } else if (startCol && endCol) { // Multi-day event logic - const startDate = dayjs(record.row[startCol.title!]) + let startDate = dayjs(record.row[startCol.title!]) const endDate = dayjs(record.row[endCol.title!]) let currentWeekStart = startDate.startOf('week') + if (startDate.isBefore(currentWeekStart)) { + startDate = calendarData.value.weeks[0].days[0].date + } + const id = record.rowMeta.id ?? generateRandomNumber() // Since the records can span multiple weeks, to display, we render multiple elements // for each week the record spans. The id is used to identify the elements that belong to the same record @@ -286,6 +290,12 @@ const recordsToDisplay = computed<{ const recordStart = currentWeekStart.isBefore(startDate) ? startDate : currentWeekStart const recordEnd = currentWeekEnd.isAfter(endDate) ? endDate : currentWeekEnd + + if (recordEnd.isBefore(calendarData.value.weeks[0].days[0].date)) { + currentWeekStart = currentWeekStart.add(1, 'week') + continue + } + const duration = recordEnd.diff(recordStart, 'day') + 1 const dateKey = recordStart.format('YYYY-MM-DD')