Co-authored-by: Erik Kroes <erik.kroes@ing.com> Co-authored-by: Gerjan van Geest <gerjan.van.geest@ing.com> Co-authored-by: Thijs Louisse <thijs.louisse@ing.com> Co-authored-by: Thomas Allmer <thomas.allmer@ing.com>
26 lines
743 B
JavaScript
26 lines
743 B
JavaScript
import { createMonth } from './createMonth.js';
|
|
|
|
export function createMultipleMonth(
|
|
date,
|
|
{ firstDayOfWeek = 0, pastMonths = 0, futureMonths = 0 } = {},
|
|
) {
|
|
const multipleMonths = {
|
|
months: [],
|
|
};
|
|
|
|
for (let i = pastMonths; i > 0; i -= 1) {
|
|
const pastDate = new Date(date);
|
|
pastDate.setMonth(pastDate.getMonth() - i);
|
|
multipleMonths.months.push(createMonth(pastDate, { firstDayOfWeek }));
|
|
}
|
|
|
|
multipleMonths.months.push(createMonth(date, { firstDayOfWeek }));
|
|
|
|
for (let i = 0; i < futureMonths; i += 1) {
|
|
const futureDate = new Date(date);
|
|
futureDate.setMonth(futureDate.getMonth() + (i + 1));
|
|
multipleMonths.months.push(createMonth(futureDate, { firstDayOfWeek }));
|
|
}
|
|
|
|
return multipleMonths;
|
|
}
|