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.
This commit is contained in:
parent
ad3da57174
commit
c56d6d5816
1 changed files with 12 additions and 0 deletions
|
|
@ -40,3 +40,15 @@ def day_start_utc(tz_str: str = "UTC") -> datetime:
|
||||||
tz = ZoneInfo("UTC")
|
tz = ZoneInfo("UTC")
|
||||||
local_midnight = datetime(user_today.year, user_today.month, user_today.day, tzinfo=tz)
|
local_midnight = datetime(user_today.year, user_today.month, user_today.day, tzinfo=tz)
|
||||||
return local_midnight.astimezone(ZoneInfo("UTC"))
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue