Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I HOPE THIS TIME COMPARISON WORKS! #214

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading