Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qtimezoneprivate_tz.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | - | |||||||||||||||||||
10 | - | |||||||||||||||||||
11 | - | |||||||||||||||||||
12 | - | |||||||||||||||||||
13 | - | |||||||||||||||||||
14 | - | |||||||||||||||||||
15 | struct QTzTimeZone { | - | ||||||||||||||||||
16 | QLocale::Country country; | - | ||||||||||||||||||
17 | QByteArray comment; | - | ||||||||||||||||||
18 | }; | - | ||||||||||||||||||
19 | - | |||||||||||||||||||
20 | - | |||||||||||||||||||
21 | typedef QHash<QByteArray, QTzTimeZone> QTzTimeZoneHash; | - | ||||||||||||||||||
22 | - | |||||||||||||||||||
23 | - | |||||||||||||||||||
24 | static QTzTimeZoneHash loadTzTimeZones() | - | ||||||||||||||||||
25 | { | - | ||||||||||||||||||
26 | QString path = ([]() -> QString { enum { Size = sizeof(u"" "/usr/share/zoneinfo/zone.tab")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/usr/share/zoneinfo/zone.tab" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 1 time by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 1 time by 1 test: }());return qstring_literal_temp; Executed by:
| 1 | ||||||||||||||||||
27 | if (!QFile::exists(path)
| 0-1 | ||||||||||||||||||
28 | path = ([]() -> QString { enum { Size = sizeof(u"" "/usr/lib/zoneinfo/zone.tab")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/usr/lib/zoneinfo/zone.tab" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }());return qstring_literal_temp; never executed: path = ([]() -> QString { enum { Size = sizeof(u"" "/usr/lib/zoneinfo/zone.tab")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/usr/lib/zoneinfo/zone.tab" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); | 0 | ||||||||||||||||||
29 | - | |||||||||||||||||||
30 | QFile tzif(path); | - | ||||||||||||||||||
31 | if (!tzif.open(QIODevice::ReadOnly)
| 0-1 | ||||||||||||||||||
32 | return never executed: QTzTimeZoneHash();return QTzTimeZoneHash(); never executed: return QTzTimeZoneHash(); | 0 | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | QTzTimeZoneHash zonesHash; | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | QTextStream ts(&tzif); | - | ||||||||||||||||||
37 | while (!ts.atEnd()
| 1-445 | ||||||||||||||||||
38 | const QString line = ts.readLine(); | - | ||||||||||||||||||
39 | - | |||||||||||||||||||
40 | if (!line.isEmpty()
| 0-445 | ||||||||||||||||||
41 | - | |||||||||||||||||||
42 | const QStringList parts = line.split('\t'); | - | ||||||||||||||||||
43 | QTzTimeZone zone; | - | ||||||||||||||||||
44 | zone.country = QLocalePrivate::codeToCountry(parts.at(0)); | - | ||||||||||||||||||
45 | if (parts.size() > 3
| 204-217 | ||||||||||||||||||
46 | zone.comment = parts.at(3).toUtf8(); executed 204 times by 1 test: zone.comment = parts.at(3).toUtf8(); Executed by:
| 204 | ||||||||||||||||||
47 | zonesHash.insert(parts.at(2).toUtf8(), zone); | - | ||||||||||||||||||
48 | } executed 421 times by 1 test: end of block Executed by:
| 421 | ||||||||||||||||||
49 | } executed 445 times by 1 test: end of block Executed by:
| 445 | ||||||||||||||||||
50 | return executed 1 time by 1 test: zonesHash;return zonesHash; Executed by:
executed 1 time by 1 test: return zonesHash; Executed by:
| 1 | ||||||||||||||||||
51 | } | - | ||||||||||||||||||
52 | - | |||||||||||||||||||
53 | - | |||||||||||||||||||
54 | namespace { namespace Q_QGS_tzZones { typedef const QTzTimeZoneHash Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
executed 1 time by 1 test: }guard.store(QtGlobalStatic::Destroyed); Executed by:
executed 1 time by 1 test: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type (loadTzTimeZones()))) : value (loadTzTimeZones()) { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of block Executed by:
executed 1732 times by 1 test: &holder.value;return &holder.value; Executed by:
executed 1732 times by 1 test: } } } static QGlobalStatic<const QTzTimeZoneHash, Q_QGS_tzZones::innerFunction, Q_QGS_tzZones::guard> tzZones;;return &holder.value; Executed by:
| 0-1732 | ||||||||||||||||||
55 | struct QTzHeader { | - | ||||||||||||||||||
56 | char tzh_magic[4]; | - | ||||||||||||||||||
57 | char tzh_version; | - | ||||||||||||||||||
58 | char tzh_reserved[15]; | - | ||||||||||||||||||
59 | quint32 tzh_ttisgmtcnt; | - | ||||||||||||||||||
60 | quint32 tzh_ttisstdcnt; | - | ||||||||||||||||||
61 | quint32 tzh_leapcnt; | - | ||||||||||||||||||
62 | quint32 tzh_timecnt; | - | ||||||||||||||||||
63 | quint32 tzh_typecnt; | - | ||||||||||||||||||
64 | quint32 tzh_charcnt; | - | ||||||||||||||||||
65 | }; | - | ||||||||||||||||||
66 | - | |||||||||||||||||||
67 | struct QTzTransition { | - | ||||||||||||||||||
68 | qint64 tz_time; | - | ||||||||||||||||||
69 | quint8 tz_typeind; | - | ||||||||||||||||||
70 | }; | - | ||||||||||||||||||
71 | template<> class QTypeInfo<QTzTransition > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_PRIMITIVE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QTzTransition)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QTzTransition >::value, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QTzTransition) }; static inline const char *name() { return "QTzTransition"; } }; | - | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | struct QTzType { | - | ||||||||||||||||||
74 | int tz_gmtoff; | - | ||||||||||||||||||
75 | bool tz_isdst; | - | ||||||||||||||||||
76 | quint8 tz_abbrind; | - | ||||||||||||||||||
77 | bool tz_ttisgmt; | - | ||||||||||||||||||
78 | bool tz_ttisstd; | - | ||||||||||||||||||
79 | }; | - | ||||||||||||||||||
80 | template<> class QTypeInfo<QTzType > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_PRIMITIVE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QTzType)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QTzType >::value, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QTzType) }; static inline const char *name() { return "QTzType"; } }; | - | ||||||||||||||||||
81 | - | |||||||||||||||||||
82 | - | |||||||||||||||||||
83 | - | |||||||||||||||||||
84 | - | |||||||||||||||||||
85 | static QTzHeader parseTzHeader(QDataStream &ds, bool *ok) | - | ||||||||||||||||||
86 | { | - | ||||||||||||||||||
87 | QTzHeader hdr; | - | ||||||||||||||||||
88 | quint8 ch; | - | ||||||||||||||||||
89 | *ok = false; | - | ||||||||||||||||||
90 | - | |||||||||||||||||||
91 | - | |||||||||||||||||||
92 | ds.readRawData(hdr.tzh_magic, 4); | - | ||||||||||||||||||
93 | - | |||||||||||||||||||
94 | if (memcmp(hdr.tzh_magic, "TZif", 4) != 0
| 0-908 | ||||||||||||||||||
95 | return never executed: hdr;return hdr; never executed: return hdr; | 0 | ||||||||||||||||||
96 | - | |||||||||||||||||||
97 | - | |||||||||||||||||||
98 | ds >> ch; | - | ||||||||||||||||||
99 | hdr.tzh_version = ch; | - | ||||||||||||||||||
100 | if (ds.status() != QDataStream::Ok
| 0-908 | ||||||||||||||||||
101 | || (hdr.tzh_version != '2'
| 0-894 | ||||||||||||||||||
102 | return never executed: hdr;return hdr; never executed: return hdr; | 0 | ||||||||||||||||||
103 | } | - | ||||||||||||||||||
104 | - | |||||||||||||||||||
105 | - | |||||||||||||||||||
106 | ds.readRawData(hdr.tzh_reserved, 15); | - | ||||||||||||||||||
107 | if (ds.status() != QDataStream::Ok
| 0-908 | ||||||||||||||||||
108 | return never executed: hdr;return hdr; never executed: return hdr; | 0 | ||||||||||||||||||
109 | - | |||||||||||||||||||
110 | - | |||||||||||||||||||
111 | ds >> hdr.tzh_ttisgmtcnt >> hdr.tzh_ttisstdcnt >> hdr.tzh_leapcnt >> hdr.tzh_timecnt | - | ||||||||||||||||||
112 | >> hdr.tzh_typecnt >> hdr.tzh_charcnt; | - | ||||||||||||||||||
113 | - | |||||||||||||||||||
114 | - | |||||||||||||||||||
115 | if (ds.status() != QDataStream::Ok
| 0-908 | ||||||||||||||||||
116 | || hdr.tzh_timecnt > 1200
| 0-908 | ||||||||||||||||||
117 | || hdr.tzh_typecnt > 256
| 0-908 | ||||||||||||||||||
118 | || hdr.tzh_charcnt > 50
| 0-908 | ||||||||||||||||||
119 | || hdr.tzh_leapcnt > 50
| 0-908 | ||||||||||||||||||
120 | || hdr.tzh_ttisgmtcnt > hdr.tzh_typecnt
| 0-908 | ||||||||||||||||||
121 | || hdr.tzh_ttisstdcnt > hdr.tzh_typecnt
| 0-908 | ||||||||||||||||||
122 | return never executed: hdr;return hdr; never executed: return hdr; | 0 | ||||||||||||||||||
123 | } | - | ||||||||||||||||||
124 | - | |||||||||||||||||||
125 | *ok = true; | - | ||||||||||||||||||
126 | return executed 908 times by 2 tests: hdr;return hdr; Executed by:
executed 908 times by 2 tests: return hdr; Executed by:
| 908 | ||||||||||||||||||
127 | } | - | ||||||||||||||||||
128 | - | |||||||||||||||||||
129 | static QVector<QTzTransition> parseTzTransitions(QDataStream &ds, int tzh_timecnt, bool longTran) | - | ||||||||||||||||||
130 | { | - | ||||||||||||||||||
131 | QVector<QTzTransition> transitions(tzh_timecnt); | - | ||||||||||||||||||
132 | - | |||||||||||||||||||
133 | if (longTran
| 454 | ||||||||||||||||||
134 | - | |||||||||||||||||||
135 | for (int i = 0; i < tzh_timecnt
| 0-31553 | ||||||||||||||||||
136 | ds >> transitions[i].tz_time; | - | ||||||||||||||||||
137 | if (ds.status() != QDataStream::Ok
| 0-31553 | ||||||||||||||||||
138 | transitions.resize(i); never executed: transitions.resize(i); | 0 | ||||||||||||||||||
139 | } executed 31553 times by 2 tests: end of block Executed by:
| 31553 | ||||||||||||||||||
140 | } executed 454 times by 2 tests: else {end of block Executed by:
| 454 | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | int val; | - | ||||||||||||||||||
143 | for (int i = 0; i < tzh_timecnt
| 0-31278 | ||||||||||||||||||
144 | ds >> val; | - | ||||||||||||||||||
145 | transitions[i].tz_time = val; | - | ||||||||||||||||||
146 | if (ds.status() != QDataStream::Ok
| 0-31278 | ||||||||||||||||||
147 | transitions.resize(i); never executed: transitions.resize(i); | 0 | ||||||||||||||||||
148 | } executed 31278 times by 2 tests: end of block Executed by:
| 31278 | ||||||||||||||||||
149 | } executed 454 times by 2 tests: end of block Executed by:
| 454 | ||||||||||||||||||
150 | - | |||||||||||||||||||
151 | - | |||||||||||||||||||
152 | for (int i = 0; i < tzh_timecnt
| 0-62831 | ||||||||||||||||||
153 | quint8 typeind; | - | ||||||||||||||||||
154 | ds >> typeind; | - | ||||||||||||||||||
155 | if (ds.status() == QDataStream::Ok
| 0-62831 | ||||||||||||||||||
156 | transitions[i].tz_typeind = typeind; executed 62831 times by 2 tests: transitions[i].tz_typeind = typeind; Executed by:
| 62831 | ||||||||||||||||||
157 | } executed 62831 times by 2 tests: end of block Executed by:
| 62831 | ||||||||||||||||||
158 | - | |||||||||||||||||||
159 | return executed 908 times by 2 tests: transitions;return transitions; Executed by:
executed 908 times by 2 tests: return transitions; Executed by:
| 908 | ||||||||||||||||||
160 | } | - | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | static QVector<QTzType> parseTzTypes(QDataStream &ds, int tzh_typecnt) | - | ||||||||||||||||||
163 | { | - | ||||||||||||||||||
164 | QVector<QTzType> types(tzh_typecnt); | - | ||||||||||||||||||
165 | - | |||||||||||||||||||
166 | - | |||||||||||||||||||
167 | for (int i = 0; i < tzh_typecnt
| 0-5130 | ||||||||||||||||||
168 | QTzType &type = types[i]; | - | ||||||||||||||||||
169 | - | |||||||||||||||||||
170 | ds >> type.tz_gmtoff; | - | ||||||||||||||||||
171 | - | |||||||||||||||||||
172 | if (ds.status() == QDataStream::Ok
| 0-5130 | ||||||||||||||||||
173 | ds >> type.tz_isdst; executed 5130 times by 2 tests: ds >> type.tz_isdst; Executed by:
| 5130 | ||||||||||||||||||
174 | - | |||||||||||||||||||
175 | if (ds.status() == QDataStream::Ok
| 0-5130 | ||||||||||||||||||
176 | ds >> type.tz_abbrind; executed 5130 times by 2 tests: ds >> type.tz_abbrind; Executed by:
| 5130 | ||||||||||||||||||
177 | - | |||||||||||||||||||
178 | type.tz_ttisgmt = false; | - | ||||||||||||||||||
179 | type.tz_ttisstd = false; | - | ||||||||||||||||||
180 | if (ds.status() != QDataStream::Ok
| 0-5130 | ||||||||||||||||||
181 | types.resize(i); never executed: types.resize(i); | 0 | ||||||||||||||||||
182 | } executed 5130 times by 2 tests: end of block Executed by:
| 5130 | ||||||||||||||||||
183 | - | |||||||||||||||||||
184 | return executed 908 times by 2 tests: types;return types; Executed by:
executed 908 times by 2 tests: return types; Executed by:
| 908 | ||||||||||||||||||
185 | } | - | ||||||||||||||||||
186 | - | |||||||||||||||||||
187 | static QMap<int, QByteArray> parseTzAbbreviations(QDataStream &ds, int tzh_charcnt, const QVector<QTzType> &types) | - | ||||||||||||||||||
188 | { | - | ||||||||||||||||||
189 | - | |||||||||||||||||||
190 | - | |||||||||||||||||||
191 | - | |||||||||||||||||||
192 | - | |||||||||||||||||||
193 | - | |||||||||||||||||||
194 | QMap<int, QByteArray> map; | - | ||||||||||||||||||
195 | quint8 ch; | - | ||||||||||||||||||
196 | QByteArray input; | - | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | for (int i = 0; i < tzh_charcnt
| 0-14643 | ||||||||||||||||||
199 | ds >> ch; | - | ||||||||||||||||||
200 | if (ds.status() == QDataStream::Ok
| 0-14643 | ||||||||||||||||||
201 | input.append(char(ch)); executed 14643 times by 2 tests: input.append(char(ch)); Executed by:
| 14643 | ||||||||||||||||||
202 | else | - | ||||||||||||||||||
203 | return never executed: map;return map; never executed: return map; | 0 | ||||||||||||||||||
204 | } | - | ||||||||||||||||||
205 | - | |||||||||||||||||||
206 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(types)>::type> _container_((types)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QTzType &type = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
207 | QByteArray abbrev; | - | ||||||||||||||||||
208 | for (int i = type.tz_abbrind; input.at(i) != '\0'
| 5130-17454 | ||||||||||||||||||
209 | abbrev.append(input.at(i)); executed 17454 times by 2 tests: abbrev.append(input.at(i)); Executed by:
| 17454 | ||||||||||||||||||
210 | - | |||||||||||||||||||
211 | map[type.tz_abbrind] = abbrev; | - | ||||||||||||||||||
212 | } executed 5130 times by 2 tests: end of block Executed by:
| 5130 | ||||||||||||||||||
213 | return executed 908 times by 2 tests: map;return map; Executed by:
executed 908 times by 2 tests: return map; Executed by:
| 908 | ||||||||||||||||||
214 | } | - | ||||||||||||||||||
215 | - | |||||||||||||||||||
216 | static void parseTzLeapSeconds(QDataStream &ds, int tzh_leapcnt, bool longTran) | - | ||||||||||||||||||
217 | { | - | ||||||||||||||||||
218 | - | |||||||||||||||||||
219 | - | |||||||||||||||||||
220 | qint64 val; | - | ||||||||||||||||||
221 | if (longTran
| 454 | ||||||||||||||||||
222 | qint64 time; | - | ||||||||||||||||||
223 | for (int i = 0; i < tzh_leapcnt
| 0-454 | ||||||||||||||||||
224 | - | |||||||||||||||||||
225 | ds >> time; | - | ||||||||||||||||||
226 | - | |||||||||||||||||||
227 | if (ds.status() == QDataStream::Ok
| 0 | ||||||||||||||||||
228 | ds >> val; never executed: ds >> val; | 0 | ||||||||||||||||||
229 | } never executed: end of block | 0 | ||||||||||||||||||
230 | } executed 454 times by 2 tests: else {end of block Executed by:
| 454 | ||||||||||||||||||
231 | for (int i = 0; i < tzh_leapcnt
| 0-454 | ||||||||||||||||||
232 | - | |||||||||||||||||||
233 | ds >> val; | - | ||||||||||||||||||
234 | - | |||||||||||||||||||
235 | if (ds.status() == QDataStream::Ok
| 0 | ||||||||||||||||||
236 | ds >> val; never executed: ds >> val; | 0 | ||||||||||||||||||
237 | } never executed: end of block | 0 | ||||||||||||||||||
238 | } executed 454 times by 2 tests: end of block Executed by:
| 454 | ||||||||||||||||||
239 | } | - | ||||||||||||||||||
240 | - | |||||||||||||||||||
241 | static QVector<QTzType> parseTzIndicators(QDataStream &ds, const QVector<QTzType> &types, int tzh_ttisstdcnt, int tzh_ttisgmtcnt) | - | ||||||||||||||||||
242 | { | - | ||||||||||||||||||
243 | QVector<QTzType> result = types; | - | ||||||||||||||||||
244 | bool temp; | - | ||||||||||||||||||
245 | - | |||||||||||||||||||
246 | - | |||||||||||||||||||
247 | for (int i = 0; i < tzh_ttisstdcnt
| 0-5130 | ||||||||||||||||||
248 | ds >> temp; | - | ||||||||||||||||||
249 | if (ds.status() == QDataStream::Ok
| 0-5130 | ||||||||||||||||||
250 | result[i].tz_ttisstd = temp; executed 5130 times by 2 tests: result[i].tz_ttisstd = temp; Executed by:
| 5130 | ||||||||||||||||||
251 | } executed 5130 times by 2 tests: end of block Executed by:
| 5130 | ||||||||||||||||||
252 | - | |||||||||||||||||||
253 | - | |||||||||||||||||||
254 | for (int i = 0; i < tzh_ttisgmtcnt
| 0-5130 | ||||||||||||||||||
255 | ds >> temp; | - | ||||||||||||||||||
256 | if (ds.status() == QDataStream::Ok
| 0-5130 | ||||||||||||||||||
257 | result[i].tz_ttisgmt = temp; executed 5130 times by 2 tests: result[i].tz_ttisgmt = temp; Executed by:
| 5130 | ||||||||||||||||||
258 | } executed 5130 times by 2 tests: end of block Executed by:
| 5130 | ||||||||||||||||||
259 | - | |||||||||||||||||||
260 | return executed 908 times by 2 tests: result;return result; Executed by:
executed 908 times by 2 tests: return result; Executed by:
| 908 | ||||||||||||||||||
261 | } | - | ||||||||||||||||||
262 | - | |||||||||||||||||||
263 | static QByteArray parseTzPosixRule(QDataStream &ds) | - | ||||||||||||||||||
264 | { | - | ||||||||||||||||||
265 | - | |||||||||||||||||||
266 | QByteArray rule; | - | ||||||||||||||||||
267 | - | |||||||||||||||||||
268 | quint8 ch; | - | ||||||||||||||||||
269 | ds >> ch; | - | ||||||||||||||||||
270 | if (ch != '\n'
| 0-454 | ||||||||||||||||||
271 | return never executed: rule;return rule; never executed: return rule; | 0 | ||||||||||||||||||
272 | ds >> ch; | - | ||||||||||||||||||
273 | while (ch != '\n'
| 0-5987 | ||||||||||||||||||
274 | rule.append((char)ch); | - | ||||||||||||||||||
275 | ds >> ch; | - | ||||||||||||||||||
276 | } executed 5987 times by 2 tests: end of block Executed by:
| 5987 | ||||||||||||||||||
277 | - | |||||||||||||||||||
278 | return executed 454 times by 2 tests: rule;return rule; Executed by:
executed 454 times by 2 tests: return rule; Executed by:
| 454 | ||||||||||||||||||
279 | } | - | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | static QDate calculateDowDate(int year, int month, int dayOfWeek, int week) | - | ||||||||||||||||||
282 | { | - | ||||||||||||||||||
283 | QDate date(year, month, 1); | - | ||||||||||||||||||
284 | int startDow = date.dayOfWeek(); | - | ||||||||||||||||||
285 | if (startDow <= dayOfWeek
| 295-3471 | ||||||||||||||||||
286 | date = date.addDays(dayOfWeek - startDow - 7); executed 295 times by 2 tests: date = date.addDays(dayOfWeek - startDow - 7); Executed by:
| 295 | ||||||||||||||||||
287 | else | - | ||||||||||||||||||
288 | date = date.addDays(dayOfWeek - startDow); executed 3471 times by 2 tests: date = date.addDays(dayOfWeek - startDow); Executed by:
| 3471 | ||||||||||||||||||
289 | date = date.addDays(week * 7); | - | ||||||||||||||||||
290 | while (date.month() != month
| 1243-3766 | ||||||||||||||||||
291 | date = date.addDays(-7); executed 1243 times by 2 tests: date = date.addDays(-7); Executed by:
| 1243 | ||||||||||||||||||
292 | return executed 3766 times by 2 tests: date;return date; Executed by:
executed 3766 times by 2 tests: return date; Executed by:
| 3766 | ||||||||||||||||||
293 | } | - | ||||||||||||||||||
294 | - | |||||||||||||||||||
295 | static QDate calculatePosixDate(const QByteArray &dateRule, int year) | - | ||||||||||||||||||
296 | { | - | ||||||||||||||||||
297 | - | |||||||||||||||||||
298 | if (dateRule.at(0) == 'M'
| 24-3766 | ||||||||||||||||||
299 | - | |||||||||||||||||||
300 | QList<QByteArray> dateParts = dateRule.split('.'); | - | ||||||||||||||||||
301 | int month = dateParts.at(0).mid(1).toInt(); | - | ||||||||||||||||||
302 | int week = dateParts.at(1).toInt(); | - | ||||||||||||||||||
303 | int dow = dateParts.at(2).toInt(); | - | ||||||||||||||||||
304 | if (dow == 0
| 252-3514 | ||||||||||||||||||
305 | ++ executed 3514 times by 2 tests: dow;++dow; Executed by:
executed 3514 times by 2 tests: ++dow; Executed by:
| 3514 | ||||||||||||||||||
306 | return executed 3766 times by 2 tests: calculateDowDate(year, month, dow, week);return calculateDowDate(year, month, dow, week); Executed by:
executed 3766 times by 2 tests: return calculateDowDate(year, month, dow, week); Executed by:
| 3766 | ||||||||||||||||||
307 | } else if (dateRule.at(0) == 'J'
| 0-24 | ||||||||||||||||||
308 | - | |||||||||||||||||||
309 | int doy = dateRule.mid(1).toInt(); | - | ||||||||||||||||||
310 | QDate date = QDate(year, 1, 1).addDays(doy - 1); | - | ||||||||||||||||||
311 | if (QDate::isLeapYear(date.year())
| 0-24 | ||||||||||||||||||
312 | date = date.addDays(-1); never executed: date = date.addDays(-1); | 0 | ||||||||||||||||||
313 | return executed 24 times by 1 test: date;return date; Executed by:
executed 24 times by 1 test: return date; Executed by:
| 24 | ||||||||||||||||||
314 | } else { | - | ||||||||||||||||||
315 | - | |||||||||||||||||||
316 | int doy = dateRule.toInt(); | - | ||||||||||||||||||
317 | return never executed: QDate(year, 1, 1).addDays(doy - 1);return QDate(year, 1, 1).addDays(doy - 1); never executed: return QDate(year, 1, 1).addDays(doy - 1); | 0 | ||||||||||||||||||
318 | } | - | ||||||||||||||||||
319 | } | - | ||||||||||||||||||
320 | - | |||||||||||||||||||
321 | - | |||||||||||||||||||
322 | static int parsePosixTime(const char *begin, const char *end) | - | ||||||||||||||||||
323 | { | - | ||||||||||||||||||
324 | - | |||||||||||||||||||
325 | int hour, min = 0, sec = 0; | - | ||||||||||||||||||
326 | - | |||||||||||||||||||
327 | - | |||||||||||||||||||
328 | - | |||||||||||||||||||
329 | - | |||||||||||||||||||
330 | - | |||||||||||||||||||
331 | - | |||||||||||||||||||
332 | - | |||||||||||||||||||
333 | bool ok = false; | - | ||||||||||||||||||
334 | hour = qstrtoll(begin, &begin, 10, &ok); | - | ||||||||||||||||||
335 | if (!ok
| 0-5037 | ||||||||||||||||||
336 | return executed 8 times by 1 test: (-2147483647 - 1);return (-2147483647 - 1); Executed by:
executed 8 times by 1 test: return (-2147483647 - 1); Executed by:
| 8 | ||||||||||||||||||
337 | if (begin < end
| 0-4855 | ||||||||||||||||||
338 | - | |||||||||||||||||||
339 | ++begin; | - | ||||||||||||||||||
340 | min = qstrtoll(begin, &begin, 10, &ok); | - | ||||||||||||||||||
341 | if (!ok
| 0-174 | ||||||||||||||||||
342 | return never executed: (-2147483647 - 1);return (-2147483647 - 1); never executed: return (-2147483647 - 1); | 0 | ||||||||||||||||||
343 | - | |||||||||||||||||||
344 | if (begin < end
| 0-174 | ||||||||||||||||||
345 | - | |||||||||||||||||||
346 | ++begin; | - | ||||||||||||||||||
347 | sec = qstrtoll(begin, &begin, 10, &ok); | - | ||||||||||||||||||
348 | if (!ok
| 0 | ||||||||||||||||||
349 | return never executed: (-2147483647 - 1);return (-2147483647 - 1); never executed: return (-2147483647 - 1); | 0 | ||||||||||||||||||
350 | } never executed: end of block | 0 | ||||||||||||||||||
351 | } executed 174 times by 1 test: end of block Executed by:
| 174 | ||||||||||||||||||
352 | - | |||||||||||||||||||
353 | - | |||||||||||||||||||
354 | if (begin != end
| 0-5029 | ||||||||||||||||||
355 | return never executed: (-2147483647 - 1);return (-2147483647 - 1); never executed: return (-2147483647 - 1); | 0 | ||||||||||||||||||
356 | - | |||||||||||||||||||
357 | return executed 5029 times by 2 tests: (hour * 60 + min) * 60 + sec;return (hour * 60 + min) * 60 + sec; Executed by:
executed 5029 times by 2 tests: return (hour * 60 + min) * 60 + sec; Executed by:
| 5029 | ||||||||||||||||||
358 | } | - | ||||||||||||||||||
359 | - | |||||||||||||||||||
360 | static QTime parsePosixTransitionTime(const QByteArray &timeRule) | - | ||||||||||||||||||
361 | { | - | ||||||||||||||||||
362 | - | |||||||||||||||||||
363 | int value = parsePosixTime(timeRule.constBegin(), timeRule.constEnd()); | - | ||||||||||||||||||
364 | if (value == (-2147483647 - 1)
| 8-504 | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | return executed 8 times by 1 test: QTime(2, 0, 0);return QTime(2, 0, 0); Executed by:
executed 8 times by 1 test: return QTime(2, 0, 0); Executed by:
| 8 | ||||||||||||||||||
367 | } | - | ||||||||||||||||||
368 | return executed 504 times by 2 tests: QTime::fromMSecsSinceStartOfDay(value * 1000);return QTime::fromMSecsSinceStartOfDay(value * 1000); Executed by:
executed 504 times by 2 tests: return QTime::fromMSecsSinceStartOfDay(value * 1000); Executed by:
| 504 | ||||||||||||||||||
369 | } | - | ||||||||||||||||||
370 | - | |||||||||||||||||||
371 | static int parsePosixOffset(const char *begin, const char *end) | - | ||||||||||||||||||
372 | { | - | ||||||||||||||||||
373 | - | |||||||||||||||||||
374 | - | |||||||||||||||||||
375 | bool negate = true; | - | ||||||||||||||||||
376 | if (*
| 0-4525 | ||||||||||||||||||
377 | ++begin; | - | ||||||||||||||||||
378 | } never executed: else if (*end of block
| 0-2621 | ||||||||||||||||||
379 | negate = false; | - | ||||||||||||||||||
380 | ++begin; | - | ||||||||||||||||||
381 | } executed 2621 times by 2 tests: end of block Executed by:
| 2621 | ||||||||||||||||||
382 | - | |||||||||||||||||||
383 | int value = parsePosixTime(begin, end); | - | ||||||||||||||||||
384 | if (value == (-2147483647 - 1)
| 0-4525 | ||||||||||||||||||
385 | return never executed: value;return value; never executed: return value; | 0 | ||||||||||||||||||
386 | return executed 4525 times by 2 tests: negatereturn negate ? -value : value; Executed by:
executed 4525 times by 2 tests: return negate ? -value : value; Executed by:
| 1904-4525 | ||||||||||||||||||
387 | } | - | ||||||||||||||||||
388 | - | |||||||||||||||||||
389 | static inline bool asciiIsLetter(char ch) | - | ||||||||||||||||||
390 | { | - | ||||||||||||||||||
391 | ch |= 0x20; | - | ||||||||||||||||||
392 | return executed 20587 times by 2 tests: ch >= 'a'return ch >= 'a' && ch <= 'z'; Executed by:
executed 20587 times by 2 tests: return ch >= 'a' && ch <= 'z'; Executed by:
| 0-20587 | ||||||||||||||||||
393 | } | - | ||||||||||||||||||
394 | - | |||||||||||||||||||
395 | - | |||||||||||||||||||
396 | - | |||||||||||||||||||
397 | - | |||||||||||||||||||
398 | static QPair<QString, int> parsePosixZoneNameAndOffset(const char *&pos, const char *end) | - | ||||||||||||||||||
399 | { | - | ||||||||||||||||||
400 | static const char offsetChars[] = "0123456789:"; | - | ||||||||||||||||||
401 | QPair<QString, int> result = qMakePair(QString(), (-2147483647 - 1)); | - | ||||||||||||||||||
402 | - | |||||||||||||||||||
403 | const char *nameBegin = pos; | - | ||||||||||||||||||
404 | const char *nameEnd; | - | ||||||||||||||||||
405 | ((!(pos < end)) ? qt_assert("pos < end",__FILE__,459) : qt_noop()); | - | ||||||||||||||||||
406 | - | |||||||||||||||||||
407 | if (*
| 147-5002 | ||||||||||||||||||
408 | nameBegin = pos + 1; | - | ||||||||||||||||||
409 | nameEnd = nameBegin; | - | ||||||||||||||||||
410 | while (nameEnd < end
| 0-588 | ||||||||||||||||||
411 | - | |||||||||||||||||||
412 | ++nameEnd; | - | ||||||||||||||||||
413 | } executed 441 times by 1 test: end of block Executed by:
| 441 | ||||||||||||||||||
414 | pos = nameEnd + 1; | - | ||||||||||||||||||
415 | } executed 147 times by 1 test: else {end of block Executed by:
| 147 | ||||||||||||||||||
416 | nameBegin = pos; | - | ||||||||||||||||||
417 | nameEnd = nameBegin; | - | ||||||||||||||||||
418 | while (nameEnd < end
| 624-20587 | ||||||||||||||||||
419 | ++ executed 16209 times by 2 tests: nameEnd;++nameEnd; Executed by:
executed 16209 times by 2 tests: ++nameEnd; Executed by:
| 16209 | ||||||||||||||||||
420 | pos = nameEnd; | - | ||||||||||||||||||
421 | } executed 5002 times by 2 tests: end of block Executed by:
| 5002 | ||||||||||||||||||
422 | if (nameEnd - nameBegin < 3
| 0-5149 | ||||||||||||||||||
423 | return never executed: result;return result; never executed: return result; | 0 | ||||||||||||||||||
424 | - | |||||||||||||||||||
425 | - | |||||||||||||||||||
426 | const char *zoneBegin = pos; | - | ||||||||||||||||||
427 | const char *zoneEnd = pos; | - | ||||||||||||||||||
428 | if (zoneEnd < end
| 0-4525 | ||||||||||||||||||
429 | ++ executed 2621 times by 2 tests: zoneEnd;++zoneEnd; Executed by:
executed 2621 times by 2 tests: ++zoneEnd; Executed by:
| 2621 | ||||||||||||||||||
430 | while (zoneEnd < end
| 4517-6295 | ||||||||||||||||||
431 | if (strchr(offsetChars, char(*zoneEnd)) == __null
| 632-5663 | ||||||||||||||||||
432 | break; executed 632 times by 2 tests: break; Executed by:
| 632 | ||||||||||||||||||
433 | ++zoneEnd; | - | ||||||||||||||||||
434 | } executed 5663 times by 2 tests: end of block Executed by:
| 5663 | ||||||||||||||||||
435 | - | |||||||||||||||||||
436 | result.first = QString::fromUtf8(nameBegin, nameEnd - nameBegin); | - | ||||||||||||||||||
437 | if (zoneEnd > zoneBegin
| 624-4525 | ||||||||||||||||||
438 | result.second = parsePosixOffset(zoneBegin, zoneEnd); executed 4525 times by 2 tests: result.second = parsePosixOffset(zoneBegin, zoneEnd); Executed by:
| 4525 | ||||||||||||||||||
439 | pos = zoneEnd; | - | ||||||||||||||||||
440 | return executed 5149 times by 2 tests: result;return result; Executed by:
executed 5149 times by 2 tests: return result; Executed by:
| 5149 | ||||||||||||||||||
441 | } | - | ||||||||||||||||||
442 | - | |||||||||||||||||||
443 | static QVector<QTimeZonePrivate::Data> calculatePosixTransitions(const QByteArray &posixRule, | - | ||||||||||||||||||
444 | int startYear, int endYear, | - | ||||||||||||||||||
445 | int lastTranMSecs) | - | ||||||||||||||||||
446 | { | - | ||||||||||||||||||
447 | QVector<QTimeZonePrivate::Data> result; | - | ||||||||||||||||||
448 | - | |||||||||||||||||||
449 | - | |||||||||||||||||||
450 | if (startYear > 292278994
| 0-4517 | ||||||||||||||||||
451 | startYear = 292278994; never executed: startYear = 292278994; | 0 | ||||||||||||||||||
452 | if (endYear > 292278994
| 1-4516 | ||||||||||||||||||
453 | endYear = 292278994; executed 1 time by 1 test: endYear = 292278994; Executed by:
| 1 | ||||||||||||||||||
454 | - | |||||||||||||||||||
455 | - | |||||||||||||||||||
456 | - | |||||||||||||||||||
457 | - | |||||||||||||||||||
458 | QList<QByteArray> parts = posixRule.split(','); | - | ||||||||||||||||||
459 | - | |||||||||||||||||||
460 | QPair<QString, int> stdZone, dstZone; | - | ||||||||||||||||||
461 | { | - | ||||||||||||||||||
462 | const QByteArray &zoneinfo = parts.at(0); | - | ||||||||||||||||||
463 | const char *begin = zoneinfo.constBegin(); | - | ||||||||||||||||||
464 | - | |||||||||||||||||||
465 | stdZone = parsePosixZoneNameAndOffset(begin, zoneinfo.constEnd()); | - | ||||||||||||||||||
466 | if (stdZone.second == (-2147483647 - 1)
| 0-4517 | ||||||||||||||||||
467 | stdZone.second = 0; | - | ||||||||||||||||||
468 | } never executed: else if (begin < zoneinfo.constEnd()end of block
| 0-3885 | ||||||||||||||||||
469 | dstZone = parsePosixZoneNameAndOffset(begin, zoneinfo.constEnd()); | - | ||||||||||||||||||
470 | if (dstZone.second == (-2147483647 - 1)
| 8-624 | ||||||||||||||||||
471 | - | |||||||||||||||||||
472 | dstZone.second = stdZone.second + (60 * 60); | - | ||||||||||||||||||
473 | } executed 624 times by 2 tests: end of block Executed by:
| 624 | ||||||||||||||||||
474 | } executed 632 times by 2 tests: end of block Executed by:
| 632 | ||||||||||||||||||
475 | } | - | ||||||||||||||||||
476 | - | |||||||||||||||||||
477 | - | |||||||||||||||||||
478 | if (parts.count() == 1
| 632-3885 | ||||||||||||||||||
479 | QTimeZonePrivate::Data data; | - | ||||||||||||||||||
480 | data.atMSecsSinceEpoch = lastTranMSecs; | - | ||||||||||||||||||
481 | data.offsetFromUtc = stdZone.second; | - | ||||||||||||||||||
482 | data.standardTimeOffset = stdZone.second; | - | ||||||||||||||||||
483 | data.daylightTimeOffset = 0; | - | ||||||||||||||||||
484 | data.abbreviation = stdZone.first; | - | ||||||||||||||||||
485 | result << data; | - | ||||||||||||||||||
486 | return executed 3885 times by 2 tests: result;return result; Executed by:
executed 3885 times by 2 tests: return result; Executed by:
| 3885 | ||||||||||||||||||
487 | } | - | ||||||||||||||||||
488 | - | |||||||||||||||||||
489 | - | |||||||||||||||||||
490 | - | |||||||||||||||||||
491 | QList<QByteArray> dstParts = parts.at(1).split('/'); | - | ||||||||||||||||||
492 | QByteArray dstDateRule = dstParts.at(0); | - | ||||||||||||||||||
493 | QTime dstTime; | - | ||||||||||||||||||
494 | if (dstParts.count() > 1
| 172-460 | ||||||||||||||||||
495 | dstTime = parsePosixTransitionTime(dstParts.at(1)); executed 172 times by 1 test: dstTime = parsePosixTransitionTime(dstParts.at(1)); Executed by:
| 172 | ||||||||||||||||||
496 | else | - | ||||||||||||||||||
497 | dstTime = QTime(2, 0, 0); executed 460 times by 2 tests: dstTime = QTime(2, 0, 0); Executed by:
| 460 | ||||||||||||||||||
498 | - | |||||||||||||||||||
499 | - | |||||||||||||||||||
500 | QList<QByteArray> stdParts = parts.at(2).split('/'); | - | ||||||||||||||||||
501 | QByteArray stdDateRule = stdParts.at(0); | - | ||||||||||||||||||
502 | QTime stdTime; | - | ||||||||||||||||||
503 | if (stdParts.count() > 1
| 292-340 | ||||||||||||||||||
504 | stdTime = parsePosixTransitionTime(stdParts.at(1)); executed 340 times by 2 tests: stdTime = parsePosixTransitionTime(stdParts.at(1)); Executed by:
| 340 | ||||||||||||||||||
505 | else | - | ||||||||||||||||||
506 | stdTime = QTime(2, 0, 0); executed 292 times by 1 test: stdTime = QTime(2, 0, 0); Executed by:
| 292 | ||||||||||||||||||
507 | - | |||||||||||||||||||
508 | for (int year = startYear; year <= endYear
| 632-1895 | ||||||||||||||||||
509 | QTimeZonePrivate::Data dstData; | - | ||||||||||||||||||
510 | QDateTime dst(calculatePosixDate(dstDateRule, year), dstTime, Qt::UTC); | - | ||||||||||||||||||
511 | dstData.atMSecsSinceEpoch = dst.toMSecsSinceEpoch() - (stdZone.second * 1000); | - | ||||||||||||||||||
512 | dstData.offsetFromUtc = dstZone.second; | - | ||||||||||||||||||
513 | dstData.standardTimeOffset = stdZone.second; | - | ||||||||||||||||||
514 | dstData.daylightTimeOffset = dstZone.second - stdZone.second; | - | ||||||||||||||||||
515 | dstData.abbreviation = dstZone.first; | - | ||||||||||||||||||
516 | QTimeZonePrivate::Data stdData; | - | ||||||||||||||||||
517 | QDateTime std(calculatePosixDate(stdDateRule, year), stdTime, Qt::UTC); | - | ||||||||||||||||||
518 | stdData.atMSecsSinceEpoch = std.toMSecsSinceEpoch() - (dstZone.second * 1000); | - | ||||||||||||||||||
519 | stdData.offsetFromUtc = stdZone.second; | - | ||||||||||||||||||
520 | stdData.standardTimeOffset = stdZone.second; | - | ||||||||||||||||||
521 | stdData.daylightTimeOffset = 0; | - | ||||||||||||||||||
522 | stdData.abbreviation = stdZone.first; | - | ||||||||||||||||||
523 | - | |||||||||||||||||||
524 | if (year == 292278994
| 0-1894 | ||||||||||||||||||
525 | if (dstData.atMSecsSinceEpoch > 0
| 0-1 | ||||||||||||||||||
526 | result << dstData; | - | ||||||||||||||||||
527 | } executed 1 time by 1 test: else if (stdData.atMSecsSinceEpoch > 0end of block Executed by:
| 0-1 | ||||||||||||||||||
528 | result << stdData; | - | ||||||||||||||||||
529 | } never executed: end of block | 0 | ||||||||||||||||||
530 | } executed 1 time by 1 test: else if (dst < stdend of block Executed by:
| 1-1654 | ||||||||||||||||||
531 | result << dstData << stdData; | - | ||||||||||||||||||
532 | } executed 1654 times by 2 tests: else {end of block Executed by:
| 1654 | ||||||||||||||||||
533 | result << stdData << dstData; | - | ||||||||||||||||||
534 | } executed 240 times by 1 test: end of block Executed by:
| 240 | ||||||||||||||||||
535 | } | - | ||||||||||||||||||
536 | return executed 632 times by 2 tests: result;return result; Executed by:
executed 632 times by 2 tests: return result; Executed by:
| 632 | ||||||||||||||||||
537 | } | - | ||||||||||||||||||
538 | - | |||||||||||||||||||
539 | - | |||||||||||||||||||
540 | QTzTimeZonePrivate::QTzTimeZonePrivate() | - | ||||||||||||||||||
541 | - | |||||||||||||||||||
542 | : m_icu(0) | - | ||||||||||||||||||
543 | - | |||||||||||||||||||
544 | { | - | ||||||||||||||||||
545 | init(systemTimeZoneId()); | - | ||||||||||||||||||
546 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
547 | - | |||||||||||||||||||
548 | - | |||||||||||||||||||
549 | QTzTimeZonePrivate::QTzTimeZonePrivate(const QByteArray &ianaId) | - | ||||||||||||||||||
550 | - | |||||||||||||||||||
551 | : m_icu(0) | - | ||||||||||||||||||
552 | - | |||||||||||||||||||
553 | { | - | ||||||||||||||||||
554 | init(ianaId); | - | ||||||||||||||||||
555 | } executed 455 times by 2 tests: end of block Executed by:
| 455 | ||||||||||||||||||
556 | - | |||||||||||||||||||
557 | QTzTimeZonePrivate::QTzTimeZonePrivate(const QTzTimeZonePrivate &other) | - | ||||||||||||||||||
558 | : QTimeZonePrivate(other), m_tranTimes(other.m_tranTimes), | - | ||||||||||||||||||
559 | m_tranRules(other.m_tranRules), m_abbreviations(other.m_abbreviations), | - | ||||||||||||||||||
560 | - | |||||||||||||||||||
561 | m_icu(other.m_icu), | - | ||||||||||||||||||
562 | - | |||||||||||||||||||
563 | m_posixRule(other.m_posixRule) | - | ||||||||||||||||||
564 | { | - | ||||||||||||||||||
565 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||
566 | - | |||||||||||||||||||
567 | QTzTimeZonePrivate::~QTzTimeZonePrivate() | - | ||||||||||||||||||
568 | { | - | ||||||||||||||||||
569 | } | - | ||||||||||||||||||
570 | - | |||||||||||||||||||
571 | QTimeZonePrivate *QTzTimeZonePrivate::clone() | - | ||||||||||||||||||
572 | { | - | ||||||||||||||||||
573 | return executed 20 times by 1 test: new QTzTimeZonePrivate(*this);return new QTzTimeZonePrivate(*this); Executed by:
executed 20 times by 1 test: return new QTzTimeZonePrivate(*this); Executed by:
| 20 | ||||||||||||||||||
574 | } | - | ||||||||||||||||||
575 | - | |||||||||||||||||||
576 | void QTzTimeZonePrivate::init(const QByteArray &ianaId) | - | ||||||||||||||||||
577 | { | - | ||||||||||||||||||
578 | QFile tzif; | - | ||||||||||||||||||
579 | if (ianaId.isEmpty()
| 0-457 | ||||||||||||||||||
580 | - | |||||||||||||||||||
581 | tzif.setFileName(([]() -> QString { enum { Size = sizeof(u"" "/etc/localtime")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/etc/localtime" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
582 | if (!tzif.open(QIODevice::ReadOnly)
| 0 | ||||||||||||||||||
583 | return; never executed: return; | 0 | ||||||||||||||||||
584 | } never executed: else {end of block | 0 | ||||||||||||||||||
585 | - | |||||||||||||||||||
586 | tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId)); | - | ||||||||||||||||||
587 | if (!tzif.open(QIODevice::ReadOnly)
| 3-454 | ||||||||||||||||||
588 | tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId)); | - | ||||||||||||||||||
589 | if (!tzif.open(QIODevice::ReadOnly)
| 0-3 | ||||||||||||||||||
590 | return; executed 3 times by 2 tests: return; Executed by:
| 3 | ||||||||||||||||||
591 | } never executed: end of block | 0 | ||||||||||||||||||
592 | } executed 454 times by 2 tests: end of block Executed by:
| 454 | ||||||||||||||||||
593 | - | |||||||||||||||||||
594 | QDataStream ds(&tzif); | - | ||||||||||||||||||
595 | - | |||||||||||||||||||
596 | - | |||||||||||||||||||
597 | bool ok = false; | - | ||||||||||||||||||
598 | QTzHeader hdr = parseTzHeader(ds, &ok); | - | ||||||||||||||||||
599 | if (!ok
| 0-454 | ||||||||||||||||||
600 | return; never executed: return; | 0 | ||||||||||||||||||
601 | QVector<QTzTransition> tranList = parseTzTransitions(ds, hdr.tzh_timecnt, false); | - | ||||||||||||||||||
602 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
603 | return; never executed: return; | 0 | ||||||||||||||||||
604 | QVector<QTzType> typeList = parseTzTypes(ds, hdr.tzh_typecnt); | - | ||||||||||||||||||
605 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
606 | return; never executed: return; | 0 | ||||||||||||||||||
607 | QMap<int, QByteArray> abbrevMap = parseTzAbbreviations(ds, hdr.tzh_charcnt, typeList); | - | ||||||||||||||||||
608 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
609 | return; never executed: return; | 0 | ||||||||||||||||||
610 | parseTzLeapSeconds(ds, hdr.tzh_leapcnt, false); | - | ||||||||||||||||||
611 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
612 | return; never executed: return; | 0 | ||||||||||||||||||
613 | typeList = parseTzIndicators(ds, typeList, hdr.tzh_ttisstdcnt, hdr.tzh_ttisgmtcnt); | - | ||||||||||||||||||
614 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
615 | return; never executed: return; | 0 | ||||||||||||||||||
616 | - | |||||||||||||||||||
617 | - | |||||||||||||||||||
618 | if (hdr.tzh_version == '2'
| 0-447 | ||||||||||||||||||
619 | ok = false; | - | ||||||||||||||||||
620 | QTzHeader hdr2 = parseTzHeader(ds, &ok); | - | ||||||||||||||||||
621 | if (!ok
| 0-454 | ||||||||||||||||||
622 | return; never executed: return; | 0 | ||||||||||||||||||
623 | tranList = parseTzTransitions(ds, hdr2.tzh_timecnt, true); | - | ||||||||||||||||||
624 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
625 | return; never executed: return; | 0 | ||||||||||||||||||
626 | typeList = parseTzTypes(ds, hdr2.tzh_typecnt); | - | ||||||||||||||||||
627 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
628 | return; never executed: return; | 0 | ||||||||||||||||||
629 | abbrevMap = parseTzAbbreviations(ds, hdr2.tzh_charcnt, typeList); | - | ||||||||||||||||||
630 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
631 | return; never executed: return; | 0 | ||||||||||||||||||
632 | parseTzLeapSeconds(ds, hdr2.tzh_leapcnt, true); | - | ||||||||||||||||||
633 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
634 | return; never executed: return; | 0 | ||||||||||||||||||
635 | typeList = parseTzIndicators(ds, typeList, hdr2.tzh_ttisstdcnt, hdr2.tzh_ttisgmtcnt); | - | ||||||||||||||||||
636 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
637 | return; never executed: return; | 0 | ||||||||||||||||||
638 | m_posixRule = parseTzPosixRule(ds); | - | ||||||||||||||||||
639 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
640 | return; never executed: return; | 0 | ||||||||||||||||||
641 | } executed 454 times by 2 tests: end of block Executed by:
| 454 | ||||||||||||||||||
642 | - | |||||||||||||||||||
643 | - | |||||||||||||||||||
644 | - | |||||||||||||||||||
645 | - | |||||||||||||||||||
646 | m_abbreviations = abbrevMap.values(); | - | ||||||||||||||||||
647 | QList<int> abbrindList = abbrevMap.keys(); | - | ||||||||||||||||||
648 | for (int i = 0; i < typeList.size()
| 454-2700 | ||||||||||||||||||
649 | typeList[i].tz_abbrind = abbrindList.indexOf(typeList.at(i).tz_abbrind); executed 2700 times by 2 tests: typeList[i].tz_abbrind = abbrindList.indexOf(typeList.at(i).tz_abbrind); Executed by:
| 2700 | ||||||||||||||||||
650 | - | |||||||||||||||||||
651 | - | |||||||||||||||||||
652 | - | |||||||||||||||||||
653 | int utcOffset = 0; | - | ||||||||||||||||||
654 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(tranList)>::type> _container_((tranList)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QTzTransition &tran = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
655 | if (!typeList.at(tran.tz_typeind).tz_isdst
| 3-454 | ||||||||||||||||||
656 | utcOffset = typeList.at(tran.tz_typeind).tz_gmtoff; | - | ||||||||||||||||||
657 | break; executed 454 times by 2 tests: break; Executed by:
| 454 | ||||||||||||||||||
658 | } | - | ||||||||||||||||||
659 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||
660 | - | |||||||||||||||||||
661 | - | |||||||||||||||||||
662 | m_tranTimes.reserve(tranList.count()); | - | ||||||||||||||||||
663 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(tranList)>::type> _container_((tranList)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QTzTransition &tz_tran = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
664 | QTzTransitionTime tran; | - | ||||||||||||||||||
665 | QTzTransitionRule rule; | - | ||||||||||||||||||
666 | const QTzType tz_type = typeList.at(tz_tran.tz_typeind); | - | ||||||||||||||||||
667 | - | |||||||||||||||||||
668 | - | |||||||||||||||||||
669 | if (!tz_type.tz_isdst
| 15309-16244 | ||||||||||||||||||
670 | utcOffset = tz_type.tz_gmtoff; executed 16244 times by 2 tests: utcOffset = tz_type.tz_gmtoff; Executed by:
| 16244 | ||||||||||||||||||
671 | rule.stdOffset = utcOffset; | - | ||||||||||||||||||
672 | rule.dstOffset = tz_type.tz_gmtoff - utcOffset; | - | ||||||||||||||||||
673 | rule.abbreviationIndex = tz_type.tz_abbrind; | - | ||||||||||||||||||
674 | - | |||||||||||||||||||
675 | int ruleIndex = m_tranRules.indexOf(rule); | - | ||||||||||||||||||
676 | if (ruleIndex == -1
| 1704-29849 | ||||||||||||||||||
677 | m_tranRules.append(rule); | - | ||||||||||||||||||
678 | tran.ruleIndex = m_tranRules.size() - 1; | - | ||||||||||||||||||
679 | } executed 1704 times by 2 tests: else {end of block Executed by:
| 1704 | ||||||||||||||||||
680 | tran.ruleIndex = ruleIndex; | - | ||||||||||||||||||
681 | } executed 29849 times by 2 tests: end of block Executed by:
| 29849 | ||||||||||||||||||
682 | - | |||||||||||||||||||
683 | - | |||||||||||||||||||
684 | if (tz_type.tz_ttisgmt
| 8759-22794 | ||||||||||||||||||
685 | tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000; executed 8759 times by 2 tests: tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000; Executed by:
| 8759 | ||||||||||||||||||
686 | else if (tz_type.tz_ttisstd
| 7286-15508 | ||||||||||||||||||
687 | tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000; executed 7286 times by 2 tests: tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000; Executed by:
| 7286 | ||||||||||||||||||
688 | else | - | ||||||||||||||||||
689 | tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000; executed 15508 times by 2 tests: tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000; Executed by:
| 15508 | ||||||||||||||||||
690 | - | |||||||||||||||||||
691 | m_tranTimes.append(tran); | - | ||||||||||||||||||
692 | } executed 31553 times by 2 tests: end of block Executed by:
| 31553 | ||||||||||||||||||
693 | - | |||||||||||||||||||
694 | if (ianaId.isEmpty()
| 0-454 | ||||||||||||||||||
695 | m_id = systemTimeZoneId(); never executed: m_id = systemTimeZoneId(); | 0 | ||||||||||||||||||
696 | else | - | ||||||||||||||||||
697 | m_id = ianaId; executed 454 times by 2 tests: m_id = ianaId; Executed by:
| 454 | ||||||||||||||||||
698 | } | - | ||||||||||||||||||
699 | - | |||||||||||||||||||
700 | QLocale::Country QTzTimeZonePrivate::country() const | - | ||||||||||||||||||
701 | { | - | ||||||||||||||||||
702 | return executed 422 times by 1 test: tzZones->value(m_id).country;return tzZones->value(m_id).country; Executed by:
executed 422 times by 1 test: return tzZones->value(m_id).country; Executed by:
| 422 | ||||||||||||||||||
703 | } | - | ||||||||||||||||||
704 | - | |||||||||||||||||||
705 | QString QTzTimeZonePrivate::comment() const | - | ||||||||||||||||||
706 | { | - | ||||||||||||||||||
707 | return executed 421 times by 1 test: QString::fromUtf8(tzZones->value(m_id).comment);return QString::fromUtf8(tzZones->value(m_id).comment); Executed by:
executed 421 times by 1 test: return QString::fromUtf8(tzZones->value(m_id).comment); Executed by:
| 421 | ||||||||||||||||||
708 | } | - | ||||||||||||||||||
709 | - | |||||||||||||||||||
710 | QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch, | - | ||||||||||||||||||
711 | QTimeZone::NameType nameType, | - | ||||||||||||||||||
712 | const QLocale &locale) const | - | ||||||||||||||||||
713 | { | - | ||||||||||||||||||
714 | - | |||||||||||||||||||
715 | if (!m_icu
| 0-421 | ||||||||||||||||||
716 | m_icu = new QIcuTimeZonePrivate(m_id); executed 421 times by 1 test: m_icu = new QIcuTimeZonePrivate(m_id); Executed by:
| 421 | ||||||||||||||||||
717 | - | |||||||||||||||||||
718 | - | |||||||||||||||||||
719 | if (m_icu->isValid()
| 10-411 | ||||||||||||||||||
720 | return executed 411 times by 1 test: m_icu->displayName(atMSecsSinceEpoch, nameType, locale);return m_icu->displayName(atMSecsSinceEpoch, nameType, locale); Executed by:
executed 411 times by 1 test: return m_icu->displayName(atMSecsSinceEpoch, nameType, locale); Executed by:
| 411 | ||||||||||||||||||
721 | - | |||||||||||||||||||
722 | - | |||||||||||||||||||
723 | - | |||||||||||||||||||
724 | - | |||||||||||||||||||
725 | return executed 10 times by 1 test: abbreviation(atMSecsSinceEpoch);return abbreviation(atMSecsSinceEpoch); Executed by:
executed 10 times by 1 test: return abbreviation(atMSecsSinceEpoch); Executed by:
| 10 | ||||||||||||||||||
726 | } | - | ||||||||||||||||||
727 | - | |||||||||||||||||||
728 | QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType, | - | ||||||||||||||||||
729 | QTimeZone::NameType nameType, | - | ||||||||||||||||||
730 | const QLocale &locale) const | - | ||||||||||||||||||
731 | { | - | ||||||||||||||||||
732 | - | |||||||||||||||||||
733 | if (!m_icu
| 0-842 | ||||||||||||||||||
734 | m_icu = new QIcuTimeZonePrivate(m_id); never executed: m_icu = new QIcuTimeZonePrivate(m_id); | 0 | ||||||||||||||||||
735 | - | |||||||||||||||||||
736 | - | |||||||||||||||||||
737 | if (m_icu->isValid()
| 20-822 | ||||||||||||||||||
738 | return executed 822 times by 1 test: m_icu->displayName(timeType, nameType, locale);return m_icu->displayName(timeType, nameType, locale); Executed by:
executed 822 times by 1 test: return m_icu->displayName(timeType, nameType, locale); Executed by:
| 822 | ||||||||||||||||||
739 | - | |||||||||||||||||||
740 | - | |||||||||||||||||||
741 | - | |||||||||||||||||||
742 | - | |||||||||||||||||||
743 | - | |||||||||||||||||||
744 | - | |||||||||||||||||||
745 | - | |||||||||||||||||||
746 | if (timeType == QTimeZone::GenericTime
| 0-20 | ||||||||||||||||||
747 | timeType = QTimeZone::StandardTime; never executed: timeType = QTimeZone::StandardTime; | 0 | ||||||||||||||||||
748 | - | |||||||||||||||||||
749 | - | |||||||||||||||||||
750 | const qint64 currentMSecs = QDateTime::currentMSecsSinceEpoch(); | - | ||||||||||||||||||
751 | QTimeZonePrivate::Data tran = data(currentMSecs); | - | ||||||||||||||||||
752 | if (tran.atMSecsSinceEpoch != invalidMSecs()
| 0-20 | ||||||||||||||||||
753 | && ((timeType == QTimeZone::DaylightTime
| 1-10 | ||||||||||||||||||
754 | || (timeType == QTimeZone::StandardTime
| 1-10 | ||||||||||||||||||
755 | return executed 10 times by 1 test: tran.abbreviation;return tran.abbreviation; Executed by:
executed 10 times by 1 test: return tran.abbreviation; Executed by:
| 10 | ||||||||||||||||||
756 | } | - | ||||||||||||||||||
757 | - | |||||||||||||||||||
758 | - | |||||||||||||||||||
759 | tran = nextTransition(currentMSecs); | - | ||||||||||||||||||
760 | if (tran.atMSecsSinceEpoch != invalidMSecs()
| 1-9 | ||||||||||||||||||
761 | && ((timeType == QTimeZone::DaylightTime
| 0-1 | ||||||||||||||||||
762 | || (timeType == QTimeZone::StandardTime
| 0-1 | ||||||||||||||||||
763 | return executed 1 time by 1 test: tran.abbreviation;return tran.abbreviation; Executed by:
executed 1 time by 1 test: return tran.abbreviation; Executed by:
| 1 | ||||||||||||||||||
764 | } | - | ||||||||||||||||||
765 | - | |||||||||||||||||||
766 | - | |||||||||||||||||||
767 | tran = previousTransition(currentMSecs); | - | ||||||||||||||||||
768 | if (tran.atMSecsSinceEpoch != invalidMSecs()
| 0-9 | ||||||||||||||||||
769 | tran = previousTransition(tran.atMSecsSinceEpoch); executed 9 times by 1 test: tran = previousTransition(tran.atMSecsSinceEpoch); Executed by:
| 9 | ||||||||||||||||||
770 | if (tran.atMSecsSinceEpoch != invalidMSecs()
| 0-9 | ||||||||||||||||||
771 | && ((timeType == QTimeZone::DaylightTime
| 0-9 | ||||||||||||||||||
772 | || (timeType == QTimeZone::StandardTime
| 0-9 | ||||||||||||||||||
773 | return never executed: tran.abbreviation;return tran.abbreviation; never executed: return tran.abbreviation; | 0 | ||||||||||||||||||
774 | } | - | ||||||||||||||||||
775 | - | |||||||||||||||||||
776 | - | |||||||||||||||||||
777 | for (int i = m_tranTimes.size() - 1; i >= 0
| 1-41 | ||||||||||||||||||
778 | if (m_tranTimes.at(i).atMSecsSinceEpoch <= currentMSecs
| 0-41 | ||||||||||||||||||
779 | tran = dataForTzTransition(m_tranTimes.at(i)); | - | ||||||||||||||||||
780 | if ((timeType == QTimeZone::DaylightTime
| 0-41 | ||||||||||||||||||
781 | || (timeType == QTimeZone::StandardTime
| 0-33 | ||||||||||||||||||
782 | return executed 8 times by 1 test: tran.abbreviation;return tran.abbreviation; Executed by:
executed 8 times by 1 test: return tran.abbreviation; Executed by:
| 8 | ||||||||||||||||||
783 | } | - | ||||||||||||||||||
784 | } executed 33 times by 1 test: end of block Executed by:
| 33 | ||||||||||||||||||
785 | } executed 33 times by 1 test: end of block Executed by:
| 33 | ||||||||||||||||||
786 | - | |||||||||||||||||||
787 | - | |||||||||||||||||||
788 | return executed 1 time by 1 test: data(currentMSecs).abbreviation;return data(currentMSecs).abbreviation; Executed by:
executed 1 time by 1 test: return data(currentMSecs).abbreviation; Executed by:
| 1 | ||||||||||||||||||
789 | } | - | ||||||||||||||||||
790 | - | |||||||||||||||||||
791 | QString QTzTimeZonePrivate::abbreviation(qint64 atMSecsSinceEpoch) const | - | ||||||||||||||||||
792 | { | - | ||||||||||||||||||
793 | return executed 860 times by 2 tests: data(atMSecsSinceEpoch).abbreviation;return data(atMSecsSinceEpoch).abbreviation; Executed by:
executed 860 times by 2 tests: return data(atMSecsSinceEpoch).abbreviation; Executed by:
| 860 | ||||||||||||||||||
794 | } | - | ||||||||||||||||||
795 | - | |||||||||||||||||||
796 | int QTzTimeZonePrivate::offsetFromUtc(qint64 atMSecsSinceEpoch) const | - | ||||||||||||||||||
797 | { | - | ||||||||||||||||||
798 | const QTimeZonePrivate::Data tran = data(atMSecsSinceEpoch); | - | ||||||||||||||||||
799 | return executed 441 times by 2 tests: tran.standardTimeOffset + tran.daylightTimeOffset;return tran.standardTimeOffset + tran.daylightTimeOffset; Executed by:
executed 441 times by 2 tests: return tran.standardTimeOffset + tran.daylightTimeOffset; Executed by:
| 441 | ||||||||||||||||||
800 | } | - | ||||||||||||||||||
801 | - | |||||||||||||||||||
802 | int QTzTimeZonePrivate::standardTimeOffset(qint64 atMSecsSinceEpoch) const | - | ||||||||||||||||||
803 | { | - | ||||||||||||||||||
804 | return executed 693 times by 2 tests: data(atMSecsSinceEpoch).standardTimeOffset;return data(atMSecsSinceEpoch).standardTimeOffset; Executed by:
executed 693 times by 2 tests: return data(atMSecsSinceEpoch).standardTimeOffset; Executed by:
| 693 | ||||||||||||||||||
805 | } | - | ||||||||||||||||||
806 | - | |||||||||||||||||||
807 | int QTzTimeZonePrivate::daylightTimeOffset(qint64 atMSecsSinceEpoch) const | - | ||||||||||||||||||
808 | { | - | ||||||||||||||||||
809 | return executed 588 times by 2 tests: data(atMSecsSinceEpoch).daylightTimeOffset;return data(atMSecsSinceEpoch).daylightTimeOffset; Executed by:
executed 588 times by 2 tests: return data(atMSecsSinceEpoch).daylightTimeOffset; Executed by:
| 588 | ||||||||||||||||||
810 | } | - | ||||||||||||||||||
811 | - | |||||||||||||||||||
812 | bool QTzTimeZonePrivate::hasDaylightTime() const | - | ||||||||||||||||||
813 | { | - | ||||||||||||||||||
814 | - | |||||||||||||||||||
815 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_tranRules)>::type> _container_((m_tranRules)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QTzTransitionRule &rule = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
816 | if (rule.dstOffset != 0
| 1519-3635 | ||||||||||||||||||
817 | return executed 1519 times by 2 tests: true;return true; Executed by:
executed 1519 times by 2 tests: return true; Executed by:
| 1519 | ||||||||||||||||||
818 | } executed 3635 times by 2 tests: end of block Executed by:
| 3635 | ||||||||||||||||||
819 | return executed 660 times by 1 test: false;return false; Executed by:
executed 660 times by 1 test: return false; Executed by:
| 660 | ||||||||||||||||||
820 | } | - | ||||||||||||||||||
821 | - | |||||||||||||||||||
822 | bool QTzTimeZonePrivate::isDaylightTime(qint64 atMSecsSinceEpoch) const | - | ||||||||||||||||||
823 | { | - | ||||||||||||||||||
824 | return executed 295 times by 2 tests: (daylightTimeOffset(atMSecsSinceEpoch) != 0);return (daylightTimeOffset(atMSecsSinceEpoch) != 0); Executed by:
executed 295 times by 2 tests: return (daylightTimeOffset(atMSecsSinceEpoch) != 0); Executed by:
| 295 | ||||||||||||||||||
825 | } | - | ||||||||||||||||||
826 | - | |||||||||||||||||||
827 | QTimeZonePrivate::Data QTzTimeZonePrivate::dataForTzTransition(QTzTransitionTime tran) const | - | ||||||||||||||||||
828 | { | - | ||||||||||||||||||
829 | QTimeZonePrivate::Data data; | - | ||||||||||||||||||
830 | data.atMSecsSinceEpoch = tran.atMSecsSinceEpoch; | - | ||||||||||||||||||
831 | QTzTransitionRule rule = m_tranRules.at(tran.ruleIndex); | - | ||||||||||||||||||
832 | data.standardTimeOffset = rule.stdOffset; | - | ||||||||||||||||||
833 | data.daylightTimeOffset = rule.dstOffset; | - | ||||||||||||||||||
834 | data.offsetFromUtc = rule.stdOffset + rule.dstOffset; | - | ||||||||||||||||||
835 | data.abbreviation = QString::fromUtf8(m_abbreviations.at(rule.abbreviationIndex)); | - | ||||||||||||||||||
836 | return executed 9024 times by 2 tests: data;return data; Executed by:
executed 9024 times by 2 tests: return data; Executed by:
| 9024 | ||||||||||||||||||
837 | } | - | ||||||||||||||||||
838 | - | |||||||||||||||||||
839 | QTimeZonePrivate::Data QTzTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const | - | ||||||||||||||||||
840 | { | - | ||||||||||||||||||
841 | - | |||||||||||||||||||
842 | if (m_tranTimes.size() > 0
| 0-3297 | ||||||||||||||||||
843 | && !m_posixRule.isEmpty()
| 0-2042 | ||||||||||||||||||
844 | const int year = QDateTime::fromMSecsSinceEpoch(forMSecsSinceEpoch, Qt::UTC).date().year(); | - | ||||||||||||||||||
845 | QVector<QTimeZonePrivate::Data> posixTrans = | - | ||||||||||||||||||
846 | calculatePosixTransitions(m_posixRule, year - 1, year + 1, | - | ||||||||||||||||||
847 | m_tranTimes.last().atMSecsSinceEpoch); | - | ||||||||||||||||||
848 | for (int i = posixTrans.size() - 1; i >= 0
| 0-2059 | ||||||||||||||||||
849 | if (posixTrans.at(i).atMSecsSinceEpoch <= forMSecsSinceEpoch
| 17-2042 | ||||||||||||||||||
850 | QTimeZonePrivate::Data data = posixTrans.at(i); | - | ||||||||||||||||||
851 | data.atMSecsSinceEpoch = forMSecsSinceEpoch; | - | ||||||||||||||||||
852 | return executed 2042 times by 2 tests: data;return data; Executed by:
executed 2042 times by 2 tests: return data; Executed by:
| 2042 | ||||||||||||||||||
853 | } | - | ||||||||||||||||||
854 | } executed 17 times by 2 tests: end of block Executed by:
| 17 | ||||||||||||||||||
855 | } never executed: end of block | 0 | ||||||||||||||||||
856 | - | |||||||||||||||||||
857 | - | |||||||||||||||||||
858 | for (int i = m_tranTimes.size() - 1; i >= 0
| 3-54031 | ||||||||||||||||||
859 | if (m_tranTimes.at(i).atMSecsSinceEpoch <= forMSecsSinceEpoch
| 1252-52779 | ||||||||||||||||||
860 | Data data = dataForTzTransition(m_tranTimes.at(i)); | - | ||||||||||||||||||
861 | data.atMSecsSinceEpoch = forMSecsSinceEpoch; | - | ||||||||||||||||||
862 | return executed 1252 times by 2 tests: data;return data; Executed by:
executed 1252 times by 2 tests: return data; Executed by:
| 1252 | ||||||||||||||||||
863 | } | - | ||||||||||||||||||
864 | } executed 52779 times by 2 tests: end of block Executed by:
| 52779 | ||||||||||||||||||
865 | - | |||||||||||||||||||
866 | - | |||||||||||||||||||
867 | if (m_tranTimes.size() > 0
| 0-3 | ||||||||||||||||||
868 | Data data = dataForTzTransition(m_tranTimes.at(0)); | - | ||||||||||||||||||
869 | data.atMSecsSinceEpoch = forMSecsSinceEpoch; | - | ||||||||||||||||||
870 | return executed 3 times by 2 tests: data;return data; Executed by:
executed 3 times by 2 tests: return data; Executed by:
| 3 | ||||||||||||||||||
871 | } | - | ||||||||||||||||||
872 | - | |||||||||||||||||||
873 | - | |||||||||||||||||||
874 | return never executed: invalidData();return invalidData(); never executed: return invalidData(); | 0 | ||||||||||||||||||
875 | } | - | ||||||||||||||||||
876 | - | |||||||||||||||||||
877 | bool QTzTimeZonePrivate::hasTransitions() const | - | ||||||||||||||||||
878 | { | - | ||||||||||||||||||
879 | return executed 5705 times by 2 tests: true;return true; Executed by:
executed 5705 times by 2 tests: return true; Executed by:
| 5705 | ||||||||||||||||||
880 | } | - | ||||||||||||||||||
881 | - | |||||||||||||||||||
882 | QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSinceEpoch) const | - | ||||||||||||||||||
883 | { | - | ||||||||||||||||||
884 | - | |||||||||||||||||||
885 | if (m_tranTimes.size() > 0
| 0-8488 | ||||||||||||||||||
886 | && !m_posixRule.isEmpty()
| 0-1138 | ||||||||||||||||||
887 | const int year = QDateTime::fromMSecsSinceEpoch(afterMSecsSinceEpoch, Qt::UTC).date().year(); | - | ||||||||||||||||||
888 | QVector<QTimeZonePrivate::Data> posixTrans = | - | ||||||||||||||||||
889 | calculatePosixTransitions(m_posixRule, year - 1, year + 1, | - | ||||||||||||||||||
890 | m_tranTimes.last().atMSecsSinceEpoch); | - | ||||||||||||||||||
891 | for (int i = 0; i < posixTrans.size()
| 807-1905 | ||||||||||||||||||
892 | if (posixTrans.at(i).atMSecsSinceEpoch > afterMSecsSinceEpoch
| 313-1592 | ||||||||||||||||||
893 | return executed 313 times by 2 tests: posixTrans.at(i);return posixTrans.at(i); Executed by:
executed 313 times by 2 tests: return posixTrans.at(i); Executed by:
| 313 | ||||||||||||||||||
894 | } executed 1592 times by 2 tests: end of block Executed by:
| 1592 | ||||||||||||||||||
895 | } executed 807 times by 1 test: end of block Executed by:
| 807 | ||||||||||||||||||
896 | - | |||||||||||||||||||
897 | - | |||||||||||||||||||
898 | for (int i = 0; i < m_tranTimes.size()
| 1042-275638 | ||||||||||||||||||
899 | if (m_tranTimes.at(i).atMSecsSinceEpoch > afterMSecsSinceEpoch
| 7133-268505 | ||||||||||||||||||
900 | return executed 7133 times by 2 tests: dataForTzTransition(m_tranTimes.at(i));return dataForTzTransition(m_tranTimes.at(i)); Executed by:
executed 7133 times by 2 tests: return dataForTzTransition(m_tranTimes.at(i)); Executed by:
| 7133 | ||||||||||||||||||
901 | } | - | ||||||||||||||||||
902 | } executed 268505 times by 2 tests: end of block Executed by:
| 268505 | ||||||||||||||||||
903 | - | |||||||||||||||||||
904 | - | |||||||||||||||||||
905 | return executed 1042 times by 2 tests: invalidData();return invalidData(); Executed by:
executed 1042 times by 2 tests: return invalidData(); Executed by:
| 1042 | ||||||||||||||||||
906 | } | - | ||||||||||||||||||
907 | - | |||||||||||||||||||
908 | QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const | - | ||||||||||||||||||
909 | { | - | ||||||||||||||||||
910 | - | |||||||||||||||||||
911 | if (m_tranTimes.size() > 0
| 0-2796 | ||||||||||||||||||
912 | && !m_posixRule.isEmpty()
| 0-1355 | ||||||||||||||||||
913 | const int year = QDateTime::fromMSecsSinceEpoch(beforeMSecsSinceEpoch, Qt::UTC).date().year(); | - | ||||||||||||||||||
914 | QVector<QTimeZonePrivate::Data> posixTrans = | - | ||||||||||||||||||
915 | calculatePosixTransitions(m_posixRule, year - 1, year + 1, | - | ||||||||||||||||||
916 | m_tranTimes.last().atMSecsSinceEpoch); | - | ||||||||||||||||||
917 | for (int i = posixTrans.size() - 1; i >= 0
| 0-2450 | ||||||||||||||||||
918 | if (posixTrans.at(i).atMSecsSinceEpoch < beforeMSecsSinceEpoch
| 1095-1355 | ||||||||||||||||||
919 | return executed 1355 times by 2 tests: posixTrans.at(i);return posixTrans.at(i); Executed by:
executed 1355 times by 2 tests: return posixTrans.at(i); Executed by:
| 1355 | ||||||||||||||||||
920 | } executed 1095 times by 2 tests: end of block Executed by:
| 1095 | ||||||||||||||||||
921 | } never executed: end of block | 0 | ||||||||||||||||||
922 | - | |||||||||||||||||||
923 | - | |||||||||||||||||||
924 | for (int i = m_tranTimes.size() - 1; i >= 0
| 846-82123 | ||||||||||||||||||
925 | if (m_tranTimes.at(i).atMSecsSinceEpoch < beforeMSecsSinceEpoch
| 595-81528 | ||||||||||||||||||
926 | return executed 595 times by 2 tests: dataForTzTransition(m_tranTimes.at(i));return dataForTzTransition(m_tranTimes.at(i)); Executed by:
executed 595 times by 2 tests: return dataForTzTransition(m_tranTimes.at(i)); Executed by:
| 595 | ||||||||||||||||||
927 | } | - | ||||||||||||||||||
928 | } executed 81528 times by 2 tests: end of block Executed by:
| 81528 | ||||||||||||||||||
929 | - | |||||||||||||||||||
930 | - | |||||||||||||||||||
931 | return executed 846 times by 2 tests: invalidData();return invalidData(); Executed by:
executed 846 times by 2 tests: return invalidData(); Executed by:
| 846 | ||||||||||||||||||
932 | } | - | ||||||||||||||||||
933 | - | |||||||||||||||||||
934 | - | |||||||||||||||||||
935 | QByteArray QTzTimeZonePrivate::systemTimeZoneId() const | - | ||||||||||||||||||
936 | { | - | ||||||||||||||||||
937 | - | |||||||||||||||||||
938 | QByteArray ianaId = qgetenv("TZ"); | - | ||||||||||||||||||
939 | if (!ianaId.isEmpty()
| 0-2 | ||||||||||||||||||
940 | ianaId = ianaId.mid(1); never executed: ianaId = ianaId.mid(1); | 0 | ||||||||||||||||||
941 | - | |||||||||||||||||||
942 | - | |||||||||||||||||||
943 | - | |||||||||||||||||||
944 | - | |||||||||||||||||||
945 | - | |||||||||||||||||||
946 | if (ianaId == "/etc/localtime"
| 0-2 | ||||||||||||||||||
947 | ianaId.clear(); never executed: ianaId.clear(); | 0 | ||||||||||||||||||
948 | - | |||||||||||||||||||
949 | - | |||||||||||||||||||
950 | if (ianaId.isEmpty()
| 0-2 | ||||||||||||||||||
951 | QFile tzif(([]() -> QString { enum { Size = sizeof(u"" "/etc/timezone")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/etc/timezone" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 2 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 2 times by 1 test: }()));return qstring_literal_temp; Executed by:
| 2 | ||||||||||||||||||
952 | if (tzif.open(QIODevice::ReadOnly)
| 0-2 | ||||||||||||||||||
953 | - | |||||||||||||||||||
954 | QTextStream ts(&tzif); | - | ||||||||||||||||||
955 | if (!ts.atEnd()
| 0-2 | ||||||||||||||||||
956 | ianaId = ts.readLine().toUtf8(); executed 2 times by 1 test: ianaId = ts.readLine().toUtf8(); Executed by:
| 2 | ||||||||||||||||||
957 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
958 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
959 | - | |||||||||||||||||||
960 | - | |||||||||||||||||||
961 | if (ianaId.isEmpty()
| 0-2 | ||||||||||||||||||
962 | const QString path = QFile::symLinkTarget(([]() -> QString { enum { Size = sizeof(u"" "/etc/localtime")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/etc/localtime" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
963 | if (!path.isEmpty()
| 0 | ||||||||||||||||||
964 | - | |||||||||||||||||||
965 | int index = path.indexOf(QLatin1String("/zoneinfo/")) + 10; | - | ||||||||||||||||||
966 | ianaId = path.mid(index).toUtf8(); | - | ||||||||||||||||||
967 | } never executed: end of block | 0 | ||||||||||||||||||
968 | } never executed: end of block | 0 | ||||||||||||||||||
969 | - | |||||||||||||||||||
970 | - | |||||||||||||||||||
971 | - | |||||||||||||||||||
972 | if (ianaId.isEmpty()
| 0-2 | ||||||||||||||||||
973 | QFile tzif(([]() -> QString { enum { Size = sizeof(u"" "/etc/sysconfig/clock")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/etc/sysconfig/clock" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
974 | if (tzif.open(QIODevice::ReadOnly)
| 0 | ||||||||||||||||||
975 | - | |||||||||||||||||||
976 | QTextStream ts(&tzif); | - | ||||||||||||||||||
977 | QString line; | - | ||||||||||||||||||
978 | while (ianaId.isEmpty()
| 0 | ||||||||||||||||||
979 | line = ts.readLine(); | - | ||||||||||||||||||
980 | if (line.startsWith(QLatin1String("ZONE="))
| 0 | ||||||||||||||||||
981 | ianaId = line.mid(6, line.size() - 7).toUtf8(); | - | ||||||||||||||||||
982 | } never executed: else if (line.startsWith(QLatin1String("TIMEZONE="))end of block
| 0 | ||||||||||||||||||
983 | ianaId = line.mid(10, line.size() - 11).toUtf8(); | - | ||||||||||||||||||
984 | } never executed: end of block | 0 | ||||||||||||||||||
985 | } never executed: end of block | 0 | ||||||||||||||||||
986 | } never executed: end of block | 0 | ||||||||||||||||||
987 | } never executed: end of block | 0 | ||||||||||||||||||
988 | - | |||||||||||||||||||
989 | - | |||||||||||||||||||
990 | if (ianaId.isEmpty()
| 0-2 | ||||||||||||||||||
991 | ianaId = utcQByteArray(); never executed: ianaId = utcQByteArray(); | 0 | ||||||||||||||||||
992 | - | |||||||||||||||||||
993 | return executed 2 times by 1 test: ianaId;return ianaId; Executed by:
executed 2 times by 1 test: return ianaId; Executed by:
| 2 | ||||||||||||||||||
994 | } | - | ||||||||||||||||||
995 | - | |||||||||||||||||||
996 | QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds() const | - | ||||||||||||||||||
997 | { | - | ||||||||||||||||||
998 | QList<QByteArray> result = tzZones->keys(); | - | ||||||||||||||||||
999 | std::sort(result.begin(), result.end()); | - | ||||||||||||||||||
1000 | return executed 467 times by 1 test: result;return result; Executed by:
executed 467 times by 1 test: return result; Executed by:
| 467 | ||||||||||||||||||
1001 | } | - | ||||||||||||||||||
1002 | - | |||||||||||||||||||
1003 | QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const | - | ||||||||||||||||||
1004 | { | - | ||||||||||||||||||
1005 | - | |||||||||||||||||||
1006 | QList<QByteArray> result; | - | ||||||||||||||||||
1007 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(tzZones->keys())>::type> _container_((tzZones->keys())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QByteArray &key = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
1008 | if (tzZones->value(key).country == country
| 29-392 | ||||||||||||||||||
1009 | result << key; executed 29 times by 1 test: result << key; Executed by:
| 29 | ||||||||||||||||||
1010 | } executed 421 times by 1 test: end of block Executed by:
| 421 | ||||||||||||||||||
1011 | std::sort(result.begin(), result.end()); | - | ||||||||||||||||||
1012 | return executed 1 time by 1 test: result;return result; Executed by:
executed 1 time by 1 test: return result; Executed by:
| 1 | ||||||||||||||||||
1013 | } | - | ||||||||||||||||||
1014 | - | |||||||||||||||||||
1015 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |