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