fix: update Chart component to display time correctly at midnight for hourly intervals

This commit is contained in:
Usman Baig
2026-01-19 18:44:57 +01:00
parent 3629f11661
commit 2a51982c28

View File

@@ -163,7 +163,11 @@ export default function Chart({ data, prevData, stats, prevStats, interval }: Ch
if (interval === 'minute') {
formattedDate = new Date(item.date).toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' })
} else if (interval === 'hour') {
formattedDate = new Date(item.date).toLocaleTimeString('en-US', { hour: 'numeric', minute: 'numeric' })
const d = new Date(item.date)
const isMidnight = d.getHours() === 0 && d.getMinutes() === 0
formattedDate = isMidnight
? d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })
: d.toLocaleTimeString('en-US', { hour: 'numeric', minute: 'numeric' })
} else {
formattedDate = new Date(item.date).toLocaleDateString('en-US', { month: 'short', day: 'numeric' })
}