minor tweaks

This commit is contained in:
Jannis R 2020-09-10 23:57:03 +02:00
parent 43bd9cf65b
commit a621fd6df4
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 9 additions and 11 deletions

2
.gitignore vendored
View file

@ -6,5 +6,3 @@ node_modules
npm-debug.log
package-lock.json
/id.json

View file

@ -48,18 +48,18 @@ const parseJourneyLeg = (ctx, pt, date) => { // pt = raw leg
destination: clone(pt.arr.location)
}
const arr = profile.parseWhen(ctx, date, pt.arr.aTimeS, pt.arr.aTimeR, pt.arr.aTZOffset, pt.arr.aCncl)
res.arrival = arr.when
res.plannedArrival = arr.plannedWhen
res.arrivalDelay = arr.delay
if (arr.prognosedWhen) res.prognosedArrival = arr.prognosedWhen
const dep = profile.parseWhen(ctx, date, pt.dep.dTimeS, pt.dep.dTimeR, pt.dep.dTZOffset, pt.dep.dCncl)
res.departure = dep.when
res.plannedDeparture = dep.plannedWhen
res.departureDelay = dep.delay
if (dep.prognosedWhen) res.prognosedDeparture = dep.prognosedWhen
const arr = profile.parseWhen(ctx, date, pt.arr.aTimeS, pt.arr.aTimeR, pt.arr.aTZOffset, pt.arr.aCncl)
res.arrival = arr.when
res.plannedArrival = arr.plannedWhen
res.arrivalDelay = arr.delay
if (arr.prognosedWhen) res.prognosedArrival = arr.prognosedWhen
if (pt.jny && ('isRchbl' in pt.jny)) {
res.reachable = !!pt.jny.isRchbl
}

View file

@ -53,7 +53,7 @@ const testEarlierLaterJourneys = async (cfg) => {
let earliestDep = Infinity, latestDep = -Infinity
for (let j of model.journeys) {
if (j.legs[0].departure === null) continue
const dep = +new Date(j.legs[0].departure)
const dep = Date.parse(j.legs[0].departure)
if (dep < earliestDep) earliestDep = dep
else if (dep > latestDep) latestDep = dep
}
@ -65,7 +65,7 @@ const testEarlierLaterJourneys = async (cfg) => {
})
for (let j of earlier.journeys) {
const firstLeg = j.legs[0]
const dep = new Date(firstLeg.departure || firstLeg.plannedDeparture)
const dep = Date.parse(firstLeg.departure || firstLeg.plannedDeparture)
t.ok(dep < earliestDep)
}
@ -76,7 +76,7 @@ const testEarlierLaterJourneys = async (cfg) => {
})
for (let j of later.journeys) {
const firstLeg = j.legs[0]
const dep = new Date(firstLeg.departure || firstLeg.plannedDeparture)
const dep = Date.parse(firstLeg.departure || firstLeg.plannedDeparture)
t.ok(dep > latestDep)
}
}