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:
2026-08-09 16:15:32 +03:30
co-authored by Cursor
parent 1c3c494a43
commit f46b02efa8
+5 -4
View File
@@ -57,10 +57,11 @@ function isJalaliDateString(value: string): boolean {
function toDateValue(date: string | Date): Date {
if (typeof date !== 'string') return date
const trimmed = date.trim()
// YYYY-MM-DD (and datetime starting with it) as local calendar date — avoids UTC day-shift
const isoDay = trimmed.match(/^(\d{4})-(\d{2})-(\d{2})/)
if (isoDay && Number(isoDay[1]) >= 1700) {
return new Date(Number(isoDay[1]), Number(isoDay[2]) - 1, Number(isoDay[3]))
// فقط تاریخِ بدون ساعت (YYYY-MM-DD) را به‌صورت تقویم محلی بخوان تا شیفت UTC روز را جابه‌جا نکند.
// رشته‌های دارای ساعت (…T10:30:00 یا … 10:30) باید کامل پارس شوند.
const dateOnly = trimmed.match(/^(\d{4})-(\d{2})-(\d{2})$/)
if (dateOnly && Number(dateOnly[1]) >= 1700) {
return new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]))
}
const parsed = new Date(trimmed)
if (Number.isNaN(parsed.getTime())) return new Date(NaN)