Skip to content

Commit d734327

Browse files
šŸ› fix(web): Inconsistent exclusive/inclusive end dates for allday events (#896)
* fix(web): Inconsistent exclusive/inclusive end dates for allday events * Update packages/web/src/ducks/events/sagas/saga.util.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 223df83 commit d734327

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

ā€Žpackages/web/src/common/utils/web.date.util.tsā€Ž

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,19 @@ export const getCalendarHeadingLabel = (
221221

222222
export const mapToBackend = (s: Schema_SelectedDates) => {
223223
if (s.isAllDay) {
224+
const startDate = dayjs(s.startDate).format(YEAR_MONTH_DAY_FORMAT);
225+
const endDate = dayjs(s.endDate).format(YEAR_MONTH_DAY_FORMAT);
226+
227+
if (startDate === endDate) {
228+
return {
229+
startDate,
230+
endDate: dayjs(endDate).add(1, "day").format(YEAR_MONTH_DAY_FORMAT),
231+
};
232+
}
233+
224234
return {
225-
startDate: dayjs(s.startDate).format(YEAR_MONTH_DAY_FORMAT),
226-
endDate: dayjs(s.endDate).format(YEAR_MONTH_DAY_FORMAT),
235+
startDate,
236+
endDate,
227237
};
228238
}
229239

ā€Žpackages/web/src/ducks/events/sagas/saga.util.tsā€Ž

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,18 @@ export const EventDateUtils = {
9898
) => {
9999
return events.filter((event) => {
100100
if (event.isAllDay) {
101-
const belongsInRange =
102-
dayjs(event.startDate).isSameOrAfter(startDate) ||
103-
dayjs(event.endDate).isSameOrBefore(endDate) ||
104-
// is between start and end date
105-
(dayjs(startDate).isBetween(event.startDate, event.endDate) &&
106-
dayjs(endDate).isBetween(event.startDate, event.endDate));
101+
// For all-day events with exclusive end dates (e.g., Mon event: start="2025-09-08", end="2025-09-09")
102+
// Check if the event overlaps with the requested date range
103+
const eventStart = dayjs(event.startDate);
104+
const eventEnd = dayjs(event.endDate); // This is exclusive, so the event ends at the very start of the end date
105+
const rangeStart = dayjs(startDate);
106+
const rangeEnd = dayjs(endDate);
107107

108-
return belongsInRange;
108+
// Event overlaps if: event starts before range ends AND event ends after range starts
109+
const overlaps =
110+
eventStart.isBefore(rangeEnd) && eventEnd.isAfter(rangeStart);
111+
112+
return overlaps;
109113
}
110114

111115
return (

0 commit comments

Comments
Ā (0)