mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 17:55:21 +03:00
fix LastDayInRange when a time is selected
This commit is contained in:
parent
6a98ec9665
commit
dd609bfa21
@ -102,8 +102,9 @@ const Calendar = ({ onChange, calendarRef, close, dateRange, children }) => {
|
|||||||
...prev,
|
...prev,
|
||||||
selectedDay: todayTimestamp,
|
selectedDay: todayTimestamp,
|
||||||
monthDetails: getMonthDetails(year, month),
|
monthDetails: getMonthDetails(year, month),
|
||||||
|
timeRange: { ...dateRange },
|
||||||
}));
|
}));
|
||||||
}, [year, month, getMonthDetails]);
|
}, [year, month, getMonthDetails, dateRange]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// add refs for keyboard navigation
|
// add refs for keyboard navigation
|
||||||
@ -136,10 +137,14 @@ const Calendar = ({ onChange, calendarRef, close, dateRange, children }) => {
|
|||||||
|
|
||||||
const isLastDayInRange = useCallback(
|
const isLastDayInRange = useCallback(
|
||||||
(day) => {
|
(day) => {
|
||||||
return (
|
// if the hour is not above 0, we will use 24 hour.
|
||||||
new Date(state.timeRange.before).setHours(24) === new Date(day.timestamp).setHours(24) ||
|
const beforeHour = new Date(state.timeRange.before).getHours() || 24;
|
||||||
state.timeRange.before === new Date(day.timestamp).setHours(24)
|
|
||||||
);
|
/**
|
||||||
|
* When user selects a day in the calendar, the before will be 00:00.
|
||||||
|
* When user selects a time in timepicker, the day.timestamp hour must be changed to match the selected end () hour.
|
||||||
|
*/
|
||||||
|
return state.timeRange.before === new Date(day.timestamp).setHours(beforeHour);
|
||||||
},
|
},
|
||||||
[state.timeRange.before]
|
[state.timeRange.before]
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user