Skip to content

Commit

Permalink
Openmeteo correction for daily astronomy. (schachmat#190)
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.

Co-authored-by: Pedro Pereira <[email protected]>
  • Loading branch information
peter81git and Pedro Pereira authored Oct 6, 2024
1 parent 75ab651 commit 2127ad0
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 2127ad0

Please sign in to comment.