Skip to content

Prevent first forecast from being for a previous date

Fix for #226 (closed)

OpenWeatherMap sometimes returns the previous day's forecast, especially in the early morning hours of the lat / lng being queried. To prevent the first forecast element in the UI from being the previous day's forecast, check for the returned forecast elements being for a previous day and maintain a forecast index advance counter to skip previous day forecasts.

Test setup: My location is London, UK. Time 04:56.

UI with code from current master unexpectedly shows yesterday's forecast as the first UI forecast element:

image

After fixing with this patch, today's forecast is the first UI forecast element:

image

Additionally, the UI is unchanged from before and after the patch if OpenWeatherMap stops returning data for the previous day (usually after 05:00 / 06:00, depending on the time zone).

UI with code from current master:

image

UI with code from this patch:

image

Merge request reports