diff --git a/api/advent22_api/routers/days.py b/api/advent22_api/routers/days.py index d564d86..96e858e 100644 --- a/api/advent22_api/routers/days.py +++ b/api/advent22_api/routers/days.py @@ -32,18 +32,23 @@ async def get_date() -> str: return date.today().isoformat() +@router.get("/number") +async def get_number() -> int: + today = date.today() + + if today.month == 12: + return today.day + + if today.month in (1, 2, 3): + return 24 + + return 0 + + async def user_can_view( index: int, ) -> bool: - today = date.today() - - if today.month in (1, 2, 3): - return True - - elif today.month == 12: - return index < today.day - - return False + return index < await get_number() @router.get(