diff --git a/__pycache__/app.cpython-310.pyc b/__pycache__/app.cpython-310.pyc index 6218ade..426bc30 100644 Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ diff --git a/app.py b/app.py index e40d95f..2c289ea 100644 --- a/app.py +++ b/app.py @@ -64,6 +64,14 @@ def _round_temp(k): def get_mosmix_forecast(lat, lon, hours=72): """Holt MOSMIX-Vorhersage für die nächsten Stunden.""" try: + # Zeitzone Berlin für alle Anzeige-Timestamps + try: + import zoneinfo + _berlin = zoneinfo.ZoneInfo("Europe/Berlin") + except ImportError: + import pytz + _berlin = pytz.timezone("Europe/Berlin") + req = DwdMosmixRequest(parameters=MOSMIX_PARAMS) nearest = req.filter_by_rank(latlon=(lat, lon), rank=1) result = nearest.values.all() @@ -119,7 +127,7 @@ def get_mosmix_forecast(lat, lon, hours=72): wind_dir = float(wind_dir_v) if not _isnan(wind_dir_v) else None forecast.append({ - "datetime": date_val, + "datetime": pd.Timestamp(date_val).tz_convert(_berlin).tz_localize(None), "temp_c": temp_c, "wind_kmh": wind_kmh, "gust_kmh": gust_kmh, @@ -200,7 +208,7 @@ def wetter(): station_lon = float(mosmix_station.get("longitude", lon)) station_dist = round(haversine(lat, lon, station_lat, station_lon), 1) - # "Aktuell" = erste Stunde >= jetzt (UTC), sonst erste verfügbare + # "Aktuell" = erste Stunde >= jetzt (Berliner Lokalzeit) now_utc = _dt.datetime.now(_dt.timezone.utc).replace(tzinfo=None) try: import zoneinfo @@ -208,12 +216,14 @@ def wetter(): except ImportError: import pytz berlin = pytz.timezone("Europe/Berlin") - now_local = _dt.datetime.now(berlin).strftime("%H:%M") + now_local_dt = _dt.datetime.now(berlin) + now_local = now_local_dt.strftime("%H:%M") + now_berlin_naive = now_local_dt.replace(tzinfo=None) current_idx = 0 for i, h in enumerate(forecast): dt = h["datetime"] dt_naive = dt.replace(tzinfo=None) if hasattr(dt, "tzinfo") and dt.tzinfo is not None else dt - if dt_naive >= now_utc: + if dt_naive >= now_berlin_naive: current_idx = i break current = forecast[current_idx]