Skip to content

Commit

Permalink
forecast backend: time type float -> int
Browse files Browse the repository at this point in the history
  • Loading branch information
schachmat committed May 5, 2016
1 parent 63a126f commit dfa313d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions backends/forecast.io.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ type forecastConfig struct {
}

type forecastDataPoint struct {
Time *float64 `json:"time"`
Time *int64 `json:"time"`
Summary string `json:"summary"`
Icon string `json:"icon"`
SunriseTime *float32 `json:"sunriseTime"`
SunsetTime *float32 `json:"sunsetTime"`
SunriseTime *int64 `json:"sunriseTime"`
SunsetTime *int64 `json:"sunsetTime"`
PrecipIntensity *float32 `json:"precipIntensity"`
PrecipProbability *float32 `json:"precipProbability"`
PrecipProb *float32 `json:"precipProbability"`
Temperature *float32 `json:"temperature"`
TemperatureMin *float32 `json:"temperatureMin"`
TemperatureMax *float32 `json:"temperatureMax"`
Expand Down Expand Up @@ -62,12 +62,12 @@ const (

func (c *forecastConfig) parseAstro(cur *iface.Day, days []forecastDataPoint) {
for _, day := range days {
if day.Time != nil && cur.Date.Day() == time.Unix(int64(*day.Time), 0).In(c.tz).Day() {
if day.Time != nil && cur.Date.Day() == time.Unix(*day.Time, 0).In(c.tz).Day() {
if day.SunriseTime != nil {
cur.Astronomy.Sunrise = time.Unix(int64(*day.SunriseTime), 0).In(c.tz)
cur.Astronomy.Sunrise = time.Unix(*day.SunriseTime, 0).In(c.tz)
}
if day.SunsetTime != nil {
cur.Astronomy.Sunset = time.Unix(int64(*day.SunsetTime), 0).In(c.tz)
cur.Astronomy.Sunset = time.Unix(*day.SunsetTime, 0).In(c.tz)
}
return
}
Expand Down Expand Up @@ -121,7 +121,7 @@ func (c *forecastConfig) parseCond(dp forecastDataPoint) (ret iface.Cond, err er
if dp.Time == nil {
return iface.Cond{}, fmt.Errorf("The forecast.io response did not provide a time for the weather condition")
}
ret.Time = time.Unix(int64(*dp.Time), 0).In(c.tz)
ret.Time = time.Unix(*dp.Time, 0).In(c.tz)

ret.Code = iface.CodeUnknown
if val, ok := codemap[dp.Icon]; ok {
Expand All @@ -132,8 +132,8 @@ func (c *forecastConfig) parseCond(dp forecastDataPoint) (ret iface.Cond, err er
ret.TempC = dp.Temperature
ret.FeelsLikeC = dp.ApparentTemperature

if dp.PrecipProbability != nil {
p := int(*dp.PrecipProbability * 100)
if dp.PrecipProb != nil && *dp.PrecipProb >= 0 && *dp.PrecipProb <= 1 {
p := int(*dp.PrecipProb * 100)
ret.ChanceOfRainPercent = &p
}

Expand Down

0 comments on commit dfa313d

Please sign in to comment.