""" Daily intake-window helpers. Intake runs on a schedule (8AM-3:30PM by default), so it's useful to know when a ticket arrived relative to the cutoff - a ticket created after INTAKE_CUTOFF_TIME didn't have a full window to get processed same-day, which helps explain carryover rather than just seeing it as unexplained backlog. """ from __future__ import annotations import datetime as dt from typing import Optional from app import config def parse_cutoff_time(raw: str) -> Optional[dt.time]: raw = (raw or "").strip() if not raw: return None try: hour_str, minute_str = raw.split(":") return dt.time(int(hour_str), int(minute_str)) except (ValueError, TypeError): return None def get_cutoff_time() -> Optional[dt.time]: return parse_cutoff_time( config.get("INTAKE_CUTOFF_TIME", config.DEFAULT_INTAKE_CUTOFF_TIME) ) def is_past_cutoff(created_at: Optional[dt.datetime], cutoff: Optional[dt.time]) -> bool: if not created_at or not cutoff: return False return created_at.time() > cutoff