Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qtimezonelocale_p.h
Go to the documentation of this file.
1
// Copyright (C) 2024 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QTIMEZONELOCALE_P_H
6
#
define
QTIMEZONELOCALE_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists for the convenience
13
// of internal files. This header file may change from version to version
14
// without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
#
include
<
private
/
qglobal_p
.
h
>
19
20
#
include
<
QtCore
/
qstring
.
h
>
21
#
include
<
QtCore
/
qtimezone
.
h
>
22
#
if
QT_CONFIG
(
datestring
)
23
#
include
"private/qttemporalpattern_p.h"
24
#
endif
25
26
#
if
QT_CONFIG
(
icu
)
27
#
include
<
unicode
/
ucal
.
h
>
28
#
else
29
#
include
<
QtCore
/
private
/
qlocale_p
.
h
>
// for DataRange
30
#
endif
31
32
QT_REQUIRE_CONFIG
(
timezone
);
33
QT_REQUIRE_CONFIG
(
timezone_locale
);
34
// #define QT_CLDR_ZONE_DEBUG
35
36
QT_BEGIN_NAMESPACE
37
38
namespace
QtTimeZoneLocale
{
39
#
if
QT_CONFIG
(
icu
)
40
QString
ucalTimeZoneDisplayName
(
UCalendar
*
ucal
,
QTimeZone
::
TimeType
timeType
,
41
QTimeZone
::
NameType
nameType
,
42
const
QByteArray
&
localeCode
);
43
44
bool
ucalKnownTimeZoneId
(
const
QString
&
id
);
45
#
else
46
47
QList
<
QByteArrayView
>
ianaIdsForTerritory
(QLocale::Territory territory);
48
49
QList
<
qsizetype
>
fallbackLocalesFor
(qsizetype index);
// qlocale.cpp
50
51
#
if
QT_CONFIG
(
datestring
)
52
// See comments in QTZL.cpp; qlocale.cpp has a fallback implementation.
53
QString
zoneOffsetFormat
(
const
QLocale
&
locale
,
qsizetype
locInd
,
54
QtTemporalPattern
::
TemporalFieldFlags
flags
,
55
const
QDateTime
&
when
,
int
offsetSeconds
);
56
#
endif
// datestring
57
58
// Define data types for QTZL_data_p.h
59
60
// Accessor methods returning DataRange:
61
#
define
rangeGetter
(
name
)
62
constexpr
QLocaleData
::
DataRange
name
(
)
const
63
{
return
{
m_
##
name
##
_idx
,
m_
##
name
##
_size
}
;
}
64
// Indices of starts of formats within their tables:
65
#
define
declFieldIndex
(
name
)
quint16
m_
##
name
##
_idx
;
66
#
define
declBigFieldIndex
(
name
)
quint32
m_
##
name
##
_idx
;
67
// Lengths of formats:
68
#
define
declFieldSize
(
name
)
quint8
m_
##
name
##
_size
;
69
// Generic, standard, daylight-saving triples:
70
#
define
forEachNameType
(
X
,
form
)
X
(
form
##
Generic
)
X
(
form
##
Standard
)
X
(
form
##
DaylightSaving
)
71
// Mapping TimeType to the appropriate one of those:
72
#
define
timeTypeRange
(
form
)
73
constexpr
QLocaleData
::
DataRange
form
##
Name
(
QTimeZone
::
TimeType
timeType
)
const
74
{
75
switch
(
timeType
)
{
76
case
QTimeZone
::
StandardTime
:
return
form
##
Standard
(
)
;
77
case
QTimeZone
::
DaylightTime
:
return
form
##
DaylightSaving
(
)
;
78
case
QTimeZone
::
GenericTime
:
return
form
##
Generic
(
)
;
79
}
80
Q_UNREACHABLE_RETURN
(
{
}
)
;
81
}
82
// Mostly form is short or long and we want to append Name.
83
// See kludge below for regionFormat, for which that's not the name the method wants.
84
85
struct
LocaleZoneData
86
{
87
#
ifdef
QT_CLDR_ZONE_DEBUG
88
// Only included when this define is set, for the sake of asserting
89
// consistency with QLocaleData at matching index in tables.
90
quint16
m_language_id
,
m_script_id
,
m_territory_id
;
91
#
endif
92
93
// Indices for this locale:
94
quint32
m_exemplarTableStart
;
// first LocaleZoneExemplar
95
quint32
m_metaLongTableStart
;
// first LocaleMetaZoneLongNames
96
quint16
m_metaShortTableStart
;
// first LocaleMetaZoneShortNames
97
quint16
m_zoneTableStart
;
// first LocaleZoneNames
98
99
// Zone-independent formats:
100
#
define
forEachField
(
X
)
101
X
(
posHourFormat
)
X
(
negHourFormat
)
X
(
offsetGmtFormat
)
X
(
fallbackFormat
)
102
forEachNameType
(
X
,
regionFormat
)
103
// Hour formats: HH is hour, mm is minutes (always use two digits for each).
104
// GMT format: %0 is an hour format's result.
105
// Region formats: %0 is exemplar city or territory.
106
// Fallback format: %0 is exemplar city or territory, %1 is meta-zone name.
107
108
forEachField
(
rangeGetter
)
109
forEachField
(
declFieldIndex
)
110
forEachField
(
declFieldSize
)
111
112
#
undef
forEachField
113
#
define
regionFormatName
regionFormatRange
// kludge naming
114
timeTypeRange
(regionFormat)
115
#
undef
regionFormatName
116
};
117
118
// Sorted by localeIndex, then ianaIdIndex
119
struct
LocaleZoneExemplar
120
{
121
quint16
localeIndex
;
// Index in locale data tables
122
quint16
ianaIdIndex
;
// Location in IANA ID table
123
constexpr
QByteArrayView
ianaId
()
const
;
// Defined in QTZL.cpp
124
rangeGetter
(exemplarCity);
125
quint32
m_exemplarCity_idx
;
126
quint8
m_exemplarCity_size
;
127
};
128
129
// Sorted by localeIndex, then ianaIdIndex
130
struct
LocaleZoneNames
131
{
132
quint16
localeIndex
;
// Index in locale data tables
133
quint16
ianaIdIndex
;
// Location in IANA ID table
134
constexpr
QByteArrayView
ianaId
()
const
;
// Defined in QTZL.cpp
135
constexpr
QLocaleData
::
DataRange
name
(QTimeZone::NameType nameType,
136
QTimeZone::TimeType timeType)
const
137
{
138
return
nameType == QTimeZone::ShortName ? shortName(timeType) : longName(timeType);
139
}
140
timeTypeRange
(
long
)
141
timeTypeRange
(
short
)
142
#
define
forEach32BitField
(
X
)
forEachNameType
(
X
,
long
)
143
#
define
forEach16BitField
(
X
)
forEachNameType
(
X
,
short
)
144
#
define
forEachField
(
X
)
forEach32BitField
(
X
)
forEach16BitField
(
X
)
145
// Localized name of exemplar city for zone.
146
// Long and short localized names (length zero for unspecified) for the zone
147
// in its generic, standard and daylight-saving forms.
148
149
forEachField
(
rangeGetter
)
150
forEach32BitField
(
declBigFieldIndex
)
151
forEach16BitField
(
declFieldIndex
)
152
forEachField
(
declFieldSize
)
153
154
#
undef
forEachField
155
#
undef
forEach16BitField
156
#
undef
forEach32BitField
157
};
158
159
// Sorted by localeIndex, then metaIdIndex
160
struct
LocaleMetaZoneLongNames
161
{
162
quint16
localeIndex
;
// Index in locale data tables
163
quint16
metaIdIndex
;
// As for MetaZoneData metaZoneTable[].
164
timeTypeRange
(
long
)
165
#
define
forEachField
(
X
)
forEachNameType
(
X
,
long
)
166
// Long localized names (length zero for unspecified) for the
167
// metazone in its generic, standard and daylight-saving forms.
168
169
forEachField
(
rangeGetter
)
170
forEachField
(
declBigFieldIndex
)
171
forEachField
(
declFieldSize
)
172
173
#
undef
forEachField
174
};
175
176
// Sorted by localeIndex, then metaIdIndex
177
struct
LocaleMetaZoneShortNames
178
{
179
quint16
localeIndex
;
// Index in locale data tables
180
quint16
metaIdIndex
;
// metaZoneTable[metaZoneKey - 1].metaIdIndex
181
timeTypeRange
(
short
)
182
#
define
forEachField
(
X
)
forEachNameType
(
X
,
short
)
183
// Short localized names (length zero for unspecified) for the
184
// metazone in its generic, standard and daylight-saving forms.
185
186
forEachField
(
rangeGetter
)
187
forEachField
(
declFieldIndex
)
188
forEachField
(
declFieldSize
)
189
190
#
undef
forEachField
191
};
192
193
#
undef
timeTypeRange
194
#
undef
forEachNameType
195
#
undef
declFieldSize
196
#
undef
declFieldIndex
197
#
undef
rangeGetter
198
#
endif
199
}
// QtTimeZoneLocale
200
201
QT_END_NAMESPACE
202
203
#
endif
// QTIMEZONELOCALE_P_H
QtTimeZoneLocale
Definition
qtimezonelocale.cpp:152
QtTimeZoneLocale::fallbackLocalesFor
QList< qsizetype > fallbackLocalesFor(qsizetype index)
QtTimeZoneLocale::ianaIdsForTerritory
QList< QByteArrayView > ianaIdsForTerritory(QLocale::Territory territory)
Definition
qtimezonelocale.cpp:560
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(animation)
rangeGetter
#define rangeGetter(name)
Definition
qlocale_p.h:643
forEachField
#define forEachField(X)
Definition
qtimezonelocale_p.h:100
timeTypeRange
#define timeTypeRange(form)
Definition
qtimezonelocale_p.h:72
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(timezone_locale)
forEach16BitField
#define forEach16BitField(X)
forEach32BitField
#define forEach32BitField(X)
ucalOffsetsAtTime
static bool ucalOffsetsAtTime(UCalendar *m_ucal, qint64 atMSecsSinceEpoch, int *utcOffset, int *dstOffset)
Definition
qtimezoneprivate_icu.cpp:65
ucalDaylightOffset
static int ucalDaylightOffset(const QByteArray &id)
Definition
qtimezoneprivate_icu.cpp:196
uenumToIdList
static QList< QByteArray > uenumToIdList(UEnumeration *uenum)
Definition
qtimezoneprivate_icu.cpp:171
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(timezone)
QtTimeZoneLocale::LocaleMetaZoneLongNames
Definition
qtimezonelocale_p.h:161
QtTimeZoneLocale::LocaleMetaZoneLongNames::metaIdIndex
quint16 metaIdIndex
Definition
qtimezonelocale_p.h:163
QtTimeZoneLocale::LocaleMetaZoneLongNames::localeIndex
quint16 localeIndex
Definition
qtimezonelocale_p.h:162
QtTimeZoneLocale::LocaleMetaZoneShortNames
Definition
qtimezonelocale_p.h:178
QtTimeZoneLocale::LocaleMetaZoneShortNames::localeIndex
quint16 localeIndex
Definition
qtimezonelocale_p.h:179
QtTimeZoneLocale::LocaleMetaZoneShortNames::metaIdIndex
quint16 metaIdIndex
Definition
qtimezonelocale_p.h:180
QtTimeZoneLocale::LocaleZoneData
Definition
qtimezonelocale_p.h:86
QtTimeZoneLocale::LocaleZoneData::m_zoneTableStart
quint16 m_zoneTableStart
Definition
qtimezonelocale_p.h:97
QtTimeZoneLocale::LocaleZoneData::m_metaLongTableStart
quint32 m_metaLongTableStart
Definition
qtimezonelocale_p.h:95
QtTimeZoneLocale::LocaleZoneData::m_metaShortTableStart
quint16 m_metaShortTableStart
Definition
qtimezonelocale_p.h:96
QtTimeZoneLocale::LocaleZoneData::m_exemplarTableStart
quint32 m_exemplarTableStart
Definition
qtimezonelocale_p.h:94
QtTimeZoneLocale::LocaleZoneExemplar
Definition
qtimezonelocale_p.h:120
QtTimeZoneLocale::LocaleZoneExemplar::localeIndex
quint16 localeIndex
Definition
qtimezonelocale_p.h:121
QtTimeZoneLocale::LocaleZoneExemplar::m_exemplarCity_idx
quint32 m_exemplarCity_idx
Definition
qtimezonelocale_p.h:125
QtTimeZoneLocale::LocaleZoneExemplar::m_exemplarCity_size
quint8 m_exemplarCity_size
Definition
qtimezonelocale_p.h:126
QtTimeZoneLocale::LocaleZoneExemplar::ianaId
constexpr QByteArrayView ianaId() const
Definition
qtimezonelocale.cpp:155
QtTimeZoneLocale::LocaleZoneExemplar::ianaIdIndex
quint16 ianaIdIndex
Definition
qtimezonelocale_p.h:122
QtTimeZoneLocale::LocaleZoneNames
Definition
qtimezonelocale_p.h:131
QtTimeZoneLocale::LocaleZoneNames::name
constexpr QLocaleData::DataRange name(QTimeZone::NameType nameType, QTimeZone::TimeType timeType) const
Definition
qtimezonelocale_p.h:135
QtTimeZoneLocale::LocaleZoneNames::ianaIdIndex
quint16 ianaIdIndex
Definition
qtimezonelocale_p.h:133
QtTimeZoneLocale::LocaleZoneNames::localeIndex
quint16 localeIndex
Definition
qtimezonelocale_p.h:132
QtTimeZoneLocale::LocaleZoneNames::ianaId
constexpr QByteArrayView ianaId() const
Definition
qtimezonelocale.cpp:156
qtbase
src
corelib
time
qtimezonelocale_p.h
Generated on
for Qt by
1.18.0