From c9fa1d55f7050bf6d5adfd526c0c9daebc25b6ef Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sat, 10 May 2025 13:02:06 -0400 Subject: [PATCH] Refactor toLocalDatetime function to improve ISO date handling and return format --- frontend/src/lib/dateUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/dateUtils.ts b/frontend/src/lib/dateUtils.ts index d949504..6d611ed 100644 --- a/frontend/src/lib/dateUtils.ts +++ b/frontend/src/lib/dateUtils.ts @@ -12,10 +12,10 @@ export function toLocalDatetime( timezone: string = Intl.DateTimeFormat().resolvedOptions().timeZone ): string { if (!utcDate) return ''; - return DateTime.fromISO(utcDate, { zone: 'UTC' }) + const isoString = DateTime.fromISO(utcDate, { zone: 'UTC' }) .setZone(timezone) - .toISO({ suppressSeconds: true, includeOffset: false }) - .slice(0, 16); + .toISO({ suppressSeconds: true, includeOffset: false }); + return isoString ? isoString.slice(0, 16) : ''; } /**