From 95839372b5be67e11a2da8017a509055528916a8 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Mon, 15 Oct 2018 14:37:46 +0200 Subject: [PATCH] trip: remove when option, it gets ignored anyways --- docs/trip.md | 1 - index.js | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/trip.md b/docs/trip.md index 4fdd85e1..755b47a8 100644 --- a/docs/trip.md +++ b/docs/trip.md @@ -26,7 +26,6 @@ With `opt`, you can override the default options, which look like this: ```js { - when: new Date(), stopovers: true, // return stations on the way? polyline: false, // return a shape for the trip? remarks: true, // parse & expose hints & warnings? diff --git a/index.js b/index.js index 41784915..c1dbb27b 100644 --- a/index.js +++ b/index.js @@ -378,8 +378,6 @@ const createClient = (profile, userAgent, request = _request) => { polyline: false, // return a track shape? remarks: true // parse & expose hints & warnings? }, opt) - opt.when = new Date(opt.when || Date.now()) - if (Number.isNaN(+opt.when)) throw new Error('opt.when is invalid') return request(profile, userAgent, opt, { cfg: {polyEnc: 'GPA'}, @@ -388,7 +386,9 @@ const createClient = (profile, userAgent, request = _request) => { // todo: getTrainComposition jid: id, name: lineName, - date: profile.formatDate(profile, opt.when), + // HAFAS apparently ignores the date in the trip ID and uses the `date` field. + // Thus, it will find a different trip if you pass the wrong date via `opt.when`. + // date: profile.formatDate(profile, opt.when), getPolyline: !!opt.polyline } })