Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Display last update time in correct timezone (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
kochman authored and JCBird1012 committed Sep 14, 2017
1 parent 98934cb commit 67e8e7c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api/vehicles.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,16 @@ func (App *API) UpdateMessageHandler(w http.ResponseWriter, r *http.Request) {
if len(speed) > 4 {
speed = speed[0:4]
}
//nextArrival := GetArrivalTime(&update, App.Routes, App.Stops)
message = fmt.Sprintf("<b>%s</b><br/>Traveling %s at<br/> %s mph as of %s", vehicle.VehicleName, CardinalDirection(&update.Heading), speed, update.Created.Format("3:04:05pm") /*, nextArrival*/)

// Convert last updated time to local timezone
loc, err := time.LoadLocation("America/New_York")
if err != nil {
log.WithError(err).Error("Could not load time zone information.")
continue
}
lastUpdate := update.Created.In(loc).Format("3:04:05pm")

message = fmt.Sprintf("<b>%s</b><br/>Traveling %s at<br/> %s mph as of %s", vehicle.VehicleName, CardinalDirection(&update.Heading), speed, lastUpdate)
messages = append(messages, message)
}
}
Expand Down

0 comments on commit 67e8e7c

Please sign in to comment.