From 5247eb2752b9c5d0f591ec8a5676cd589dd0a436 Mon Sep 17 00:00:00 2001 From: Tobias Frischmann Date: Wed, 7 Oct 2026 15:30:06 +0200 Subject: [PATCH] show next week for recuring weekly when smarter --- app/utils/todo.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/utils/todo.ts b/app/utils/todo.ts index 147f31c..56a4943 100644 --- a/app/utils/todo.ts +++ b/app/utils/todo.ts @@ -23,6 +23,7 @@ export function isChecked(todo: Todo): boolean { return date >= start && date <= end; } +//Todo: return array of all visual TimeRanges export function getTimeRange( todo: Todo, ): { visuel: TimeRange; valid: TimeRange } | undefined { @@ -60,10 +61,18 @@ export function getTimeRange( const start = new Date(weekStart); + let visuelStart = addDays(start, todo.time.start ?? 0); + let visuelEnd = addDays(start, todo.time.end ?? 6); + + if (visuelEnd < today) { + visuelStart = addDays(visuelStart, 7); + visuelEnd = addDays(visuelEnd, 7); + } + return { visuel: { - start: toLocalDateString(addDays(start, todo.time.start ?? 0)), - end: toLocalDateString(addDays(start, todo.time.end ?? 6)), + start: toLocalDateString(visuelStart), + end: toLocalDateString(visuelEnd), }, valid: { start: toLocalDateString(start), -- 2.51.2