Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -513,12 +513,12 @@ describe("calendarEventToJCal", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("converts all-day events adjusting dtend", () => {
|
||||
it("converts all-day events", () => {
|
||||
const mockEvent: any = {
|
||||
uid: "event-11",
|
||||
title: "All Day",
|
||||
start: "2025-07-21T00:00:00.000Z",
|
||||
end: "2025-07-21T00:00:00.000Z",
|
||||
end: "2025-07-22T00:00:00.000Z",
|
||||
timezone: "Europe/Paris",
|
||||
allday: true,
|
||||
attendee: [],
|
||||
@@ -542,7 +542,7 @@ describe("calendarEventToJCal", () => {
|
||||
calId: "test/test",
|
||||
title: "Team Meeting",
|
||||
start: "2025-07-23T00:00:00.000Z",
|
||||
end: "2025-07-23T00:00:00.000Z",
|
||||
end: "2025-07-24T00:00:00.000Z",
|
||||
timezone: "Europe/Paris",
|
||||
transp: "OPAQUE",
|
||||
class: "PUBLIC",
|
||||
|
||||
@@ -994,18 +994,21 @@ function formatEnd(
|
||||
|
||||
const formatDatePart = (d: Date) =>
|
||||
d.toLocaleDateString("en-CA", { timeZone }); // YYYY-MM-DD format
|
||||
const sameDay = formatDatePart(startDate) === formatDatePart(endDate);
|
||||
|
||||
if (allday) {
|
||||
const inclusiveEndDate = new Date(endDate);
|
||||
inclusiveEndDate.setDate(inclusiveEndDate.getDate() - 1);
|
||||
const sameDay =
|
||||
formatDatePart(startDate) === formatDatePart(inclusiveEndDate);
|
||||
return sameDay
|
||||
? null
|
||||
: endDate.toLocaleDateString(t("locale"), {
|
||||
: inclusiveEndDate.toLocaleDateString(t("locale"), {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
timeZone,
|
||||
});
|
||||
} else {
|
||||
const sameDay = formatDatePart(startDate) === formatDatePart(endDate);
|
||||
if (sameDay) {
|
||||
return endDate.toLocaleTimeString(t("locale"), {
|
||||
hour: "2-digit",
|
||||
|
||||
@@ -247,6 +247,7 @@ function EventUpdateModal({
|
||||
if (isAllDay) {
|
||||
// For all-day events, use date format (YYYY-MM-DD)
|
||||
const endDate = new Date(event.end);
|
||||
endDate.setDate(endDate.getDate() - 1);
|
||||
setEnd(endDate.toISOString().split("T")[0]);
|
||||
} else {
|
||||
// For timed events, format in the event's original timezone
|
||||
|
||||
@@ -331,11 +331,6 @@ export function makeVevent(
|
||||
const endDate = new Date(event.end);
|
||||
let finalEndDate = endDate;
|
||||
|
||||
if (event.allday && endDate.getTime() === startDate.getTime()) {
|
||||
finalEndDate = new Date(endDate);
|
||||
finalEndDate.setDate(startDate.getDate() + 1);
|
||||
}
|
||||
|
||||
vevent[1].push([
|
||||
"dtend",
|
||||
{ tzid },
|
||||
|
||||
Reference in New Issue
Block a user