AI_Agro_Support/pipeline/window.py
Arsham Mirehvandi 099d1e0af9 Initial commit
2026-08-22 08:47:56 +02:00

26 lines
807 B
Python

"""Date-window helpers for the 11-day pipeline horizon."""
from __future__ import annotations
from datetime import date, timedelta
def build_window(as_of: date) -> list[date]:
"""Return the inclusive date list from as_of-5 through as_of+5."""
return [as_of + timedelta(days=offset) for offset in range(-5, 6)]
def past_days(as_of: date) -> list[date]:
"""Days strictly before as_of within the window (as_of-5 .. as_of-1)."""
return [as_of + timedelta(days=offset) for offset in range(-5, 0)]
def today_and_future(as_of: date) -> list[date]:
"""as_of through as_of+5 inclusive."""
return [as_of + timedelta(days=offset) for offset in range(0, 6)]
def format_date(d: date) -> str:
"""Format a date as DD-MM-YYYY for the JSON payload."""
return d.strftime("%d-%m-%Y")