Fix day label off-by-one in parse_open_meteo_forecast - #613
Conversation
- calendar.py: skip failed calendar URLs instead of crashing plugin - weather.py: fix Open-Meteo forecast day label off-by-one (PR fatihak#613) - model.py: remove duplicate scheduled refresh logic - refresh_task.py: add 60s timeout to prevent indefinite hangs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts: # src/plugins/weather/weather.py Co-authored-by: BaloMueller <793558+BaloMueller@users.noreply.github.com>
|
Hi @malawto, Thanks for the fix — the diagnosis looks correct and this still appears relevant against current main. One small cleanup resulting from this change: dt is now only used to calculate timestamp, and timestamp was already unused in this function. Could you remove both of these lines? dt = datetime.combine(local_date, datetime.min.time()).replace(tzinfo=tz) This would also avoid introducing the new .replace(tzinfo=tz) timezone assignment, which isn't needed now that the daily Open-Meteo value is being handled correctly as a date. It would also be useful to add a small regression test using a timezone west of UTC, such as America/New_York, to verify that a date like 2026-02-27 remains labelled Fri rather than being shifted back to Thu. Otherwise, the fix looks good to me. Thanks again, Matt. |
Fix day label and moon phase off-by-one in
parse_open_meteo_forecastOpen-Meteo daily
timevalues are date strings (e.g."2026-02-27"), not datetimes. The previous code parsed them with.replace(tzinfo=timezone.utc).astimezone(tz), which stamped them as UTC midnight and then shifted them into local time — rolling each date back to the previous evening. This caused every forecast card to display the wrong day label and the wrong day's high/low temperatures.A
timedelta(days=1)offset ontarget_datein the moon phase calculation was silently compensating for this same bug, keeping moon phases accidentally correct.This PR fixes the date parsing by using
date.fromisoformat()directly, and removes thetimedelta(days=1)offset that was masking the original error. The result is correct day labels, correct temperatures in each forecast card, and correct moon phases.