export function parseSqliteDateTime(value) { if (!value) return null if (value instanceof Date) return value let str = String(value).trim() if (!str) return null // "YYYY-MM-DD" -> "YYYY-MM-DDT00:00:00" if (/^\d{4}-\d{2}-\d{2}$/.test(str)) str = `${str}T00:00:00` // "YYYY-MM-DD HH:mm:ss" -> "YYYY-MM-DDTHH:mm:ss" let iso = str.includes('T') ? str : str.replace(' ', 'T') // SQLite 可能带微秒,Date 仅可靠支持到毫秒 iso = iso.replace(/\.(\d{3})\d+/, '.$1') // 统一按北京时间解析(除非字符串本身已带时区) const hasTimezone = /([zZ]|[+-]\d{2}:\d{2})$/.test(iso) if (!hasTimezone) iso = `${iso}+08:00` const date = new Date(iso) if (Number.isNaN(date.getTime())) return null return date } export function formatDateTime(value) { if (!value) return '-' return String(value) }