I am making a bus time page for a singular bus stop and need help using data from the API to display times in a clear way. I currently extract data raw from the API and the time till the bus arrives is given in seconds (from the API) and the time outputs in ISO 8601 format. I would like to output time to the bus stop in minutes with the actual time outputted. I am using Django for this and attached is my code.
HTML code:
{% for i in response %}
<button class="button">{{i.lineId}} to
{{i.destinationName}} </button> |
<body class="time"> <!--{{i.timeToStation}} seconds |--> {{i.expectedArrival}}</body> <button class ="button" style= background-color:yellow>Registration Plate: {{i.vehicleId}}</button><br><br>
{% endfor %}
Views.py:
def home2(request):
bluewater = '2400A070090A'
response=requests.get(f'https://api.tfl.gov.uk/StopPoint/{bluewater}/Arrivals')
data = response.json()
return render(request,'home.html',{'response':data})