const everyMonday = (async () => {
const {
addDays,
startOfWeek,
startOfDay,
isSameDay,
isAfter,
isBefore,
format,
} = await import("npm:date-fns");
const from = new Date(2024, 0, 1);
const until = startOfDay(new Date(2024, 3, 7));
let d = startOfWeek(from, { weekStartsOn: 1 });
const mondays: Date[] = [];
while (!isAfter(d, until)) {
if (!isBefore(d, from)) {
mondays.push(d);
}
d = startOfDay(addDays(d, 7));
}
return mondays.map((d) => format(d, "- MMM d")).join("\n\n");
})();
console.log(await everyMonday);