diff --git a/cmd/api/connection.go b/cmd/api/connection.go index 47a9189..18d66f1 100644 --- a/cmd/api/connection.go +++ b/cmd/api/connection.go @@ -43,6 +43,17 @@ func ParseConnections(body []byte) ([]Connection, error) { return result.Connection, nil } +func GetDurationInMinutes(c Connection) string { + duration, err := strconv.Atoi(c.Duration) + if err != nil { + fmt.Printf("Duration could not be parsed: %s", duration) + } + + duration /= 60 + + return strconv.Itoa(duration) + "m" +} + func (c Connection) GetDelayInSeconds() int { delay, err := strconv.Atoi(c.Departure.Delay) diff --git a/main.go b/main.go index c331e74..8dff507 100644 --- a/main.go +++ b/main.go @@ -43,7 +43,7 @@ func handleConnection(stationFrom string, stationTo string) { columns := []teaTable.Column{ {Title: "Departure", Width: 7}, - {Title: "", Width: 2}, + {Title: "", Width: 4}, {Title: "Duration", Width: 7}, {Title: "Arrival", Width: 7}, {Title: "Track", Width: 10}, @@ -61,7 +61,7 @@ func handleConnection(stationFrom string, stationTo string) { rows[i] = teaTable.Row{ cmd.UnixToHHMM(conn.Departure.Time), delay, - conn.Duration, + api.GetDurationInMinutes(conn), cmd.UnixToHHMM(conn.Arrival.Time), conn.Departure.Platform, } @@ -100,7 +100,7 @@ func handleTimetable(stationName string) { columns := []teaTable.Column{ {Title: "", Width: 5}, - {Title: "", Width: 4}, + {Title: "", Width: 5}, {Title: "Destination", Width: 20}, {Title: "Track", Width: 10}, }