I have a function that gets all days of any input dates's week. I use this later on to render a calendar.
However, the dates go from Sunday-Saturday when I want them going from Monday-Sunday. I feel like the would be an easy change but I can't seem to figure it out.
const createNewWeek = (startDate) => {
const newDates = Array.from(Array(7).keys()).map((idx) => {
const d = new Date(startDate);
d.setDate(d.getDate() - d.getDay() + idx);
return d;
})
return newDates
}
console.log(createNewWeek(new Date()))