Skip to content

Commit

Permalink
Openmeteo correction for daily astronomy.
Browse files Browse the repository at this point in the history
Current openweather api usage does not have daily astronomy. Api "onecall" seems to have.
  • Loading branch information
Pedro Pereira committed Sep 25, 2024
1 parent 06c3942 commit e69b5a5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions backends/open-meteo.com.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit e69b5a5

Please sign in to comment.