fix cancelled journey legs 🐛, cancelled departures & passed stations, 1.3.1

This commit is contained in:
Jannis R 2017-12-18 20:59:20 +01:00
parent 4ee1b27ae6
commit abf323d27c
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 13 additions and 3 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "hafas-client", "name": "hafas-client",
"description": "JavaScript client for HAFAS mobile APIs.", "description": "JavaScript client for HAFAS mobile APIs.",
"version": "1.3.0", "version": "1.3.1",
"main": "index.js", "main": "index.js",
"files": [ "files": [
"index.js", "index.js",

View file

@ -73,6 +73,9 @@ const stopover = (tz, s, ln, r, c) => (st) => {
if (st.dTimeR || st.dTimeS) { if (st.dTimeR || st.dTimeS) {
result.departure = dateTime(tz, c.date, st.dTimeR || st.dTimeS).format() result.departure = dateTime(tz, c.date, st.dTimeR || st.dTimeS).format()
} }
if (st.aCncl && st.dCncl) {
result.cancelled = true
}
return result return result
} }
@ -121,7 +124,9 @@ const part = (tz, s, ln, r, c) => (pt) => {
} }
// todo: follow public-transport/friendly-public-transport-format#27 here // todo: follow public-transport/friendly-public-transport-format#27 here
if (pt.dep.dCncl && pt.arr.dCncl) result.cancelled = true if (pt.dep.dCncl && pt.arr.aCncl) {
result.cancelled = true
}
return result return result
} }
@ -144,7 +149,6 @@ const journey = (tz, s, ln, r, p = part) => (c) => {
} }
// todos from derhuerst/hafas-client#2 // todos from derhuerst/hafas-client#2
// - stdStop.dCncl
// - stdStop.dPlatfS, stdStop.dPlatfR // - stdStop.dPlatfS, stdStop.dPlatfR
// todo: what is d.jny.dirFlg? // todo: what is d.jny.dirFlg?
// todo: d.stbStop.dProgType // todo: d.stbStop.dProgType
@ -164,6 +168,12 @@ const departure = (tz, s, ln, r) => (d) => {
const planned = dateTime(tz, d.date, d.stbStop.dTimeS) const planned = dateTime(tz, d.date, d.stbStop.dTimeS)
result.delay = Math.round((realtime - planned) / 1000) result.delay = Math.round((realtime - planned) / 1000)
} else result.delay = null } else result.delay = null
// todo: follow public-transport/friendly-public-transport-format#27 here
if (d.stbStop.dCncl) {
result.cancelled = true
}
return result return result
} }