1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-24 23:39:37 +02:00

Refactor toLocalDatetime function to improve ISO date handling and return format

This commit is contained in:
Sean Morley 2025-05-10 13:02:06 -04:00
parent ab189c8aff
commit c9fa1d55f7

View file

@ -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) : '';
}
/**