Skip to content

Commit d19ceec

Browse files
authored
Merge pull request #2 from Frac7/wrong-shift-for-the-first-day-of-the-month
Trash turn fixed
2 parents 167f8f8 + e9d1fa1 commit d19ceec

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/components/TrashTurns.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@ const TrashTurns = ({ date }) => {
1919
const turnObject = useMemo(() => trashTurns[trashTurnIndex], [trashTurns, trashTurnIndex]);
2020

2121
const shift = useMemo(() => {
22-
const timeDivider = 1000 * 60 * 60 * 24;
23-
const daysInMonth = new Date(selectedDate.getFullYear(),
24-
selectedDate.getMonth() + 1, 0).getDate();
2522
const initialDate = new Date(startingDate);
26-
27-
return Math.floor((selectedDate - initialDate) / (timeDivider * daysInMonth));
23+
return (selectedDate.getMonth() - initialDate.getMonth()) + (12 * (selectedDate.getFullYear() - initialDate.getFullYear()));
2824
}, [selectedDate]);
2925

3026
return (

0 commit comments

Comments
 (0)