Skip to content

Commit

Permalink
use 23:59:59 for time for end date
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlau committed Nov 24, 2024
1 parent de8e21b commit f42234b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/routes/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ export default function Root() {
};

const [search, setSearch] = useState<boolean>(false);
const formatDate = (dateStr: string) => {
const formatDate = (dateStr: string, time: string) => {
const [year, month, day] = dateStr.split("-");
if (month.length !== 2 || day.length !== 2 || year.length !== 4) {
throw new Error(`Invalid date format: ${dateStr}`);
}
return new Date(`${year}-${month}-${day}T00:00:00.000Z`).toISOString();
return new Date(`${year}-${month}-${day}T${time}Z`).toISOString();
};

const fetchData = async (filters: SearchFilter) => {
const { location, date, eventType, searchText } = filters;
let { afterDate, beforeDate } = filters;

beforeDate = beforeDate ? formatDate(beforeDate) : undefined;
afterDate = afterDate ? formatDate(afterDate) : undefined;
beforeDate = beforeDate
? formatDate(beforeDate, "00:00:00.000")
: undefined;
afterDate = afterDate ? formatDate(afterDate, "23:59:59.999") : undefined;
const params = {
...(location ? { location } : {}),
...(eventType ? { eventType } : {}),
Expand Down

0 comments on commit f42234b

Please sign in to comment.