Closed bergmannjg closed 2 years ago
hafas-client computes the last scheduledDay as
2022-12-30
, the correct value should be2022-12-10
as in fieldsDaysR
.
Good catch!
I would suggest to take the reference date from
"fpB": "20211212"
as year/month/day.
This seems to be the intended way, yes.
Just found this weird example, can you make sense of it?
{
// […]
"fpB": "20211212",
"fpE": "20231209",
// […]
"sDays": {
"sDaysR": "runs 16. Nov 2022 ",
"sDaysB": "000000000000000000000000000000000000000000000000000000000000000000000000000000000001F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
}
The sDaysB
bit mask doesn't specify just one date.
sDaysB decodes the range from 2022-11-12 to 2022-11-16
if current day is in the sDaysB range then sDaysR range starts from current day '2022-11-16'
if current day is in the sDaysB range then sDaysR range starts from current day '2022-11-16' [but
sDaysB
does not]
That is a weird API!
Fix published as hafas-client@5.26.2
. 🎉
Given the following TripSearch response
hafas-client computes the last scheduledDay as 2022-12-30, the correct value should be 2022-12-10 as in field sDaysR.
hafas-client uses the year of "date": "20221115" as the reference date.
https://github.com/public-transport/hafas-client/blob/61fc2293fb41df5a7c43a202df8707134cd51759/parse/journey.js#L60-L63
https://github.com/public-transport/hafas-client/blob/61fc2293fb41df5a7c43a202df8707134cd51759/parse/journey.js#L10-L15
I would suggest to take the reference date from "fpB": "20211212" as year/month/day.