chore: Better times

Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
This commit is contained in:
Tim Hårek Andreassen 2024-10-03 22:48:50 +02:00
parent f1aa9cbf16
commit c5cb76a731
No known key found for this signature in database
GPG key ID: E59C7734F0E10EB5
2 changed files with 3 additions and 6 deletions

View file

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
"time"
"git.sr.ht/~timharek/yr/cmd/flags" "git.sr.ht/~timharek/yr/cmd/flags"
"git.sr.ht/~timharek/yr/cmd/internal/ui/table" "git.sr.ht/~timharek/yr/cmd/internal/ui/table"
@ -83,7 +82,7 @@ func forecast(cmd *cobra.Command, args []string) {
itemTime = item.Time itemTime = item.Time
} }
t.Row( t.Row(
itemTime.Format(time.DateTime), itemTime.Format("Mon, 2 Jan 15:04"),
fmt.Sprintf("%.1f °C", item.Temperature), fmt.Sprintf("%.1f °C", item.Temperature),
fmt.Sprintf("%.1f mm", item.Percipitation), fmt.Sprintf("%.1f mm", item.Percipitation),
fmt.Sprintf("%.1f m/s %s", item.Wind.Speed, item.Wind.DirectionToString()), fmt.Sprintf("%.1f m/s %s", item.Wind.Speed, item.Wind.DirectionToString()),

View file

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
"time"
"git.sr.ht/~timharek/yr/cmd/flags" "git.sr.ht/~timharek/yr/cmd/flags"
"git.sr.ht/~timharek/yr/internal/nominatim" "git.sr.ht/~timharek/yr/internal/nominatim"
@ -77,14 +76,13 @@ func now(cmd *cobra.Command, args []string) {
itemTime = n.Time itemTime = n.Time
} }
fmt.Printf( fmt.Printf(
`%s now: `%s %s:
%s
Temperature: %.1f °C Temperature: %.1f °C
Rain: %.1f mm Rain: %.1f mm
Wind: %.1f m/s from %s Wind: %.1f m/s from %s
`, `,
n.Location, n.Location,
itemTime.Format(time.DateTime), itemTime.Format("Monday 2 Jan 15:04"),
n.Temperature, n.Temperature,
n.Percipitation, n.Percipitation,
n.Wind.Speed, n.Wind.Speed,