mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-28 01:09:37 +02:00
Refactor toLocalDatetime function to improve ISO date handling and return format
This commit is contained in:
parent
ab189c8aff
commit
c9fa1d55f7
1 changed files with 3 additions and 3 deletions
|
@ -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) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue