timezonedb.h 2.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
    Copyright (C) 2018 Volker Krause <vkrause@kde.org>

    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU Library General Public License as published by
    the Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
    License for more details.

    You should have received a copy of the GNU General Public License
15
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17
18
19
20
*/

#ifndef KITINERARY_TIMEZONEDB_H
#define KITINERARY_TIMEZONEDB_H

21
#include <kitinerary_export.h>
22
#include "countrydb.h"
23
#include "timezonedb_data.h"
24

25
#include <cstdint>
26
#include <limits>
27
28
29
30
31

class QTimeZone;

namespace KItinerary {
namespace KnowledgeDb {
32
    /** Returns the IANA timezone id for @p tz. */
33
    KITINERARY_EXPORT const char* tzId(Tz tz);
34

35
36
    /** Returns the corresponding QTimeZone. */
    KITINERARY_EXPORT QTimeZone toQTimeZone(Tz tz);
37
38
39
40

    /** Returns the timezone for the given country, as long as there is exactly
     *  one timezone used in that country.
     */
41
    KITINERARY_EXPORT Tz timezoneForCountry(CountryId country);
42

43
44
45
46
47
48
    /** 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.
     */
    KITINERARY_EXPORT CountryId countryForTimezone(Tz tz);

49
50
51
52
#if 0
    /** Returns the timezone for the given coordinate.
     *  The result can be @c Tz::Undefined if this cannot be clearly determined.
     */
53
    KITINERARY_EXPORT Tz timezoneForCoordinate(float lat, float lon, bool *ambiguous = nullptr);
54
55
56
57
58
59

    /** Returns the timezone for the given location consisting of coordinates and country.
     *  This combines the results of the two above individual queries
     *  to obtain better results close to borders.
     */
    KITINERARY_EXPORT Tz timezoneForLocation(float lat, float lon, CountryId country);
60
61
62
63
64
65
66

    /** Returns the country for the given coordinate.
     *  The result will be the country identifier only if the underlying
     *  spatial index has no ambiguity at the requested locations, ie. this
     *  will return less results than timezoneForCoordinate() for example.
     */
    KITINERARY_EXPORT CountryId countryForCoordinate(float lat, float lon);
67
#endif
68
69
70
71
}
}

#endif