UNPKG

348 BPlain TextView Raw
1import type { CalendarMonth, CalendarWeek } from "../classes/index.js";
2
3/** Returns an array of calendar weeks from an array of calendar months. */
4export function getWeeks(months: CalendarMonth[]) {
5 const initialWeeks: CalendarWeek[] = [];
6 return months.reduce((weeks, month) => {
7 return [...weeks, ...month.weeks];
8 }, initialWeeks);
9}