db-vendo-client/parse/stopover.js

40 lines
1,021 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
const createParseStopover = (profile, stations, lines, remarks, date) => {
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, 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, 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
}
// mark stations the train passes without stopping
if(st.dInS === false && st.aOutS === false) res.passBy = true
// 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