From e69b5a53ab039c1d423ed16d9bceaa44bfe9654e Mon Sep 17 00:00:00 2001 From: Pedro Pereira Date: Wed, 25 Sep 2024 09:30:01 +0100 Subject: [PATCH] Openmeteo correction for daily astronomy. Current openweather api usage does not have daily astronomy. Api "onecall" seems to have. --- backends/open-meteo.com.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backends/open-meteo.com.go b/backends/open-meteo.com.go index 696ba1e..76747ff 100644 --- a/backends/open-meteo.com.go +++ b/backends/open-meteo.com.go @@ -213,12 +213,13 @@ func (opmeteo *openmeteoConfig) Fetch(location string, numdays int) iface.Data { forecast := opmeteo.parseDaily(resp.Hourly) + for i, _ := range forecast { + forecast[i].Astronomy.Sunset = time.Unix(resp.Daily.Sunset[i], 0) + forecast[i].Astronomy.Sunrise = time.Unix(resp.Daily.Sunrise[i], 0) + } if len(forecast) > 0 { - forecast[0].Astronomy.Sunset = time.Unix(resp.Daily.Sunset[0], 0) - forecast[0].Astronomy.Sunrise = time.Unix(resp.Daily.Sunrise[0], 0) ret.Forecast = forecast } - return ret }