mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-04 12:45:17 +02:00
Improve UTC date formatting by adding validation for ISO date strings in formatUTCDate function
This commit is contained in:
parent
1323d91e32
commit
ab189c8aff
1 changed files with 3 additions and 1 deletions
|
@ -118,7 +118,9 @@ export function validateDateRange(
|
||||||
*/
|
*/
|
||||||
export function formatUTCDate(utcDate: string | null): string {
|
export function formatUTCDate(utcDate: string | null): string {
|
||||||
if (!utcDate) return '';
|
if (!utcDate) return '';
|
||||||
return DateTime.fromISO(utcDate).toISO().slice(0, 16).replace('T', ' ');
|
const dateTime = DateTime.fromISO(utcDate);
|
||||||
|
if (!dateTime.isValid) return '';
|
||||||
|
return dateTime.toISO()?.slice(0, 16).replace('T', ' ') || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export const VALID_TIMEZONES = [
|
export const VALID_TIMEZONES = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue