Refactor toLocalDatetime function to improve ISO date handling and return format
This commit is contained in:
@@ -12,10 +12,10 @@ export function toLocalDatetime(
|
|||||||
timezone: string = Intl.DateTimeFormat().resolvedOptions().timeZone
|
timezone: string = Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||||
): string {
|
): string {
|
||||||
if (!utcDate) return '';
|
if (!utcDate) return '';
|
||||||
return DateTime.fromISO(utcDate, { zone: 'UTC' })
|
const isoString = DateTime.fromISO(utcDate, { zone: 'UTC' })
|
||||||
.setZone(timezone)
|
.setZone(timezone)
|
||||||
.toISO({ suppressSeconds: true, includeOffset: false })
|
.toISO({ suppressSeconds: true, includeOffset: false });
|
||||||
.slice(0, 16);
|
return isoString ? isoString.slice(0, 16) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user