mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
radar: support delays
This commit is contained in:
parent
aeac22b569
commit
9e5e8b9d56
3 changed files with 28 additions and 4 deletions
|
@ -76,7 +76,9 @@ The response may look like this:
|
|||
}
|
||||
},
|
||||
arrival: null,
|
||||
departure: '2017-12-17T19:16:00.000+01:00'
|
||||
arrivalDelay: null,
|
||||
departure: '2017-12-17T19:16:00.000+01:00',
|
||||
departureDelay: null
|
||||
} /* … */ ],
|
||||
frames: [ {
|
||||
origin: {
|
||||
|
@ -123,11 +125,15 @@ The response may look like this:
|
|||
nextStops: [ {
|
||||
station: { /* S+U Alexanderplatz/Dircksenstr. */ },
|
||||
arrival: null,
|
||||
departure: '2017-12-17T19:52:00.000+01:00'
|
||||
arrivalDelay: null,
|
||||
departure: '2017-12-17T19:52:00.000+01:00',
|
||||
departureDelay: null
|
||||
}, {
|
||||
station: { /* Memhardstr. */ },
|
||||
arrival: '2017-12-17T19:54:00.000+01:00',
|
||||
departure: '2017-12-17T19:54:00.000+01:00'
|
||||
arrivalDelay: null,
|
||||
departure: '2017-12-17T19:54:00.000+01:00',
|
||||
departureDelay: null
|
||||
}, /* … */ ],
|
||||
frames: [ {
|
||||
origin: { /* S+U Alexanderplatz/Dircksenstr. */ },
|
||||
|
|
|
@ -17,11 +17,23 @@ const createParseMovement = (profile, locations, lines, remarks) => {
|
|||
? profile.parseDateTime(profile, m.date, s.aTimeR || s.aTimeS)
|
||||
: null
|
||||
|
||||
return {
|
||||
const res = {
|
||||
station: locations[s.locX],
|
||||
departure: dep ? dep.toISO() : null,
|
||||
arrival: arr ? arr.toISO() : null
|
||||
}
|
||||
|
||||
if (m.dTimeR && m.dTimeS) {
|
||||
const plannedDep = profile.parseDateTime(profile, m.date, s.dTimeS)
|
||||
res.departureDelay = Math.round((dep - plannedDep) / 1000)
|
||||
} else res.departureDelay = null
|
||||
|
||||
if (m.aTimeR && m.aTimeS) {
|
||||
const plannedArr = profile.parseDateTime(profile, m.date, s.aTimeS)
|
||||
res.arrivalDelay = Math.round((arr - plannedArr) / 1000)
|
||||
} else res.arrivalDelay = null
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
const res = {
|
||||
|
|
|
@ -81,6 +81,12 @@ const isValidDateTime = (w) => {
|
|||
const assertValidStopover = (t, s, coordsOptional = false) => {
|
||||
if ('arrival' in s) t.ok(isValidDateTime(s.arrival))
|
||||
if ('departure' in s) t.ok(isValidDateTime(s.departure))
|
||||
if (s.arrivalDelay !== null && s.arrivalDelay !== undefined) {
|
||||
t.equal(typeof s.arrivalDelay, 'number')
|
||||
}
|
||||
if (s.departureDelay !== null && s.departureDelay !== undefined) {
|
||||
t.equal(typeof s.departureDelay, 'number')
|
||||
}
|
||||
if (!('arrival' in s) && !('departure' in s)) {
|
||||
t.fail('stopover doesn\'t contain arrival or departure')
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue