diff --git a/gcal/widget.go b/gcal/widget.go index 8baf3422..cf07d109 100644 --- a/gcal/widget.go +++ b/gcal/widget.go @@ -117,6 +117,10 @@ func (widget *Widget) until(start time.Time) string { duration = duration.Round(time.Minute) + if duration < 0 { + return "" + } + days := duration / (24 * time.Hour) duration -= days * (24 * time.Hour) diff --git a/weather/client.go b/weather/client.go index 3725d62b..765cd88b 100644 --- a/weather/client.go +++ b/weather/client.go @@ -6,15 +6,24 @@ import ( owm "github.com/briandowns/openweathermap" ) +/* -------------------- Exported Functions -------------------- */ + func Fetch() *owm.CurrentWeatherData { apiKey := os.Getenv("WTF_OWM_API_KEY") + vancouver := 6173331 + return currentWeather(apiKey, vancouver) +} + +/* -------------------- Unexported Functions -------------------- */ + +func currentWeather(apiKey string, cityCode int) *owm.CurrentWeatherData { weather, err := owm.NewCurrent("C", "EN", apiKey) if err != nil { panic(err) } - weather.CurrentByID(6173331) + weather.CurrentByID(cityCode) return weather }