Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ import {
useId,
} from "react";
import chroma from "chroma-js";
import { subDays, addWeeks, format } from "date-fns";
import {
subDays,
addWeeks,
format,
startOfDay,
startOfHour,
addHours,
} from "date-fns";
import { useSearchParams } from "react-router-dom";
import "react-date-range/dist/styles.css";
import "react-date-range/dist/theme/default.css";
Expand Down Expand Up @@ -146,9 +153,14 @@ const getDateRange = (
}

if (interval === "day") {
// Only instantiate new Date once so that we don't get the wrong interval if
// start is 23:59:59.999 and the clock shifts to 00:00:00 before the second
// instantiation.
const today = new Date();
return {
startDate: subDays(new Date(), 6),
endDate: new Date(),
startDate: startOfDay(subDays(today, 6)),
// Add one hour to endDate to include real-time data for today.
endDate: addHours(startOfHour(today), 1),
};
}

Expand Down