diff --git a/docs/departures.md b/docs/departures.md index 6396ccee..6c37a82e 100644 --- a/docs/departures.md +++ b/docs/departures.md @@ -95,8 +95,9 @@ The response may look like this: journeyId: '1|30977|8|86|17122017', trip: 30977, station: { /* … */ }, - when: '2017-12-17T19:35:00.000+01:00', - delay: 0, + when: null, + delay: null, + cancelled: true, line: { type: 'line', id: '16441', diff --git a/docs/journey-part.md b/docs/journey-part.md index b08d300a..faba512e 100644 --- a/docs/journey-part.md +++ b/docs/journey-part.md @@ -92,6 +92,7 @@ The response looked like this: } }, arrival: '2017-12-17T19:49:00.000+01:00', + arrivalPlatform: '2', line: { type: 'line', id: '18299', @@ -106,7 +107,6 @@ The response looked like this: night: false, productCode: 0 }, - arrivalPlatform: '2', direction: 'S Spandau', passed: [ /* … */ ] } diff --git a/docs/journeys.md b/docs/journeys.md index 29f9bb1c..4617936d 100644 --- a/docs/journeys.md +++ b/docs/journeys.md @@ -154,8 +154,9 @@ The response may look like this: location: { /* … */ }, products: { /* … */ } }, - arrival: '2017-12-17T19:06:00.000+01:00', - departure: '2017-12-17T19:07:00.000+01:00' + arrival: null, + departure: null, + cancelled: true }, { station: { type: 'station', @@ -234,3 +235,5 @@ If you pass `tickets: true`, each `journey` will have a tickets array that looks amount: 4 } ] ``` + +If a journey leg has been cancelled, a `cancelled: true` will be added. Also, `departure`/`departureDelay`/`departurePlatform` and `arrival`/`arrivalDelay`/`arrivalPlatform` will be `null`. diff --git a/parse/departure.js b/parse/departure.js index 7946b5b4..1db0f914 100644 --- a/parse/departure.js +++ b/parse/departure.js @@ -1,7 +1,6 @@ 'use strict' // todos from derhuerst/hafas-client#2 -// - stdStop.dCncl // - stdStop.dPlatfS, stdStop.dPlatfR // todo: what is d.jny.dirFlg? // todo: d.stbStop.dProgType @@ -29,6 +28,13 @@ const createParseDeparture = (profile, stations, lines, remarks) => { res.delay = Math.round((realtime - planned) / 1000) } else res.delay = null + // todo: follow public-transport/friendly-public-transport-format#27 here + // see also derhuerst/vbb-rest#19 + if (pt.arr.aCncl || pt.dep.dCncl) { + res.cancelled = true + res.when = res.delay = null + } + return res } diff --git a/parse/journey-part.js b/parse/journey-part.js index c1d8648b..9d66d792 100644 --- a/parse/journey-part.js +++ b/parse/journey-part.js @@ -66,11 +66,14 @@ const createParseJourneyPart = (profile, stations, lines, remarks) => { // todo: follow public-transport/friendly-public-transport-format#27 here // see also derhuerst/vbb-rest#19 - if (pt.arr.dCncl && pt.dep.dCncl) { - result.cancelled = true - result.departure = result.departurePlatform = null - result.arrival = result.arrivalPlatform = null - result.delay = null + if (pt.arr.aCncl) { + res.cancelled = true + res.arrival = res.arrivalPlatform = null + } + if (pt.dep.dCncl) { + res.cancelled = true + res.departure = res.departurePlatform = null + res.delay = null } return res diff --git a/parse/stopover.js b/parse/stopover.js index d7a3d24f..216d9c1b 100644 --- a/parse/stopover.js +++ b/parse/stopover.js @@ -1,5 +1,7 @@ 'use strict' +// todo: arrivalDelay, departureDelay or only delay ? +// todo: arrivalPlatform, departurePlatform const createParseStopover = (profile, stations, lines, remarks, connection) => { const parseStopover = (st) => { const res = { @@ -13,6 +15,18 @@ const createParseStopover = (profile, stations, lines, remarks, connection) => { const dep = profile.parseDateTime(profile, connection.date, st.dTimeR || st.dTimeS) res.departure = dep.toISO() } + + // todo: follow public-transport/friendly-public-transport-format#27 here + // see also derhuerst/vbb-rest#19 + if (st.aCncl) { + res.cancelled = true + res.arrival = null + } + if (st.dCncl) { + res.cancelled = true + res.departure = null + } + return res }