Skip to content

Commit 2127ad0

Browse files
peter81gitPedro Pereira
and
Pedro Pereira
authored
Openmeteo correction for daily astronomy. (#190)
Current openweather api usage does not have daily astronomy. Api "onecall" seems to have. Co-authored-by: Pedro Pereira <[email protected]>
1 parent 75ab651 commit 2127ad0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

backends/open-meteo.com.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,13 @@ func (opmeteo *openmeteoConfig) Fetch(location string, numdays int) iface.Data {
213213

214214
forecast := opmeteo.parseDaily(resp.Hourly)
215215

216+
for i, _ := range forecast {
217+
forecast[i].Astronomy.Sunset = time.Unix(resp.Daily.Sunset[i], 0)
218+
forecast[i].Astronomy.Sunrise = time.Unix(resp.Daily.Sunrise[i], 0)
219+
}
216220
if len(forecast) > 0 {
217-
forecast[0].Astronomy.Sunset = time.Unix(resp.Daily.Sunset[0], 0)
218-
forecast[0].Astronomy.Sunrise = time.Unix(resp.Daily.Sunrise[0], 0)
219221
ret.Forecast = forecast
220222
}
221-
222223
return ret
223224
}
224225

0 commit comments

Comments
 (0)