mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Don't display calendar until() time if in the past
This commit is contained in:
parent
12e6b2a9f2
commit
faa4a915c4
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user