parseTrip: handle missing date 🐛

This commit is contained in:
Jannis R 2020-03-09 21:44:08 +01:00 committed by Jannis Redmann
parent 40ca838258
commit 7685d5afeb

View file

@ -14,8 +14,13 @@ const parseTrip = (ctx, t) => { // t = raw trip
arr: maxBy(t.stopL, 'idx') || last(t.stopL), arr: maxBy(t.stopL, 'idx') || last(t.stopL),
jny: t, jny: t,
} }
const trip = profile.parseJourneyLeg(ctx, fakeLeg, t.date)
// todo: this breaks if the trip starts on a different day
// how does HAFAS do this?
const today = () => profile.formatDate(profile, Date.now())
const date = t.date || today()
const trip = profile.parseJourneyLeg(ctx, fakeLeg, date)
trip.id = trip.tripId trip.id = trip.tripId
delete trip.tripId delete trip.tripId