Use user input

This commit is contained in:
Andrew Scott 2022-08-02 23:56:24 -04:00
parent 76a4785a0f
commit 1cc715522e
Signed by: a
GPG key ID: 3EB62D0BBB8DB381

View file

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"strconv"
pb "codeberg.org/andcscott/weather-cli/proto" pb "codeberg.org/andcscott/weather-cli/proto"
) )
@ -49,14 +50,16 @@ func getUnixTime(c pb.RouteGuideClient) int32 {
// Query SimplrWeather for historical data // Query SimplrWeather for historical data
func getHistoricalData(c pb.RouteGuideClient, app *Application) { func getHistoricalData(c pb.RouteGuideClient, app *Application) {
var lat, lon, year, month, day int32 var lat, lon int
lat, _ = strconv.Atoi(app.Config.Latitude)
lon, _ = strconv.Atoi(app.Config.Longitude)
res, err := c.GetHistoricalData(context.Background(), &pb.LocationDate{ res, err := c.GetHistoricalData(context.Background(), &pb.LocationDate{
Latitude: lat, Latitude: int32(lat),
Longitude: lon, Longitude: int32(lon),
Year: year, Year: app.Config.Date.Year,
Month: month, Month: app.Config.Date.Month,
Day: day, Day: app.Config.Date.Day,
}) })
if err != nil { if err != nil {
fmt.Printf("Error getting historical data: %v", err) fmt.Printf("Error getting historical data: %v", err)