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:
+6
-2
@@ -53,8 +53,12 @@ function isJalaliDateString(value: string): boolean {
|
|||||||
|
|
||||||
function toDateValue(date: string | Date): Date {
|
function toDateValue(date: string | Date): Date {
|
||||||
if (typeof date !== 'string') return date
|
if (typeof date !== 'string') return date
|
||||||
if (/^\d{4}-\d{2}-\d{2}/.test(date)) return parseISODate(date)
|
const trimmed = date.trim()
|
||||||
return new Date(date)
|
// فقط تاریخ بدون ساعت؛ رشتهٔ دارای زمان باید کامل پارس شود
|
||||||
|
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 {
|
export function formatDate(date: string | Date | null | undefined): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user