diff --git a/cmd/now.go b/cmd/now.go index 8d11a09..4aa5396 100644 --- a/cmd/now.go +++ b/cmd/now.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "os" + "time" "git.sr.ht/~timharek/yr-go/cmd/flags" "git.sr.ht/~timharek/yr-go/internal/nominatim" @@ -26,6 +27,8 @@ func init() { func now(cmd *cobra.Command, args []string) { isJson, err := cmd.Flags().GetBool(flags.JSON) cobra.CheckErr(err) + isUTC, err := cmd.Flags().GetBool(flags.UTC) + cobra.CheckErr(err) lon, _ := cmd.Flags().GetFloat64(flags.LON) lat, _ := cmd.Flags().GetFloat64(flags.LAT) @@ -55,12 +58,19 @@ func now(cmd *cobra.Command, args []string) { return } + itemTime := n.Time.Local() + if isUTC { + itemTime = n.Time + } fmt.Printf( - `Current forecast for %s + `%s now: + %s Temperature: %.1f °C Rain: %.1f mm - Wind: %.1f m/s from %s`, + Wind: %.1f m/s from %s +`, n.Location, + itemTime.Format(time.DateTime), n.Temperature, n.Percipitation, n.Wind.Speed,