summaryrefslogtreecommitdiffstats
path: root/weather
diff options
context:
space:
mode:
Diffstat (limited to 'weather')
-rw-r--r--weather/weather.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/weather/weather.go b/weather/weather.go
index 7b7161a..3a2f9f8 100644
--- a/weather/weather.go
+++ b/weather/weather.go
@@ -10,6 +10,7 @@ import (
"ricketyspace.net/peach/nws"
"ricketyspace.net/peach/photon"
+ t "ricketyspace.net/peach/time"
"ricketyspace.net/peach/version"
)
@@ -138,3 +139,19 @@ func NewWeather(lat, lng float32) (*Weather, error, int) {
}
return w, nil, 200
}
+
+func humidity(g *nws.ForecastGrid) (int, error) {
+ if g == nil {
+ return 0, fmt.Errorf("humdity: forecast grid data empty")
+ }
+ for _, v := range g.Properties.RelativeHumidity.Values {
+ yes, err := t.IsCurrent(v.ValidTime)
+ if err != nil {
+ return 0, fmt.Errorf("humidity: %v", err)
+ }
+ if yes {
+ return v.Value, nil
+ }
+ }
+ return 0, fmt.Errorf("humidity: not found")
+}