Commit 636e3ff4 authored by Volker Krause's avatar Volker Krause
Browse files

Turn toQZimeZone and timezoneForCountry into implementation details

Another step towards porting to KI18nLocaleData.
parent 077ff8f5
......@@ -239,9 +239,9 @@ private Q_SLOTS:
using namespace KnowledgeDb;
QCOMPARE(toQTimeZone(timezoneForCountry(CountryId{"DE"})), QTimeZone("Europe/Berlin"));
QCOMPARE(toQTimeZone(timezoneForCountry(CountryId{"FR"})), QTimeZone("Europe/Paris"));
QCOMPARE(toQTimeZone(timezoneForCountry(CountryId{"BR"})), QTimeZone());
QCOMPARE(timezoneForLocation(NAN, NAN, CountryId{"DE"}), QTimeZone("Europe/Berlin"));
QCOMPARE(timezoneForLocation(NAN, NAN, CountryId{"FR"}), QTimeZone("Europe/Paris"));
QCOMPARE(timezoneForLocation(NAN, NAN, CountryId{"BR"}), QTimeZone());
void testCountryForTimezone()
......@@ -20,16 +20,17 @@ const char* KnowledgeDb::tzId(KnowledgeDb::Tz tz)
return timezone_names + timezone_names_offsets[static_cast<std::underlying_type<KnowledgeDb::Tz>::type>(tz)];
QTimeZone KnowledgeDb::toQTimeZone(Tz tz)
static QTimeZone toQTimeZone(KnowledgeDb::Tz tz)
if (tz == Tz::Undefined) {
if (tz == KnowledgeDb::Tz::Undefined) {
return {};
return QTimeZone(tzId(tz));
KnowledgeDb::Tz KnowledgeDb::timezoneForCountry(CountryId country)
static KnowledgeDb::Tz timezoneForCountry(KnowledgeDb::CountryId country)
using namespace KnowledgeDb;
const auto it = std::lower_bound(std::begin(country_timezone_map), std::end(country_timezone_map), country);
if (it != std::end(country_timezone_map) && (*it).country == country) {
return (*it).timezone;
......@@ -20,14 +20,6 @@ namespace KnowledgeDb {
/** Returns the IANA timezone id for @p tz. */
KITINERARY_EXPORT const char* tzId(Tz tz);
/** Returns the corresponding QTimeZone. */
KITINERARY_EXPORT QTimeZone toQTimeZone(Tz tz);
/** Returns the timezone for the given country, as long as there is exactly
* one timezone used in that country.
KITINERARY_EXPORT Tz timezoneForCountry(CountryId country);
/** Returns the country for a given timezone.
* This is unique for most IANA timezones, but not guaranteed to be so,
* in which case an invalid country is returned.
......@@ -40,8 +32,7 @@ namespace KnowledgeDb {
KITINERARY_EXPORT Tz timezoneForCoordinate(float lat, float lon, bool *ambiguous = nullptr);
/** Returns the timezone for the given location consisting of coordinates and/or country.
* This combines the results of the two above individual queries
* to obtain better results close to borders.
* Either argument can be omitted, if both are available better results can be provided.
KITINERARY_EXPORT QTimeZone timezoneForLocation(float lat, float lon, CountryId country);
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