Update apps/client/src/widgets/collections/calendar/event_builder.ts

Replace end with duration if recurrence set. Make duration calculation clearer

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
BeatLink 2026-02-22 18:43:18 -05:00 committed by GitHub
parent e53cd7443a
commit 9b45639148
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -122,13 +122,13 @@ export async function buildEvent(note: FNote, { startDate, endDate, startTime, e
}
if (recurrence) {
delete eventData.end;
eventData.rrule = `DTSTART:${startDate.replace(/[-:]/g, "")}\n${recurrence}`;
if (endDate){
const duration = (d =>
String(d / 36e5 | 0).padStart(2, "0") + ":" +
String(d / 6e4 % 60 | 0).padStart(2, "0")
)((new Date(endDate)) - (new Date(startDate)));
eventData.duration = duration
const diffMs = new Date(endDate).getTime() - new Date(startDate).getTime();
const hours = Math.floor(diffMs / 3600000);
const minutes = Math.floor((diffMs / 60000) % 60);
eventData.duration = `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}`;
}
}
events.push(eventData);