Fetch DB long distance train numbers for a given time interval.
npm install --save db-train-numbers
const trainNumbers = require('db-train-numbers')
const start = new Date('2018-06-19T05:30:00')
const end = new Date('2018-06-19T08:30:00')
const opt = { // defaults
interval: 10 // lookup train numbers every * minutes between start and end
}
trainNumbers(start, end, opt)
.then(console.log)
.catch(console.error)
Returns a Promise that will resolve in an array of train objects which looks as follows:
[
{
train: "IC 11840",
journeyRef: "84/326594/18/19/80",
lastDeparture: "2018-06-19T03:21:00.000Z"
},
{
train: "IC 528",
journeyRef: "84/324965/18/19/80",
lastDeparture: "2018-06-19T03:24:00.000Z"
},
{
train: "EN 40467",
journeyRef: "84/267796/18/19/80",
lastDeparture: "2018-06-18T03:12:00.000Z"
},
{
train: "IC 516",
journeyRef: "84/257824/18/19/80",
lastDeparture: "2018-06-19T03:24:00.000Z"
},
{
train: "IC 3518",
journeyRef: "84/252900/18/19/80",
lastDeparture: "2018-06-19T03:33:00.000Z"
},
{
train: "ICE 71",
journeyRef: "84/215926/18/19/80",
lastDeparture: "2018-06-19T03:18:00.000Z"
},
{
train: "EC 7",
journeyRef: "84/215818/18/19/80",
lastDeparture: "2018-06-19T02:49:00.000Z"
}
// …
]
Fetch further information for trains using the journeyRef
attribute and the journeyLeg
method provided by the db-hafas
module.
You can use the lastDeparture
attribute with the db-wagenreihung
module.
If you found a bug or want to propose a feature, feel free to visit the issues page.