mirror of
https://github.com/Xevion/glance.git
synced 2025-12-09 10:07:24 -06:00
Allow changing between C and F for weather temp
This commit is contained in:
@@ -13,6 +13,7 @@ type Weather struct {
|
||||
widgetBase `yaml:",inline"`
|
||||
Location string `yaml:"location"`
|
||||
HideLocation bool `yaml:"hide-location"`
|
||||
Units string `yaml:"units"`
|
||||
Place *feed.PlaceJson `yaml:"-"`
|
||||
Weather *feed.Weather `yaml:"-"`
|
||||
TimeLabels [12]string `yaml:"-"`
|
||||
@@ -24,6 +25,12 @@ func (widget *Weather) Initialize() error {
|
||||
widget.withTitle("Weather").withCacheOnTheHour()
|
||||
widget.TimeLabels = timeLabels
|
||||
|
||||
if widget.Units == "" {
|
||||
widget.Units = "metric"
|
||||
} else if widget.Units != "metric" && widget.Units != "imperial" {
|
||||
return fmt.Errorf("invalid units '%s' for weather, must be either metric or imperial", widget.Units)
|
||||
}
|
||||
|
||||
place, err := feed.FetchPlaceFromName(widget.Location)
|
||||
|
||||
if err != nil {
|
||||
@@ -36,7 +43,7 @@ func (widget *Weather) Initialize() error {
|
||||
}
|
||||
|
||||
func (widget *Weather) Update(ctx context.Context) {
|
||||
weather, err := feed.FetchWeatherForPlace(widget.Place)
|
||||
weather, err := feed.FetchWeatherForPlace(widget.Place, widget.Units)
|
||||
|
||||
if !widget.canContinueUpdateAfterHandlingErr(err) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user