diff --git a/src/lib/due.ts b/src/lib/due.ts index 219fd2a..58d9a03 100644 --- a/src/lib/due.ts +++ b/src/lib/due.ts @@ -29,6 +29,16 @@ export function shiftDays(key: string, days: number): string { return localKey(date); } +export function monthGrid(month: Date): Date[] { + const year = month.getFullYear(); + const index = month.getMonth(); + const offset = (new Date(year, index, 1).getDay() + 6) % 7; + return Array.from( + { length: 42 }, + (_, cell) => new Date(year, index, 1 - offset + cell), + ); +} + export function daysFromToday(key: string, from = today()): number { return Math.round((fromKey(key).getTime() - fromKey(from).getTime()) / 86_400_000); } diff --git a/src/ui/day-grid.svelte b/src/ui/day-grid.svelte index 1a6d016..c838536 100644 --- a/src/ui/day-grid.svelte +++ b/src/ui/day-grid.svelte @@ -5,7 +5,7 @@