From 5d88e688260e4121526a4f6b68ef260c928c13df Mon Sep 17 00:00:00 2001 From: Nikan Zeyaei <72458440+NikanZeyaei@users.noreply.github.com> Date: Sun, 21 Jun 2026 18:56:47 +0330 Subject: [PATCH] fix(frontend): guard IntlUtil.formatDate against out-of-range timestamps (#5468) --- frontend/src/utils/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index eda03c8e4..cec7ad2f0 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -920,6 +920,8 @@ export type CalendarKind = 'gregorian' | 'jalalian'; export class IntlUtil { static formatDate(date: string | number | Date | null | undefined, calendar: CalendarKind = 'gregorian'): string { if (date == null) return ''; + const d = new Date(date); + if (!isFinite(d.getTime())) return ''; const language = LanguageManager.getLanguage(); const locale = calendar === 'jalalian' ? 'fa-IR' : language; @@ -934,11 +936,12 @@ export class IntlUtil { }; const intl = new Intl.DateTimeFormat(locale, intlOptions); - return intl.format(new Date(date)); + return intl.format(d); } static formatRelativeTime(date: number | null | undefined): string { if (date == null) return ''; + if (!isFinite(date)) return ''; const language = LanguageManager.getLanguage(); const now = new Date(); const diff = date < 0