Keep clock time when formatting ISO datetimes.
Date-only local parsing was matching any string starting with YYYY-MM-DD and zeroed hours to 00:00 in order lists. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+5
-4
@@ -57,10 +57,11 @@ 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
|
||||||
const trimmed = date.trim()
|
const trimmed = date.trim()
|
||||||
// YYYY-MM-DD (and datetime starting with it) as local calendar date — avoids UTC day-shift
|
// فقط تاریخِ بدون ساعت (YYYY-MM-DD) را بهصورت تقویم محلی بخوان تا شیفت UTC روز را جابهجا نکند.
|
||||||
const isoDay = trimmed.match(/^(\d{4})-(\d{2})-(\d{2})/)
|
// رشتههای دارای ساعت (…T10:30:00 یا … 10:30) باید کامل پارس شوند.
|
||||||
if (isoDay && Number(isoDay[1]) >= 1700) {
|
const dateOnly = trimmed.match(/^(\d{4})-(\d{2})-(\d{2})$/)
|
||||||
return new Date(Number(isoDay[1]), Number(isoDay[2]) - 1, Number(isoDay[3]))
|
if (dateOnly && Number(dateOnly[1]) >= 1700) {
|
||||||
|
return new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]))
|
||||||
}
|
}
|
||||||
const parsed = new Date(trimmed)
|
const parsed = new Date(trimmed)
|
||||||
if (Number.isNaN(parsed.getTime())) return new Date(NaN)
|
if (Number.isNaN(parsed.getTime())) return new Date(NaN)
|
||||||
|
|||||||
Reference in New Issue
Block a user