From c56d6d581663930597b9fa88c06a0f341c54ce17 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 13 Jul 2026 22:24:55 +0000 Subject: [PATCH] Fix: add missing get_week_boundaries() to dates.py points_engine.py imports this for weekly point tracking but the function was missing from the restructured codebase. --- diligence/utils/dates.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/diligence/utils/dates.py b/diligence/utils/dates.py index 65b0ab9..d54363f 100644 --- a/diligence/utils/dates.py +++ b/diligence/utils/dates.py @@ -40,3 +40,15 @@ def day_start_utc(tz_str: str = "UTC") -> datetime: tz = ZoneInfo("UTC") local_midnight = datetime(user_today.year, user_today.month, user_today.day, tzinfo=tz) return local_midnight.astimezone(ZoneInfo("UTC")) + + +def get_week_boundaries(d: date | None = None, tz_str: str = "UTC") -> tuple[date, date]: + """Return (Monday, Sunday) of the week containing date d. + + If d is None, uses today in the given timezone. + """ + if d is None: + d = today_for_user(tz_str) + monday = d - __import__("datetime").timedelta(days=d.weekday()) + sunday = monday + __import__("datetime").timedelta(days=6) + return monday, sunday