fix: handle malformed event dates in calendar route #316

This commit is contained in:
Linus Rath
2026-05-22 14:04:02 +02:00
parent 1fc6185002
commit d3778e6521
3 changed files with 25 additions and 7 deletions
+5 -1
View File
@@ -78,7 +78,11 @@ export function EventCard({ event, calendar, variant, onClick, onMouseEnter, onM
const calendarName = calendar?.name || "";
const durationMinutes = parseDuration(event.duration);
const endTime = getEventEndDate(event);
const timeString = `${format(startDate, timeFmt)} ${format(endTime, timeFmt)}`;
const safeFormat = (d: Date, fmt: string) => {
if (isNaN(d.getTime())) return "--:--";
try { return format(d, fmt); } catch { return "--:--"; }
};
const timeString = `${safeFormat(startDate, timeFmt)} ${safeFormat(endTime, timeFmt)}`;
const ariaLabel = `${event.title || t("events.no_title")}, ${timeString}${calendarName ? `, ${calendarName}` : ""}`;
const handleDragStart = useCallback((e: DragEvent) => {