Merge pull request #720: keep history date and time in the same local timezone

Derive both displayed values from local date components so the card cannot show mismatched days.
This commit is contained in:
BaiFu 2026-07-22 19:40:44 +08:00 committed by GitHub
commit fbdae298d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -312,7 +312,13 @@ const formatDate = (dateStr) => {
if (!dateStr) return ''
try {
const date = new Date(dateStr)
return date.toISOString().slice(0, 10)
// Use local date components (like formatTime below) so the displayed day
// matches the displayed time. toISOString() converts to UTC and can show
// the wrong day for non-UTC clients near midnight.
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
} catch {
return dateStr?.slice(0, 10) || ''
}