Skip to content

Commit

Permalink
I HOPE THIS TIME COMPARISON WORKS!
Browse files Browse the repository at this point in the history
  • Loading branch information
lryanle committed Apr 5, 2024
1 parent 7a322d9 commit de99057
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions frontend/app/api/listings/day/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
{
Expand Down
7 changes: 5 additions & 2 deletions frontend/components/dashboard/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateRange | undefined>({
from: addDays(new Date(), -30),
to: new Date(),
from: addDays(today, -30),
to: today,
});

return (
Expand Down

0 comments on commit de99057

Please sign in to comment.