Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(site): use correct default insights time for day interval #10837

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

Merged
merged 2 commits into from
Nov 22, 2023
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