From de99057fc34d877312b62cd848b901224fe4dc12 Mon Sep 17 00:00:00 2001 From: Ryan Le <31494954+lryanle@users.noreply.github.com> Date: Thu, 4 Apr 2024 21:13:44 -0500 Subject: [PATCH] I HOPE THIS TIME COMPARISON WORKS! --- frontend/app/api/listings/day/route.ts | 3 +-- frontend/components/dashboard/dashboard.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/app/api/listings/day/route.ts b/frontend/app/api/listings/day/route.ts index ccefca6b..d588599e 100644 --- a/frontend/app/api/listings/day/route.ts +++ b/frontend/app/api/listings/day/route.ts @@ -16,15 +16,14 @@ async function getListingsByDay(before?: string, after?: string) { // Normalize and format the dates const beforeDate = before ? new Date(before) : new Date(); beforeDate.setUTCHours(23, 59, 59, 999); - beforeDate.setDate(beforeDate.getDate() - 1); const afterDate = after ? new Date(after) : new Date(); afterDate.setUTCHours(0, 0, 0, 0); - afterDate.setDate(afterDate.getDate() - 1); const formattedBeforeDate = beforeDate.toISOString(); const formattedAfterDate = afterDate.toISOString(); console.log('formattedBeforeDate', formattedBeforeDate, 'formattedAfterDate', formattedAfterDate); + // formattedBeforeDate 2024-04-04T23:59:59.999Z formattedAfterDate 2024-03-05T00:00:00.000Z const results = await db.collection('listings').aggregate([ { diff --git a/frontend/components/dashboard/dashboard.tsx b/frontend/components/dashboard/dashboard.tsx index 9a9b7c6f..1e965dba 100644 --- a/frontend/components/dashboard/dashboard.tsx +++ b/frontend/components/dashboard/dashboard.tsx @@ -22,9 +22,12 @@ import DownloadCSV from "@/components/dashboard/DownloadCSV"; type Props = {}; export default function Dashboard({}: Props) { + const localTime = new Date(); + const today = new Date(localTime.getTime() + (localTime.getTimezoneOffset() * 60000)); + const [date, setDate] = useState({ - from: addDays(new Date(), -30), - to: new Date(), + from: addDays(today, -30), + to: today, }); return (