Commit 8ed24d9d authored by Volker Krause's avatar Volker Krause
Browse files

Prefer coordinate over country lookup, if the countries match in both cases

This helps with countries that have several equivalent sub-zones such as
AR or MY.
parent aacfed54
......@@ -104,6 +104,8 @@ KnowledgeDb::Tz KnowledgeDb::timezoneForLocation(float lat, float lon, CountryId
{
const auto coordTz = timezoneForCoordinate(lat, lon);
const auto countryTz = timezoneForCountry(country);
const auto countryFromCoord = countryForTimezone(coordTz);
if (coordTz == Tz::Undefined || coordTz == countryTz) {
return countryTz;
}
......@@ -111,6 +113,12 @@ KnowledgeDb::Tz KnowledgeDb::timezoneForLocation(float lat, float lon, CountryId
return coordTz;
}
// if the coordinate-based timezone is also in @p country, that takes precedence
// example: the various AR sub-zones, or the MY sub-zone
if (country == countryFromCoord) {
return coordTz;
}
// if both timezones are equivalent, the country-based one wins, otherwise we use the coordinate one
return isEquivalentTimezone(toQTimeZone(coordTz), toQTimeZone(countryTz)) ? countryTz : coordTz;
}
......
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