13 lines
411 B
JavaScript
13 lines
411 B
JavaScript
const DAYS_IN_WEEK = 7
|
|
|
|
// Returns the seven dates of the week, from Monday to Sunday.
|
|
// Each date is a new instance: `weekStart` is never mutated.
|
|
export function listWeekDates(weekStart) {
|
|
const dates = []
|
|
for (let dayIndex = 0; dayIndex < DAYS_IN_WEEK; dayIndex += 1) {
|
|
const date = new Date(weekStart.getTime())
|
|
date.setDate(date.getDate() + dayIndex)
|
|
dates.push(date)
|
|
}
|
|
return dates
|
|
}
|