From cea6002249705e3d576137e4d92873103a9aebbf Mon Sep 17 00:00:00 2001 From: Jimmy Kuo Date: Fri, 28 Jul 2017 04:15:59 +0800 Subject: [PATCH 1/2] Fixed uv uses corrupted URL. include Current UV & Historical UV. --- README.md | 2 +- openweathermap.go | 2 +- uv.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f5e260f..d38fd09 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ func main() { } ``` -### (Not working yet... OpenweatherMap Working out bugs) Historical UV conditions +### Historical UV conditions ```Go func main() { diff --git a/openweathermap.go b/openweathermap.go index 17bb068..bf5f080 100644 --- a/openweathermap.go +++ b/openweathermap.go @@ -36,7 +36,7 @@ var ( forecastBase = "http://api.openweathermap.org/data/2.5/forecast/daily?appid=%s&%s&mode=json&units=%s&lang=%s&cnt=%d" historyURL = "http://api.openweathermap.org/data/2.5/history/%s" pollutionURL = "http://api.openweathermap.org/pollution/v1/co/" - uvURL = "http://api.owm.io/air/1.0/uvi/" + uvURL = "http://api.openweathermap.org/data/2.5/" dataPostURL = "http://openweathermap.org/data/post" ) diff --git a/uv.go b/uv.go index cca66d2..d96fb76 100644 --- a/uv.go +++ b/uv.go @@ -44,7 +44,7 @@ func NewUV(options ...Option) (*UV, error) { // Current gets the current UV data for the given coordinates func (u *UV) Current(coord *Coordinates) error { - response, err := u.client.Get(fmt.Sprintf("%scurrent?lat=%f&lon=%f&appid=%s", uvURL, coord.Latitude, coord.Longitude, u.Key)) + response, err := u.client.Get(fmt.Sprintf("%suvi?lat=%f&lon=%f&appid=%s", uvURL, coord.Latitude, coord.Longitude, u.Key)) if err != nil { return err } @@ -59,7 +59,7 @@ func (u *UV) Current(coord *Coordinates) error { // Historical gets the historical UV data for the coordinates and times func (u *UV) Historical(coord *Coordinates, start, end time.Time) error { - response, err := u.client.Get(fmt.Sprintf("%slist?lat=%f&lon=%f&from=%d&to=%d&appid=%s", uvURL, coord.Latitude, coord.Longitude, start, end, u.Key)) + response, err := u.client.Get(fmt.Sprintf("%shistory?lat=%f&lon=%f&start=%d&end=%d&appid=%s", uvURL, coord.Latitude, coord.Longitude, start.Unix(), end.Unix(), u.Key)) if err != nil { return err } From 4a442544c449eb3ac91f4515fce79d2432c7b7cd Mon Sep 17 00:00:00 2001 From: Jimmy Kuo Date: Fri, 28 Jul 2017 04:33:35 +0800 Subject: [PATCH 2/2] Fixed typo in READMD.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d38fd09..227fdfe 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Gain access to OpenWeatherMap icons and condition codes. ### Data Available in Multiple Measurement Systems - Fahrenheit (OpenWeatherMap API - imperial) -- Celcius (OpenWeatherMap API - metric) +- Celsius (OpenWeatherMap API - metric) - Kelvin (OpenWeatherMap API - internal) ### UV Index Data