Commit e9367e10 authored by Volker Krause's avatar Volker Krause
Browse files

Generalize train trip timezone lookup

Rather than doing this by station code type (and quite incompletely),
we can do this now based on the location information alone.
parent dd46fea0
......@@ -282,14 +282,12 @@ QDateTime ExtractorPostprocessorPrivate::processTrainTripTime(QDateTime dt, cons
QTimeZone tz;
if (station.identifier().startsWith(QLatin1String("sncf:"))) {
const auto record = KnowledgeDb::stationForSncfStationId(KnowledgeDb::SncfStationId{station.identifier().mid(5)});
tz = KnowledgeDb::toQTimeZone(record.timezone());
} else if (station.identifier().startsWith(QLatin1String("ibnr:"))) {
const auto record = KnowledgeDb::stationForIbnr(KnowledgeDb::IBNR{station.identifier().mid(5).toUInt()});
tz = KnowledgeDb::toQTimeZone(record.timezone());
} else if (!station.address().addressCountry().isEmpty()) {
tz = KnowledgeDb::toQTimeZone(KnowledgeDb::timezoneForCountry(KnowledgeDb::CountryId{station.address().addressCountry()}));
const auto geo = station.geo();
const KnowledgeDb::CountryId country{station.address().addressCountry()};
if (geo.isValid()) {
tz = KnowledgeDb::toQTimeZone(KnowledgeDb::timezoneForLocation(geo.latitude(), geo.longitude(), country));
} else {
tz = KnowledgeDb::toQTimeZone(KnowledgeDb::timezoneForCountry(country));
if (!tz.isValid()) {
return dt;
Markdown is supported
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