From 7685d5afeb987ae1f6d6b22084d04c22ec887cc8 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Mon, 9 Mar 2020 21:44:08 +0100 Subject: [PATCH] =?UTF-8?q?parseTrip:=20handle=20missing=20date=20?= =?UTF-8?q?=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parse/trip.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/parse/trip.js b/parse/trip.js index 49dc243d..d6214d52 100644 --- a/parse/trip.js +++ b/parse/trip.js @@ -14,8 +14,13 @@ const parseTrip = (ctx, t) => { // t = raw trip arr: maxBy(t.stopL, 'idx') || last(t.stopL), 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 delete trip.tripId