diff options
author | r11baka <r11baka@gmail.com> | 2017-03-11 11:04:50 +0200 |
---|---|---|
committer | schachmat <schachmat@users.noreply.github.com> | 2017-03-11 11:37:34 +0100 |
commit | 59e0142a998397fa2a69e45b3d950da5c1d1246b (patch) | |
tree | 7c2b9a51d86668dc0ac18cf3b16a98640dc092d4 | |
parent | 3dc651ba95acb052b82772707bfa81e6c6d6613e (diff) |
add metric-ms unit
according to https://github.com/schachmat/wego/issues/106
-rw-r--r-- | iface/iface.go | 7 | ||||
-rw-r--r-- | main.go | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/iface/iface.go b/iface/iface.go index 50beed6..6409118 100644 --- a/iface/iface.go +++ b/iface/iface.go @@ -114,10 +114,11 @@ const ( UnitsMetric UnitSystem = iota UnitsImperial UnitsSi + UnitsMetricMs ) func (u UnitSystem) Temp(tempC float32) (res float32, unit string) { - if u == UnitsMetric { + if u == UnitsMetric || u == UnitsMetricMs { return tempC, "°C" } else if u == UnitsImperial { return tempC*1.8 + 32, "°F" @@ -133,7 +134,7 @@ func (u UnitSystem) Speed(spdKmph float32) (res float32, unit string) { return spdKmph, "km/h" } else if u == UnitsImperial { return spdKmph / 1.609, "mph" - } else if u == UnitsSi { + } else if u == UnitsSi || u == UnitsMetricMs { return spdKmph / 3.6, "m/s" } log.Fatalln("Unknown unit system:", u) @@ -141,7 +142,7 @@ func (u UnitSystem) Speed(spdKmph float32) (res float32, unit string) { } func (u UnitSystem) Distance(distM float32) (res float32, unit string) { - if u == UnitsMetric || u == UnitsSi { + if u == UnitsMetric || u == UnitsSi || u == UnitsMetricMs{ if distM < 1 { return distM * 1000, "mm" } else if distM < 1000 { @@ -47,7 +47,7 @@ func main() { numdays := flag.Int("days", 3, "`NUMBER` of days of weather forecast to be displayed") flag.IntVar(numdays, "d", 3, "`NUMBER` of days of weather forecast to be displayed (shorthand)") unitSystem := flag.String("units", "metric", "`UNITSYSTEM` to use for output.\n \tChoices are: metric, imperial, si") - flag.StringVar(unitSystem, "u", "metric", "`UNITSYSTEM` to use for output. (shorthand)\n \tChoices are: metric, imperial, si") + flag.StringVar(unitSystem, "u", "metric", "`UNITSYSTEM` to use for output. (shorthand)\n \tChoices are: metric, imperial, si , metric-ms") selectedBackend := flag.String("backend", "forecast.io", "`BACKEND` to be used") flag.StringVar(selectedBackend, "b", "forecast.io", "`BACKEND` to be used (shorthand)") selectedFrontend := flag.String("frontend", "ascii-art-table", "`FRONTEND` to be used") @@ -87,6 +87,8 @@ func main() { unit = iface.UnitsImperial } else if *unitSystem == "si" { unit = iface.UnitsSi + } else if *unitSystem == "metric-ms" { + unit = iface.UnitsMetricMs } // get selected frontend and render the weather data with it |