From 239b177a141d1a88b8062dfaf41fdaa95cd96c21 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 28 Oct 2023 01:20:28 +0100 Subject: [PATCH] fix date on analytics --- src/components/AnalyticsChart.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/AnalyticsChart.tsx b/src/components/AnalyticsChart.tsx index 967f100..88ef9ea 100644 --- a/src/components/AnalyticsChart.tsx +++ b/src/components/AnalyticsChart.tsx @@ -81,7 +81,17 @@ export default function AnalyticsChart({ labels.push("today"); continue; } - labels.push(formatTimeAgo(playerCountHistory[i].time)); + if (i == playerCountHistory.length - 2) { + labels.push("yesterday"); + continue; + } + if (i >= 1) { + const date = playerCountHistory[i - 1].time; + labels.push(formatTimeAgo(date)); + } else { + const date = playerCountHistory[i].time; + labels.push(formatTimeAgo(date)); + } } const data = {