Fix: 31. des Monats fehlt – API-End auf Monatsersten (exklusiv) gesetzt
end = first_of_this (Juni 1 00:00) statt May 31 23:59:59, damit APIs mit exklusivem End-Parameter alle Tage des letzten Monats liefern. Zusätzlich ±12h Padding auf xlim der Linien-Charts (wie Balkendiagramm). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+4
-4
@@ -48,8 +48,8 @@ plt.rcParams.update({
|
||||
def last_month_range() -> tuple[datetime, datetime, str]:
|
||||
today = datetime.now(timezone.utc)
|
||||
first_of_this = today.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
|
||||
end = first_of_this - timedelta(seconds=1)
|
||||
start = end.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
|
||||
start = (first_of_this - timedelta(days=1)).replace(day=1, hour=0, minute=0, second=0, microsecond=0)
|
||||
end = first_of_this # exklusives Ende: < Juni 1 = komplett Mai
|
||||
label = f"{MONTHS_DE[start.month - 1]} {start.year}"
|
||||
return start, end, label
|
||||
|
||||
@@ -121,7 +121,7 @@ def create_combined_chart(start: datetime, end: datetime, label: str) -> bytes:
|
||||
ax.fill_between(dates_mm, t_min, t_max, alpha=0.12, color="#888888")
|
||||
ax.set_title("Temperaturverlauf (Tages-Min / Tages-Max)", fontweight="bold", pad=10)
|
||||
ax.set_ylabel("Temperatur (°C)")
|
||||
ax.set_xlim(start, end)
|
||||
ax.set_xlim(start - timedelta(hours=12), end + timedelta(hours=12))
|
||||
ax.xaxis.set_major_formatter(mdates.DateFormatter("%d.%m."))
|
||||
ax.xaxis.set_major_locator(mdates.DayLocator(interval=3))
|
||||
plt.setp(ax.get_xticklabels(), rotation=0, ha="center")
|
||||
@@ -132,7 +132,7 @@ def create_combined_chart(start: datetime, end: datetime, label: str) -> bytes:
|
||||
ax.plot(dates_h, temps, color="#2a7be0", linewidth=1.5, label="Stundenmittel")
|
||||
ax.set_title("Temperaturverlauf (Stundenmittel)", fontweight="bold", pad=10)
|
||||
ax.set_ylabel("Temperatur (°C)")
|
||||
ax.set_xlim(start, end)
|
||||
ax.set_xlim(start - timedelta(hours=12), end + timedelta(hours=12))
|
||||
ax.xaxis.set_major_formatter(mdates.DateFormatter("%d.%m."))
|
||||
ax.xaxis.set_major_locator(mdates.DayLocator(interval=3))
|
||||
plt.setp(ax.get_xticklabels(), rotation=0, ha="center")
|
||||
|
||||
Reference in New Issue
Block a user