Commit 36199bec authored by Volker Krause's avatar Volker Krause
Browse files

Handle arrival times on the next day in the generic boarding pass extractor

parent 88dbffb5
...@@ -205,15 +205,19 @@ ExtractorResult GenericBoardingPassExtractor::extract(const ExtractorDocumentNod ...@@ -205,15 +205,19 @@ ExtractorResult GenericBoardingPassExtractor::extract(const ExtractorDocumentNod
std::sort(times.begin(), times.end()); std::sort(times.begin(), times.end());
times.erase(std::unique(times.begin(), times.end()), times.end()); times.erase(std::unique(times.begin(), times.end()), times.end());
if (times.size() == 2) { if (times.size() == 2) {
// boarding/departure only, and on the same day
if (isPlausibleBoardingTime(times[0], times[1]) && !isPlausibleFlightTime(times[0], times[1], from, to)) { if (isPlausibleBoardingTime(times[0], times[1]) && !isPlausibleFlightTime(times[0], times[1], from, to)) {
applyFlightTimes(result, times[0], times[1], {}); applyFlightTimes(result, times[0], times[1], {});
} }
} else if (times.size() == 3) { } else if (times.size() == 3) {
// boarding/departure/arrival on the same day
if (isPlausibleBoardingTime(times[0], times[1]) && isPlausibleFlightTime(times[1], times[2], from, to)) { if (isPlausibleBoardingTime(times[0], times[1]) && isPlausibleFlightTime(times[1], times[2], from, to)) {
applyFlightTimes(result, times[0], times[1], times[2]); applyFlightTimes(result, times[0], times[1], times[2]);
// boarding/departure on the same day, arrival on the next day
} else if (isPlausibleBoardingTime(times[1], times[2]) && isPlausibleFlightTime(times[2], times[0].addDays(1), from, to)) {
applyFlightTimes(result, times[1], times[2], times[0].addDays(1));
} }
// TODO handle arrival past midnight
// TODO handle boarding before midnight // TODO handle boarding before midnight
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment