Keep clock time when formatting ISO datetimes.

Date-only parsing was stripping hours from full timestamps shown in the app.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-09 16:15:35 +03:30
co-authored by Cursor
parent 9e455c2572
commit 5f60111321
+6 -2
View File
@@ -53,8 +53,12 @@ function isJalaliDateString(value: string): boolean {
function toDateValue(date: string | Date): Date {
if (typeof date !== 'string') return date
if (/^\d{4}-\d{2}-\d{2}/.test(date)) return parseISODate(date)
return new Date(date)
const trimmed = date.trim()
// فقط تاریخ بدون ساعت؛ رشتهٔ دارای زمان باید کامل پارس شود
if (/^\d{4}-\d{2}-\d{2}$/.test(trimmed)) return parseISODate(trimmed)
const parsed = new Date(trimmed)
if (Number.isNaN(parsed.getTime())) return new Date(NaN)
return parsed
}
export function formatDate(date: string | Date | null | undefined): string {