From 94b74f96a3fa0b079b605ab52127ef2353d94026 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 5 Apr 2026 20:17:22 +0200 Subject: [PATCH] fix(ical): pad datetime to 15 chars for valid iCal DTSTART/DTEND format Times like 09:00 were exported as YYYYMMDDTHHMM (13 chars) instead of YYYYMMDDTHHMMSS (15 chars). Google Calendar couldn't parse the short format and defaulted all events to 12:00 AM. Closes #432 --- server/src/services/tripService.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/services/tripService.ts b/server/src/services/tripService.ts index 9afd7f2..e5d4e27 100644 --- a/server/src/services/tripService.ts +++ b/server/src/services/tripService.ts @@ -366,8 +366,13 @@ export function exportICS(tripId: string | number): { ics: string; filename: str const uid = (id: number, type: string) => `trek-${type}-${id}@trek`; // Format datetime: handles full ISO "2026-03-30T09:00" and time-only "10:00" + // iCal requires exactly YYYYMMDDTHHMMSS format const fmtDateTime = (d: string, refDate?: string) => { - if (d.includes('T')) return d.replace(/[-:]/g, '').split('.')[0]; + if (d.includes('T')) { + const raw = d.replace(/[-:]/g, '').split('.')[0]; + // Pad to 15 chars (YYYYMMDDTHHMMSS) — add missing seconds + return raw.length === 13 ? raw + '00' : raw; + } // Time-only: combine with reference date if (refDate && d.match(/^\d{2}:\d{2}/)) { const datePart = refDate.split('T')[0];