Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
636e3ff4
Commit
636e3ff4
authored
Oct 17, 2021
by
Volker Krause
Browse files
Turn toQZimeZone and timezoneForCountry into implementation details
Another step towards porting to KI18nLocaleData.
parent
077ff8f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
autotests/knowledgedbtest.cpp
View file @
636e3ff4
...
...
@@ -239,9 +239,9 @@ private Q_SLOTS:
{
using
namespace
KnowledgeDb
;
QCOMPARE
(
t
oQTimeZone
(
timezoneForCountry
(
CountryId
{
"DE"
})
)
,
QTimeZone
(
"Europe/Berlin"
));
QCOMPARE
(
t
oQTimeZone
(
timezoneForCountry
(
CountryId
{
"FR"
})
)
,
QTimeZone
(
"Europe/Paris"
));
QCOMPARE
(
t
oQTimeZone
(
timezoneForCountry
(
CountryId
{
"BR"
})
)
,
QTimeZone
());
QCOMPARE
(
t
imezoneForLocation
(
NAN
,
NAN
,
CountryId
{
"DE"
}),
QTimeZone
(
"Europe/Berlin"
));
QCOMPARE
(
t
imezoneForLocation
(
NAN
,
NAN
,
CountryId
{
"FR"
}),
QTimeZone
(
"Europe/Paris"
));
QCOMPARE
(
t
imezoneForLocation
(
NAN
,
NAN
,
CountryId
{
"BR"
}),
QTimeZone
());
}
void
testCountryForTimezone
()
...
...
src/lib/knowledgedb/timezonedb.cpp
View file @
636e3ff4
...
...
@@ -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
;
...
...
src/lib/knowledgedb/timezonedb.h
View file @
636e3ff4
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment