From a638c0b678654616022ba3eb461f6788f238985a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20H=C3=A5rek=20Andreassen?= Date: Wed, 2 Oct 2024 21:04:58 +0200 Subject: [PATCH] chore: Add newline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tim Hårek Andreassen --- cmd/now.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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,