db-vendo-client/parse/stopover.js

37 lines
931 B
JavaScript
Raw Normal View History

2017-11-11 22:35:41 +01:00
'use strict'
// todo: arrivalDelay, departureDelay or only delay ?
// todo: arrivalPlatform, departurePlatform
2017-11-12 01:23:34 +01:00
const createParseStopover = (profile, stations, lines, remarks, connection) => {
2017-11-11 22:35:41 +01:00
const parseStopover = (st) => {
const res = {
2017-11-12 00:36:13 +01:00
station: stations[parseInt(st.locX)] || null
2017-11-11 22:35:41 +01:00
}
if (st.aTimeR || st.aTimeS) {
const arr = profile.parseDateTime(profile, connection.date, st.aTimeR || st.aTimeS)
2017-12-11 19:40:46 +01:00
res.arrival = arr.toISO()
2017-11-11 22:35:41 +01:00
}
if (st.dTimeR || st.dTimeS) {
const dep = profile.parseDateTime(profile, connection.date, st.dTimeR || st.dTimeS)
2017-12-11 19:40:46 +01:00
res.departure = dep.toISO()
2017-11-11 22:35:41 +01:00
}
// 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
}
2017-11-11 22:35:41 +01:00
return res
}
return parseStopover
}
module.exports = createParseStopover