Full date

This commit is contained in:
Phillip Kühne 2019-11-01 21:14:12 +01:00
parent 806d3a270a
commit 59c28f437d

View File

@ -14,11 +14,10 @@ function printResult(departures,respdata) {
if (element['delay'] != 0) { if (element['delay'] != 0) {
delay = element['delay'] / 60 delay = element['delay'] / 60
} }
outstr += (cutPadString(element['line']['id'], 4).toUpperCase() + " " + cutPadString(element['direction'], 20) + " " + cutPadString(getTime(element['when']), 6) + delay + "\n")
respdata['departures'].push({ respdata['departures'].push({
"line": element['line']['id'], "line": element['line']['id'],
"direction": element['direction'], "direction": element['direction'],
"time": getTime(element['when']), "time": element['when'],
"delay": delay "delay": delay
}) })
@ -42,11 +41,6 @@ async function getNearestStationDepartures(lat, lon) {
return printResult(departures,respdata) return printResult(departures,respdata)
} }
function getTime(stringTime) {
let d = new Date(stringTime)
return String(d.getHours()).padStart(2, "0") + ":" + String(d.getMinutes()).padStart(2, "0")
}
function cutPadString(string, length) { function cutPadString(string, length) {
let outstring = "" let outstring = ""
if (string.length > length) { if (string.length > length) {