diff --git a/templates/dashboard.html b/templates/dashboard.html
index 965e512..0fe9d0f 100644
--- a/templates/dashboard.html
+++ b/templates/dashboard.html
@@ -219,25 +219,21 @@
// For 'last24hours', the bucket is an hour in UTC (e.g., "14")
const utcHour = parseInt(item.bucket, 10);
const now = new Date();
- // Create Date objects for the start and end of the hour in UTC
- const utcStart = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), utcHour));
- const utcEnd = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), utcHour + 1));
- // Convert to local time strings, e.g., "16:00"
+ // Use UTC components to get the correct UTC date
+ const utcStart = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), utcHour));
+ const utcEnd = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), utcHour + 1));
+ // Convert to local time strings
const localStart = utcStart.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
const localEnd = utcEnd.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
return `${localStart} - ${localEnd}`;
} else if (timeframe === '7days' || timeframe === '30days') {
- // For these timeframes, the bucket is a date in the format "YYYY-MM-DD"
const utcDate = new Date(item.bucket + 'T00:00:00Z');
- return utcDate.toLocaleDateString(); // Adjust formatting as needed
+ return utcDate.toLocaleDateString();
} else if (timeframe === '365days') {
- // For this timeframe, the bucket is a month in the format "YYYY-MM"
const [year, month] = item.bucket.split('-');
const dateObj = new Date(year, month - 1, 1);
- // Format to something like "Mar 2025"
return dateObj.toLocaleString([], { month: 'short', year: 'numeric' });
} else {
- // Fallback: use the bucket value as-is
return item.bucket;
}
});