OpenCoverage

qtimezoneprivate.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qtimezoneprivate.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2013 John Layt <jlayt@kde.org>-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40-
41#include "qtimezone.h"-
42#include "qtimezoneprivate_p.h"-
43#include "qtimezoneprivate_data_p.h"-
44-
45#include <qdatastream.h>-
46#include <qdebug.h>-
47-
48#include <algorithm>-
49-
50QT_BEGIN_NAMESPACE-
51-
52enum {-
53 MSECS_TRAN_WINDOW = 21600000 // 6 hour window for possible recent transitions-
54};-
55-
56/*-
57 Static utilities for looking up Windows ID tables-
58*/-
59-
60static const int windowsDataTableSize = sizeof(windowsDataTable) / sizeof(QWindowsData) - 1;-
61static const int zoneDataTableSize = sizeof(zoneDataTable) / sizeof(QZoneData) - 1;-
62static const int utcDataTableSize = sizeof(utcDataTable) / sizeof(QUtcData) - 1;-
63-
64-
65static const QZoneData *zoneData(quint16 index)-
66{-
67 Q_ASSERT(index < zoneDataTableSize);-
68 return &zoneDataTable[index];
executed 6186 times by 1 test: return &zoneDataTable[index];
Executed by:
  • tst_QTimeZone
6186
69}-
70-
71static const QWindowsData *windowsData(quint16 index)-
72{-
73 Q_ASSERT(index < windowsDataTableSize);-
74 return &windowsDataTable[index];
executed 842 times by 1 test: return &windowsDataTable[index];
Executed by:
  • tst_QTimeZone
842
75}-
76-
77static const QUtcData *utcData(quint16 index)-
78{-
79 Q_ASSERT(index < utcDataTableSize);-
80 return &utcDataTable[index];
executed 37617 times by 2 tests: return &utcDataTable[index];
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
37617
81}-
82-
83// Return the Windows ID literal for a given QWindowsData-
84static QByteArray windowsId(const QWindowsData *windowsData)-
85{-
86 return (windowsIdData + windowsData->windowsIdIndex);
executed 554 times by 1 test: return (windowsIdData + windowsData->windowsIdIndex);
Executed by:
  • tst_QTimeZone
554
87}-
88-
89// Return the IANA ID literal for a given QWindowsData-
90static QByteArray ianaId(const QWindowsData *windowsData)-
91{-
92 return (ianaIdData + windowsData->ianaIdIndex);
executed 1 time by 1 test: return (ianaIdData + windowsData->ianaIdIndex);
Executed by:
  • tst_QTimeZone
1
93}-
94-
95// Return the IANA ID literal for a given QZoneData-
96static QByteArray ianaId(const QZoneData *zoneData)-
97{-
98 return (ianaIdData + zoneData->ianaIdIndex);
executed 1692 times by 1 test: return (ianaIdData + zoneData->ianaIdIndex);
Executed by:
  • tst_QTimeZone
1692
99}-
100-
101static QByteArray utcId(const QUtcData *utcData)-
102{-
103 return (ianaIdData + utcData->ianaIdIndex);
executed 37580 times by 2 tests: return (ianaIdData + utcData->ianaIdIndex);
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
37580
104}-
105-
106static quint16 toWindowsIdKey(const QByteArray &winId)-
107{-
108 for (quint16 i = 0; i < windowsDataTableSize; ++i) {
i < windowsDataTableSizeDescription
TRUEevaluated 552 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTimeZone
3-552
109 const QWindowsData *data = windowsData(i);-
110 if (windowsId(data) == winId)
windowsId(data) == winIdDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 543 times by 1 test
Evaluated by:
  • tst_QTimeZone
9-543
111 return data->windowsIdKey;
executed 9 times by 1 test: return data->windowsIdKey;
Executed by:
  • tst_QTimeZone
9
112 }
executed 543 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
543
113 return 0;
executed 3 times by 1 test: return 0;
Executed by:
  • tst_QTimeZone
3
114}-
115-
116static QByteArray toWindowsIdLiteral(quint16 windowsIdKey)-
117{-
118 for (quint16 i = 0; i < windowsDataTableSize; ++i) {
i < windowsDataTableSizeDescription
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEnever evaluated
0-52
119 const QWindowsData *data = windowsData(i);-
120 if (data->windowsIdKey == windowsIdKey)
data->windowsI...= windowsIdKeyDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_QTimeZone
2-50
121 return windowsId(data);
executed 2 times by 1 test: return windowsId(data);
Executed by:
  • tst_QTimeZone
2
122 }
executed 50 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
50
123 return QByteArray();
never executed: return QByteArray();
0
124}-
125-
126/*-
127 Base class implementing common utility routines, only intantiate for a null tz.-
128*/-
129-
130QTimeZonePrivate::QTimeZonePrivate()-
131{-
132}-
133-
134QTimeZonePrivate::QTimeZonePrivate(const QTimeZonePrivate &other)-
135 : QSharedData(other), m_id(other.m_id)-
136{-
137}
executed 20 times by 1 test: end of block
Executed by:
  • tst_QDateTime
20
138-
139QTimeZonePrivate::~QTimeZonePrivate()-
140{-
141}-
142-
143QTimeZonePrivate *QTimeZonePrivate::clone()-
144{-
145 return new QTimeZonePrivate(*this);
never executed: return new QTimeZonePrivate(*this);
0
146}-
147-
148bool QTimeZonePrivate::operator==(const QTimeZonePrivate &other) const-
149{-
150 // TODO Too simple, but need to solve problem of comparing different derived classes-
151 // Should work for all System and ICU classes as names guaranteed unique, but not for Simple.-
152 // Perhaps once all classes have working transitions can compare full list?-
153 return (m_id == other.m_id);
executed 21 times by 2 tests: return (m_id == other.m_id);
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
21
154}-
155-
156bool QTimeZonePrivate::operator!=(const QTimeZonePrivate &other) const-
157{-
158 return !(*this == other);
executed 2 times by 1 test: return !(*this == other);
Executed by:
  • tst_QTimeZone
2
159}-
160-
161bool QTimeZonePrivate::isValid() const-
162{-
163 return !m_id.isEmpty();
executed 13410 times by 2 tests: return !m_id.isEmpty();
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
13410
164}-
165-
166QByteArray QTimeZonePrivate::id() const-
167{-
168 return m_id;
executed 470 times by 2 tests: return m_id;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
470
169}-
170-
171QLocale::Country QTimeZonePrivate::country() const-
172{-
173 // Default fall-back mode, use the zoneTable to find Region of known Zones-
174 for (int i = 0; i < zoneDataTableSize; ++i) {
i < zoneDataTableSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
175 const QZoneData *data = zoneData(i);-
176 if (ianaId(data).split(' ').contains(m_id))
ianaId(data).s...contains(m_id)Description
TRUEnever evaluated
FALSEnever evaluated
0
177 return (QLocale::Country)data->country;
never executed: return (QLocale::Country)data->country;
0
178 }
never executed: end of block
0
179 return QLocale::AnyCountry;
never executed: return QLocale::AnyCountry;
0
180}-
181-
182QString QTimeZonePrivate::comment() const-
183{-
184 return QString();
never executed: return QString();
0
185}-
186-
187QString QTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,-
188 QTimeZone::NameType nameType,-
189 const QLocale &locale) const-
190{-
191 if (nameType == QTimeZone::OffsetName)
nameType == QT...ne::OffsetNameDescription
TRUEnever evaluated
FALSEevaluated 451 times by 1 test
Evaluated by:
  • tst_QTimeZone
0-451
192 return isoOffsetFormat(offsetFromUtc(atMSecsSinceEpoch));
never executed: return isoOffsetFormat(offsetFromUtc(atMSecsSinceEpoch));
0
193-
194 if (isDaylightTime(atMSecsSinceEpoch))
isDaylightTime...ecsSinceEpoch)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 430 times by 1 test
Evaluated by:
  • tst_QTimeZone
21-430
195 return displayName(QTimeZone::DaylightTime, nameType, locale);
executed 21 times by 1 test: return displayName(QTimeZone::DaylightTime, nameType, locale);
Executed by:
  • tst_QTimeZone
21
196 else-
197 return displayName(QTimeZone::StandardTime, nameType, locale);
executed 430 times by 1 test: return displayName(QTimeZone::StandardTime, nameType, locale);
Executed by:
  • tst_QTimeZone
430
198}-
199-
200QString QTimeZonePrivate::displayName(QTimeZone::TimeType timeType,-
201 QTimeZone::NameType nameType,-
202 const QLocale &locale) const-
203{-
204 Q_UNUSED(timeType)-
205 Q_UNUSED(nameType)-
206 Q_UNUSED(locale)-
207 return QString();
never executed: return QString();
0
208}-
209-
210QString QTimeZonePrivate::abbreviation(qint64 atMSecsSinceEpoch) const-
211{-
212 Q_UNUSED(atMSecsSinceEpoch)-
213 return QString();
never executed: return QString();
0
214}-
215-
216int QTimeZonePrivate::offsetFromUtc(qint64 atMSecsSinceEpoch) const-
217{-
218 return standardTimeOffset(atMSecsSinceEpoch) + daylightTimeOffset(atMSecsSinceEpoch);
executed 45 times by 1 test: return standardTimeOffset(atMSecsSinceEpoch) + daylightTimeOffset(atMSecsSinceEpoch);
Executed by:
  • tst_QTimeZone
45
219}-
220-
221int QTimeZonePrivate::standardTimeOffset(qint64 atMSecsSinceEpoch) const-
222{-
223 Q_UNUSED(atMSecsSinceEpoch)-
224 return invalidSeconds();
never executed: return invalidSeconds();
0
225}-
226-
227int QTimeZonePrivate::daylightTimeOffset(qint64 atMSecsSinceEpoch) const-
228{-
229 Q_UNUSED(atMSecsSinceEpoch)-
230 return invalidSeconds();
never executed: return invalidSeconds();
0
231}-
232-
233bool QTimeZonePrivate::hasDaylightTime() const-
234{-
235 return false;
executed 207 times by 2 tests: return false;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
207
236}-
237-
238bool QTimeZonePrivate::isDaylightTime(qint64 atMSecsSinceEpoch) const-
239{-
240 Q_UNUSED(atMSecsSinceEpoch)-
241 return false;
executed 41 times by 2 tests: return false;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
41
242}-
243-
244QTimeZonePrivate::Data QTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const-
245{-
246 Q_UNUSED(forMSecsSinceEpoch)-
247 return invalidData();
never executed: return invalidData();
0
248}-
249-
250// Private only method for use by QDateTime to convert local msecs to epoch msecs-
251// TODO Could be platform optimised if needed-
252QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs) const-
253{-
254 if (!hasDaylightTime() ||!hasTransitions()) {
!hasDaylightTime()Description
TRUEevaluated 347 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 646 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
!hasTransitions()Description
TRUEnever evaluated
FALSEevaluated 646 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
0-646
255 // No DST means same offset for all local msecs-
256 // Having DST but no transitions means we can't calculate, so use nearest-
257 return data(forLocalMSecs - (standardTimeOffset(forLocalMSecs) * 1000));
executed 347 times by 2 tests: return data(forLocalMSecs - (standardTimeOffset(forLocalMSecs) * 1000));
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
347
258 }-
259-
260 // Get the transition for the local msecs which most of the time should be the right one-
261 // Only around the transition times might it not be the right one-
262 Data tran = previousTransition(forLocalMSecs);-
263 Data nextTran;-
264-
265 // If the local msecs is less than the real local time of the transition-
266 // then get the previous transition to use instead-
267 if (forLocalMSecs < tran.atMSecsSinceEpoch + (tran.offsetFromUtc * 1000)) {
forLocalMSecs ...romUtc * 1000)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 641 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
5-641
268 while (tran.atMSecsSinceEpoch != invalidMSecs()
tran.atMSecsSi...invalidMSecs()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEnever evaluated
0-10
269 && forLocalMSecs < tran.atMSecsSinceEpoch + (tran.offsetFromUtc * 1000)) {
forLocalMSecs ...romUtc * 1000)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QDateTime
5
270 nextTran = tran;-
271 tran = previousTransition(tran.atMSecsSinceEpoch);-
272 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QDateTime
5
273 } else {
executed 5 times by 1 test: end of block
Executed by:
  • tst_QDateTime
5
274 // The zone msecs is after the transition, so check it is before the next tran-
275 // If not try use the next transition instead-
276 nextTran = nextTransition(tran.atMSecsSinceEpoch);-
277 while (nextTran.atMSecsSinceEpoch != invalidMSecs()
nextTran.atMSe...invalidMSecs()Description
TRUEevaluated 6111 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 249 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
249-6111
278 && forLocalMSecs >= nextTran.atMSecsSinceEpoch + (nextTran.offsetFromUtc * 1000)) {
forLocalMSecs ...romUtc * 1000)Description
TRUEevaluated 5719 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 392 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
392-5719
279 tran = nextTran;-
280 nextTran = nextTransition(tran.atMSecsSinceEpoch);-
281 }
executed 5719 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
5719
282 }
executed 641 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
641
283-
284 if (tran.daylightTimeOffset == 0) {
tran.daylightTimeOffset == 0Description
TRUEevaluated 587 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 59 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
59-587
285 // If tran is in StandardTime, then need to check if falls close to either DST transition.-
286 // If it does, then it may need adjusting for missing hour or for second occurrence-
287 qint64 diffPrevTran = forLocalMSecs-
288 - (tran.atMSecsSinceEpoch + (tran.offsetFromUtc * 1000));-
289 qint64 diffNextTran = nextTran.atMSecsSinceEpoch + (nextTran.offsetFromUtc * 1000)-
290 - forLocalMSecs;-
291 if (diffPrevTran >= 0 && diffPrevTran < MSECS_TRAN_WINDOW) {
diffPrevTran >= 0Description
TRUEevaluated 587 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEnever evaluated
diffPrevTran <...CS_TRAN_WINDOWDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 572 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
0-587
292 // If tran picked is for standard time check if changed from DST in last 6 hours,-
293 // as the local msecs may be ambiguous and represent two valid utc msecs.-
294 // If in last 6 hours then get prev tran and if diff falls within the DST offset-
295 // then use the prev tran as we default to the FirstOccurrence-
296 // TODO Check if faster to just always get prev tran, or if faster using 6 hour check.-
297 Data dstTran = previousTransition(tran.atMSecsSinceEpoch);-
298 if (dstTran.atMSecsSinceEpoch != invalidMSecs()
dstTran.atMSec...invalidMSecs()Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEnever evaluated
0-15
299 && dstTran.daylightTimeOffset > 0 && diffPrevTran < (dstTran.daylightTimeOffset * 1000))
dstTran.daylightTimeOffset > 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEnever evaluated
diffPrevTran <...Offset * 1000)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDateTime
0-15
300 tran = dstTran;
executed 12 times by 1 test: tran = dstTran;
Executed by:
  • tst_QDateTime
12
301 } else if (diffNextTran >= 0 && diffNextTran <= (nextTran.daylightTimeOffset * 1000)) {
executed 15 times by 1 test: end of block
Executed by:
  • tst_QDateTime
diffNextTran >= 0Description
TRUEevaluated 572 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEnever evaluated
diffNextTran <...Offset * 1000)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 570 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
0-572
302 // If time falls within last hour of standard time then is actually the missing hour-
303 // So return the next tran instead and adjust the local time to be valid-
304 tran = nextTran;-
305 forLocalMSecs = forLocalMSecs + (nextTran.daylightTimeOffset * 1000);-
306 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QDateTime
2
307 }
executed 587 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
587
308-
309 // tran should now hold the right transition offset to use-
310 tran.atMSecsSinceEpoch = forLocalMSecs - (tran.offsetFromUtc * 1000);-
311 return tran;
executed 646 times by 2 tests: return tran;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
646
312}-
313-
314bool QTimeZonePrivate::hasTransitions() const-
315{-
316 return false;
executed 481 times by 1 test: return false;
Executed by:
  • tst_QTimeZone
481
317}-
318-
319QTimeZonePrivate::Data QTimeZonePrivate::nextTransition(qint64 afterMSecsSinceEpoch) const-
320{-
321 Q_UNUSED(afterMSecsSinceEpoch)-
322 return invalidData();
never executed: return invalidData();
0
323}-
324-
325QTimeZonePrivate::Data QTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const-
326{-
327 Q_UNUSED(beforeMSecsSinceEpoch)-
328 return invalidData();
never executed: return invalidData();
0
329}-
330-
331QTimeZonePrivate::DataList QTimeZonePrivate::transitions(qint64 fromMSecsSinceEpoch,-
332 qint64 toMSecsSinceEpoch) const-
333{-
334 DataList list;-
335 if (toMSecsSinceEpoch >= fromMSecsSinceEpoch) {
toMSecsSinceEp...SecsSinceEpochDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEnever evaluated
0-2
336 // fromMSecsSinceEpoch is inclusive but nextTransitionTime() is exclusive so go back 1 msec-
337 Data next = nextTransition(fromMSecsSinceEpoch - 1);-
338 while (next.atMSecsSinceEpoch != invalidMSecs()
next.atMSecsSi...invalidMSecs()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEnever evaluated
0-6
339 && next.atMSecsSinceEpoch <= toMSecsSinceEpoch) {
next.atMSecsSi...SecsSinceEpochDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTimeZone
2-4
340 list.append(next);-
341 next = nextTransition(next.atMSecsSinceEpoch);-
342 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
4
343 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
2
344 return list;
executed 2 times by 1 test: return list;
Executed by:
  • tst_QTimeZone
2
345}-
346-
347QByteArray QTimeZonePrivate::systemTimeZoneId() const-
348{-
349 return QByteArray();
never executed: return QByteArray();
0
350}-
351-
352QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds() const-
353{-
354 return QList<QByteArray>();
never executed: return QList<QByteArray>();
0
355}-
356-
357QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const-
358{-
359 // Default fall-back mode, use the zoneTable to find Region of know Zones-
360 QList<QByteArray> regions;-
361-
362 // First get all Zones in the Zones table belonging to the Region-
363 for (int i = 0; i < zoneDataTableSize; ++i) {
i < zoneDataTableSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
364 if (zoneData(i)->country == country)
zoneData(i)->c...try == countryDescription
TRUEnever evaluated
FALSEnever evaluated
0
365 regions += ianaId(zoneData(i)).split(' ');
never executed: regions += ianaId(zoneData(i)).split(' ');
0
366 }
never executed: end of block
0
367-
368 std::sort(regions.begin(), regions.end());-
369 regions.erase(std::unique(regions.begin(), regions.end()), regions.end());-
370-
371 // Then select just those that are available-
372 const QList<QByteArray> all = availableTimeZoneIds();-
373 QList<QByteArray> result;-
374 result.reserve(qMin(all.size(), regions.size()));-
375 std::set_intersection(all.begin(), all.end(), regions.cbegin(), regions.cend(),-
376 std::back_inserter(result));-
377 return result;
never executed: return result;
0
378}-
379-
380QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(int offsetFromUtc) const-
381{-
382 // Default fall-back mode, use the zoneTable to find Offset of know Zones-
383 QList<QByteArray> offsets;-
384 // First get all Zones in the table using the Offset-
385 for (int i = 0; i < windowsDataTableSize; ++i) {
i < windowsDataTableSizeDescription
TRUEevaluated 106 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
1-106
386 const QWindowsData *winData = windowsData(i);-
387 if (winData->offsetFromUtc == offsetFromUtc) {
winData->offse... offsetFromUtcDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 102 times by 1 test
Evaluated by:
  • tst_QTimeZone
4-102
388 for (int j = 0; j < zoneDataTableSize; ++j) {
j < zoneDataTableSizeDescription
TRUEevaluated 1376 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTimeZone
4-1376
389 const QZoneData *data = zoneData(j);-
390 if (data->windowsIdKey == winData->windowsIdKey)
data->windowsI...->windowsIdKeyDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1349 times by 1 test
Evaluated by:
  • tst_QTimeZone
27-1349
391 offsets += ianaId(data).split(' ');
executed 27 times by 1 test: offsets += ianaId(data).split(' ');
Executed by:
  • tst_QTimeZone
27
392 }
executed 1376 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
1376
393 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
4
394 }
executed 106 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
106
395-
396 std::sort(offsets.begin(), offsets.end());-
397 offsets.erase(std::unique(offsets.begin(), offsets.end()), offsets.end());-
398-
399 // Then select just those that are available-
400 const QList<QByteArray> all = availableTimeZoneIds();-
401 QList<QByteArray> result;-
402 result.reserve(qMin(all.size(), offsets.size()));-
403 std::set_intersection(all.begin(), all.end(), offsets.cbegin(), offsets.cend(),-
404 std::back_inserter(result));-
405 return result;
executed 1 time by 1 test: return result;
Executed by:
  • tst_QTimeZone
1
406}-
407-
408#ifndef QT_NO_DATASTREAM-
409void QTimeZonePrivate::serialize(QDataStream &ds) const-
410{-
411 ds << QString::fromUtf8(m_id);-
412}
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
2
413#endif // QT_NO_DATASTREAM-
414-
415// Static Utility Methods-
416-
417QTimeZonePrivate::Data QTimeZonePrivate::invalidData()-
418{-
419 Data data;-
420 data.atMSecsSinceEpoch = invalidMSecs();-
421 data.offsetFromUtc = invalidSeconds();-
422 data.standardTimeOffset = invalidSeconds();-
423 data.daylightTimeOffset = invalidSeconds();-
424 return data;
executed 1890 times by 2 tests: return data;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
1890
425}-
426-
427QTimeZone::OffsetData QTimeZonePrivate::invalidOffsetData()-
428{-
429 QTimeZone::OffsetData offsetData;-
430 offsetData.atUtc = QDateTime();-
431 offsetData.offsetFromUtc = invalidSeconds();-
432 offsetData.standardTimeOffset = invalidSeconds();-
433 offsetData.daylightTimeOffset = invalidSeconds();-
434 return offsetData;
executed 5080 times by 1 test: return offsetData;
Executed by:
  • tst_QTimeZone
5080
435}-
436-
437QTimeZone::OffsetData QTimeZonePrivate::toOffsetData(const QTimeZonePrivate::Data &data)-
438{-
439 QTimeZone::OffsetData offsetData = invalidOffsetData();-
440 if (data.atMSecsSinceEpoch != invalidMSecs()) {
data.atMSecsSi...invalidMSecs()Description
TRUEevaluated 3011 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1626 times by 1 test
Evaluated by:
  • tst_QTimeZone
1626-3011
441 offsetData.atUtc = QDateTime::fromMSecsSinceEpoch(data.atMSecsSinceEpoch, Qt::UTC);-
442 offsetData.offsetFromUtc = data.offsetFromUtc;-
443 offsetData.standardTimeOffset = data.standardTimeOffset;-
444 offsetData.daylightTimeOffset = data.daylightTimeOffset;-
445 offsetData.abbreviation = data.abbreviation;-
446 }
executed 3011 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
3011
447 return offsetData;
executed 4637 times by 1 test: return offsetData;
Executed by:
  • tst_QTimeZone
4637
448}-
449-
450// Is the format of the ID valid ?-
451bool QTimeZonePrivate::isValidId(const QByteArray &ianaId)-
452{-
453 /*-
454 Main rules for defining TZ/IANA names as per ftp://ftp.iana.org/tz/code/Theory-
455 1. Use only valid POSIX file name components-
456 2. Within a file name component, use only ASCII letters, `.', `-' and `_'.-
457 3. Do not use digits (except in a [+-]\d+ suffix, when used).-
458 4. A file name component must not exceed 14 characters or start with `-'-
459 However, the rules are really guidelines - a later one says-
460 - Do not change established names if they only marginally violate the-
461 above rules.-
462 We may, therefore, need to be a bit slack in our check here, if we hit-
463 legitimate exceptions in real time-zone databases.-
464-
465 In particular, aliases such as "Etc/GMT+7" and "SystemV/EST5EDT" are valid-
466 so we need to accept digits, ':', and '+'; aliases typically have the form-
467 of POSIX TZ strings, which allow a suffix to a proper IANA name. A POSIX-
468 suffix starts with an offset (as in GMT+7) and may continue with another-
469 name (as in EST5EDT, giving the DST name of the zone); a further offset is-
470 allowed (for DST). The ("hard to describe and [...] error-prone in-
471 practice") POSIX form even allows a suffix giving the dates (and-
472 optionally times) of the annual DST transitions. Hopefully, no TZ aliases-
473 go that far, but we at least need to accept an offset and (single-
474 fragment) DST-name.-
475-
476 But for the legacy complications, the following would be preferable if-
477 QRegExp would work on QByteArrays directly:-
478 const QRegExp rx(QStringLiteral("[a-z+._][a-z+._-]{,13}"-
479 "(?:/[a-z+._][a-z+._-]{,13})*"-
480 // Optional suffix:-
481 "(?:[+-]?\d{1,2}(?::\d{1,2}){,2}" // offset-
482 // one name fragment (DST):-
483 "(?:[a-z+._][a-z+._-]{,13})?)"),-
484 Qt::CaseInsensitive);-
485 return rx.exactMatch(ianaId);-
486 */-
487-
488 // Somewhat slack hand-rolled version:-
489 const int MinSectionLength = 1;-
490 const int MaxSectionLength = 14;-
491 int sectionLength = 0;-
492 for (const char *it = ianaId.begin(), * const end = ianaId.end(); it != end; ++it, ++sectionLength) {
it != endDescription
TRUEevaluated 7709 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 518 times by 1 test
Evaluated by:
  • tst_QTimeZone
518-7709
493 const char ch = *it;-
494 if (ch == '/') {
ch == '/'Description
TRUEevaluated 578 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 7131 times by 1 test
Evaluated by:
  • tst_QTimeZone
578-7131
495 if (sectionLength < MinSectionLength || sectionLength > MaxSectionLength)
sectionLength ...nSectionLengthDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 575 times by 1 test
Evaluated by:
  • tst_QTimeZone
sectionLength ...xSectionLengthDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 572 times by 1 test
Evaluated by:
  • tst_QTimeZone
3-575
496 return false; // violates (4)
executed 6 times by 1 test: return false;
Executed by:
  • tst_QTimeZone
6
497 sectionLength = -1;-
498 } else if (ch == '-') {
executed 572 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
ch == '-'Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 7101 times by 1 test
Evaluated by:
  • tst_QTimeZone
30-7101
499 if (sectionLength == 0)
sectionLength == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_QTimeZone
4-26
500 return false; // violates (4)
executed 4 times by 1 test: return false;
Executed by:
  • tst_QTimeZone
4
501 } else if (!(ch >= 'a' && ch <= 'z')
executed 26 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
ch >= 'a'Description
TRUEevaluated 5499 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1602 times by 1 test
Evaluated by:
  • tst_QTimeZone
ch <= 'z'Description
TRUEevaluated 5499 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEnever evaluated
0-5499
502 && !(ch >= 'A' && ch <= 'Z')
ch >= 'A'Description
TRUEevaluated 1143 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 459 times by 1 test
Evaluated by:
  • tst_QTimeZone
ch <= 'Z'Description
TRUEevaluated 1071 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 72 times by 1 test
Evaluated by:
  • tst_QTimeZone
72-1143
503 && !(ch == '_')
!(ch == '_')Description
TRUEevaluated 463 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 68 times by 1 test
Evaluated by:
  • tst_QTimeZone
68-463
504 && !(ch == '.')
!(ch == '.')Description
TRUEevaluated 458 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QTimeZone
5-458
505 // Should ideally check these only happen as an offset:-
506 && !(ch >= '0' && ch <= '9')
ch >= '0'Description
TRUEevaluated 404 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 54 times by 1 test
Evaluated by:
  • tst_QTimeZone
ch <= '9'Description
TRUEevaluated 352 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 52 times by 1 test
Evaluated by:
  • tst_QTimeZone
52-404
507 && !(ch == '+')
!(ch == '+')Description
TRUEevaluated 81 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 25 times by 1 test
Evaluated by:
  • tst_QTimeZone
25-81
508 && !(ch == ':')) {
!(ch == ':')Description
TRUEevaluated 39 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_QTimeZone
39-42
509 return false; // violates (2)
executed 39 times by 1 test: return false;
Executed by:
  • tst_QTimeZone
39
510 }-
511 }
executed 7660 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
7660
512 if (sectionLength < MinSectionLength || sectionLength > MaxSectionLength)
sectionLength ...nSectionLengthDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 517 times by 1 test
Evaluated by:
  • tst_QTimeZone
sectionLength ...xSectionLengthDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 514 times by 1 test
Evaluated by:
  • tst_QTimeZone
1-517
513 return false; // violates (4)
executed 4 times by 1 test: return false;
Executed by:
  • tst_QTimeZone
4
514 return true;
executed 514 times by 1 test: return true;
Executed by:
  • tst_QTimeZone
514
515}-
516-
517QString QTimeZonePrivate::isoOffsetFormat(int offsetFromUtc)-
518{-
519 const int mins = offsetFromUtc / 60;-
520 return QString::fromUtf8("UTC%1%2:%3").arg(mins >= 0 ? QLatin1Char('+') : QLatin1Char('-'))
executed 7 times by 2 tests: return QString::fromUtf8("UTC%1%2:%3").arg(mins >= 0 ? QLatin1Char('+') : QLatin1Char('-')) .arg(qAbs(mins) / 60, 2, 10, QLatin1Char('0')) .arg(qAbs(mins) % 60, 2, 10, QLatin1Char('0'));
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
7
521 .arg(qAbs(mins) / 60, 2, 10, QLatin1Char('0'))
executed 7 times by 2 tests: return QString::fromUtf8("UTC%1%2:%3").arg(mins >= 0 ? QLatin1Char('+') : QLatin1Char('-')) .arg(qAbs(mins) / 60, 2, 10, QLatin1Char('0')) .arg(qAbs(mins) % 60, 2, 10, QLatin1Char('0'));
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
7
522 .arg(qAbs(mins) % 60, 2, 10, QLatin1Char('0'));
executed 7 times by 2 tests: return QString::fromUtf8("UTC%1%2:%3").arg(mins >= 0 ? QLatin1Char('+') : QLatin1Char('-')) .arg(qAbs(mins) / 60, 2, 10, QLatin1Char('0')) .arg(qAbs(mins) % 60, 2, 10, QLatin1Char('0'));
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
7
523}-
524-
525QByteArray QTimeZonePrivate::ianaIdToWindowsId(const QByteArray &id)-
526{-
527 for (int i = 0; i < zoneDataTableSize; ++i) {
i < zoneDataTableSizeDescription
TRUEevaluated 1655 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTimeZone
3-1655
528 const QZoneData *data = zoneData(i);-
529 if (ianaId(data).split(' ').contains(id))
ianaId(data).s...).contains(id)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1653 times by 1 test
Evaluated by:
  • tst_QTimeZone
2-1653
530 return toWindowsIdLiteral(data->windowsIdKey);
executed 2 times by 1 test: return toWindowsIdLiteral(data->windowsIdKey);
Executed by:
  • tst_QTimeZone
2
531 }
executed 1653 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
1653
532 return QByteArray();
executed 3 times by 1 test: return QByteArray();
Executed by:
  • tst_QTimeZone
3
533}-
534-
535QByteArray QTimeZonePrivate::windowsIdToDefaultIanaId(const QByteArray &windowsId)-
536{-
537 const quint16 windowsIdKey = toWindowsIdKey(windowsId);-
538 for (int i = 0; i < windowsDataTableSize; ++i) {
i < windowsDataTableSizeDescription
TRUEevaluated 132 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
1-132
539 const QWindowsData *data = windowsData(i);-
540 if (data->windowsIdKey == windowsIdKey)
data->windowsI...= windowsIdKeyDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 131 times by 1 test
Evaluated by:
  • tst_QTimeZone
1-131
541 return ianaId(data);
executed 1 time by 1 test: return ianaId(data);
Executed by:
  • tst_QTimeZone
1
542 }
executed 131 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
131
543 return QByteArray();
executed 1 time by 1 test: return QByteArray();
Executed by:
  • tst_QTimeZone
1
544}-
545-
546QByteArray QTimeZonePrivate::windowsIdToDefaultIanaId(const QByteArray &windowsId,-
547 QLocale::Country country)-
548{-
549 const QList<QByteArray> list = windowsIdToIanaIds(windowsId, country);-
550 if (list.count() > 0)
list.count() > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEnever evaluated
0-2
551 return list.first();
executed 2 times by 1 test: return list.first();
Executed by:
  • tst_QTimeZone
2
552 else-
553 return QByteArray();
never executed: return QByteArray();
0
554}-
555-
556QList<QByteArray> QTimeZonePrivate::windowsIdToIanaIds(const QByteArray &windowsId)-
557{-
558 const quint16 windowsIdKey = toWindowsIdKey(windowsId);-
559 QList<QByteArray> list;-
560-
561 for (int i = 0; i < zoneDataTableSize; ++i) {
i < zoneDataTableSizeDescription
TRUEevaluated 688 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTimeZone
2-688
562 const QZoneData *data = zoneData(i);-
563 if (data->windowsIdKey == windowsIdKey)
data->windowsI...= windowsIdKeyDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 684 times by 1 test
Evaluated by:
  • tst_QTimeZone
4-684
564 list << ianaId(data).split(' ');
executed 4 times by 1 test: list << ianaId(data).split(' ');
Executed by:
  • tst_QTimeZone
4
565 }
executed 688 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
688
566-
567 // Return the full list in alpha order-
568 std::sort(list.begin(), list.end());-
569 return list;
executed 2 times by 1 test: return list;
Executed by:
  • tst_QTimeZone
2
570}-
571-
572QList<QByteArray> QTimeZonePrivate::windowsIdToIanaIds(const QByteArray &windowsId,-
573 QLocale::Country country)-
574{-
575 const quint16 windowsIdKey = toWindowsIdKey(windowsId);-
576 for (int i = 0; i < zoneDataTableSize; ++i) {
i < zoneDataTableSizeDescription
TRUEevaluated 2467 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTimeZone
2-2467
577 const QZoneData *data = zoneData(i);-
578 // Return the region matches in preference order-
579 if (data->windowsIdKey == windowsIdKey && data->country == (quint16) country)
data->windowsI...= windowsIdKeyDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 2450 times by 1 test
Evaluated by:
  • tst_QTimeZone
data->country ...int16) countryDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QTimeZone
6-2450
580 return ianaId(data).split(' ');
executed 6 times by 1 test: return ianaId(data).split(' ');
Executed by:
  • tst_QTimeZone
6
581 }
executed 2461 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
2461
582-
583 return QList<QByteArray>();
executed 2 times by 1 test: return QList<QByteArray>();
Executed by:
  • tst_QTimeZone
2
584}-
585-
586// Define template for derived classes to reimplement so QSharedDataPointer clone() works correctly-
587template<> QTimeZonePrivate *QSharedDataPointer<QTimeZonePrivate>::clone()-
588{-
589 return d->clone();
executed 20 times by 1 test: return d->clone();
Executed by:
  • tst_QDateTime
20
590}-
591-
592/*-
593 UTC Offset implementation, used when QT_NO_SYSTEMLOCALE set and QT_USE_ICU not set,-
594 or for QDateTimes with a Qt:Spec of Qt::OffsetFromUtc.-
595*/-
596-
597// Create default UTC time zone-
598QUtcTimeZonePrivate::QUtcTimeZonePrivate()-
599{-
600 const QString name = utcQString();-
601 init(utcQByteArray(), 0, name, name, QLocale::AnyCountry, name);-
602}
executed 470 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
470
603-
604// Create a named UTC time zone-
605QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QByteArray &id)-
606{-
607 // Look for the name in the UTC list, if found set the values-
608 for (int i = 0; i < utcDataTableSize; ++i) {
i < utcDataTableSizeDescription
TRUEevaluated 18897 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 450 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
450-18897
609 const QUtcData *data = utcData(i);-
610 const QByteArray uid = utcId(data);-
611 if (uid == id) {
uid == idDescription
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 18851 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
46-18851
612 QString name = QString::fromUtf8(id);-
613 init(id, data->offsetFromUtc, name, name, QLocale::AnyCountry, name);-
614 break;
executed 46 times by 1 test: break;
Executed by:
  • tst_QTimeZone
46
615 }-
616 }
executed 18851 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
18851
617}
executed 496 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
496
618-
619// Create offset from UTC-
620QUtcTimeZonePrivate::QUtcTimeZonePrivate(qint32 offsetSeconds)-
621{-
622 QString utcId;-
623-
624 if (offsetSeconds == 0)
offsetSeconds == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
0-7
625 utcId = utcQString();
never executed: utcId = utcQString();
0
626 else-
627 utcId = isoOffsetFormat(offsetSeconds);
executed 7 times by 2 tests: utcId = isoOffsetFormat(offsetSeconds);
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
7
628-
629 init(utcId.toUtf8(), offsetSeconds, utcId, utcId, QLocale::AnyCountry, utcId);-
630}
executed 7 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
7
631-
632QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QByteArray &zoneId, int offsetSeconds,-
633 const QString &name, const QString &abbreviation,-
634 QLocale::Country country, const QString &comment)-
635{-
636 init(zoneId, offsetSeconds, name, abbreviation, country, comment);-
637}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
3
638-
639QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QUtcTimeZonePrivate &other)-
640 : QTimeZonePrivate(other), m_name(other.m_name),-
641 m_abbreviation(other.m_abbreviation),-
642 m_comment(other.m_comment),-
643 m_country(other.m_country),-
644 m_offsetFromUtc(other.m_offsetFromUtc)-
645{-
646}
never executed: end of block
0
647-
648QUtcTimeZonePrivate::~QUtcTimeZonePrivate()-
649{-
650}-
651-
652QTimeZonePrivate *QUtcTimeZonePrivate::clone()-
653{-
654 return new QUtcTimeZonePrivate(*this);
never executed: return new QUtcTimeZonePrivate(*this);
0
655}-
656-
657QTimeZonePrivate::Data QUtcTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const-
658{-
659 Data d;-
660 d.abbreviation = m_abbreviation;-
661 d.atMSecsSinceEpoch = forMSecsSinceEpoch;-
662 d.standardTimeOffset = d.offsetFromUtc = m_offsetFromUtc;-
663 d.daylightTimeOffset = 0;-
664 return d;
executed 85 times by 2 tests: return d;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
85
665}-
666-
667void QUtcTimeZonePrivate::init(const QByteArray &zoneId)-
668{-
669 m_id = zoneId;-
670}
never executed: end of block
0
671-
672void QUtcTimeZonePrivate::init(const QByteArray &zoneId, int offsetSeconds, const QString &name,-
673 const QString &abbreviation, QLocale::Country country,-
674 const QString &comment)-
675{-
676 m_id = zoneId;-
677 m_offsetFromUtc = offsetSeconds;-
678 m_name = name;-
679 m_abbreviation = abbreviation;-
680 m_country = country;-
681 m_comment = comment;-
682}
executed 526 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
526
683-
684QLocale::Country QUtcTimeZonePrivate::country() const-
685{-
686 return m_country;
executed 43 times by 1 test: return m_country;
Executed by:
  • tst_QTimeZone
43
687}-
688-
689QString QUtcTimeZonePrivate::comment() const-
690{-
691 return m_comment;
executed 42 times by 1 test: return m_comment;
Executed by:
  • tst_QTimeZone
42
692}-
693-
694QString QUtcTimeZonePrivate::displayName(QTimeZone::TimeType timeType,-
695 QTimeZone::NameType nameType,-
696 const QLocale &locale) const-
697{-
698 Q_UNUSED(timeType)-
699 Q_UNUSED(locale)-
700 if (nameType == QTimeZone::ShortName)
nameType == QT...one::ShortNameDescription
TRUEnever evaluated
FALSEevaluated 124 times by 1 test
Evaluated by:
  • tst_QTimeZone
0-124
701 return m_abbreviation;
never executed: return m_abbreviation;
0
702 else if (nameType == QTimeZone::OffsetName)
nameType == QT...ne::OffsetNameDescription
TRUEnever evaluated
FALSEevaluated 124 times by 1 test
Evaluated by:
  • tst_QTimeZone
0-124
703 return isoOffsetFormat(m_offsetFromUtc);
never executed: return isoOffsetFormat(m_offsetFromUtc);
0
704 return m_name;
executed 124 times by 1 test: return m_name;
Executed by:
  • tst_QTimeZone
124
705}-
706-
707QString QUtcTimeZonePrivate::abbreviation(qint64 atMSecsSinceEpoch) const-
708{-
709 Q_UNUSED(atMSecsSinceEpoch)-
710 return m_abbreviation;
executed 83 times by 1 test: return m_abbreviation;
Executed by:
  • tst_QTimeZone
83
711}-
712-
713qint32 QUtcTimeZonePrivate::standardTimeOffset(qint64 atMSecsSinceEpoch) const-
714{-
715 Q_UNUSED(atMSecsSinceEpoch)-
716 return m_offsetFromUtc;
executed 172 times by 2 tests: return m_offsetFromUtc;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
172
717}-
718-
719qint32 QUtcTimeZonePrivate::daylightTimeOffset(qint64 atMSecsSinceEpoch) const-
720{-
721 Q_UNUSED(atMSecsSinceEpoch)-
722 return 0;
executed 46 times by 1 test: return 0;
Executed by:
  • tst_QTimeZone
46
723}-
724-
725QByteArray QUtcTimeZonePrivate::systemTimeZoneId() const-
726{-
727 return utcQByteArray();
never executed: return utcQByteArray();
0
728}-
729-
730QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds() const-
731{-
732 QList<QByteArray> result;-
733 result.reserve(utcDataTableSize);-
734 for (int i = 0; i < utcDataTableSize; ++i)
i < utcDataTableSizeDescription
TRUEevaluated 18680 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 467 times by 1 test
Evaluated by:
  • tst_QTimeZone
467-18680
735 result << utcId(utcData(i));
executed 18680 times by 1 test: result << utcId(utcData(i));
Executed by:
  • tst_QTimeZone
18680
736 std::sort(result.begin(), result.end()); // ### or already sorted??-
737 // ### assuming no duplicates-
738 return result;
executed 467 times by 1 test: return result;
Executed by:
  • tst_QTimeZone
467
739}-
740-
741QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const-
742{-
743 // If AnyCountry then is request for all non-region offset codes-
744 if (country == QLocale::AnyCountry)
country == QLocale::AnyCountryDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
0-1
745 return availableTimeZoneIds();
never executed: return availableTimeZoneIds();
0
746 return QList<QByteArray>();
executed 1 time by 1 test: return QList<QByteArray>();
Executed by:
  • tst_QTimeZone
1
747}-
748-
749QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds(qint32 offsetSeconds) const-
750{-
751 QList<QByteArray> result;-
752 for (int i = 0; i < utcDataTableSize; ++i) {
i < utcDataTableSizeDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
1-40
753 const QUtcData *data = utcData(i);-
754 if (data->offsetFromUtc == offsetSeconds)
data->offsetFr... offsetSecondsDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 37 times by 1 test
Evaluated by:
  • tst_QTimeZone
3-37
755 result << utcId(data);
executed 3 times by 1 test: result << utcId(data);
Executed by:
  • tst_QTimeZone
3
756 }
executed 40 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
40
757 std::sort(result.begin(), result.end()); // ### or already sorted??-
758 // ### assuming no duplicates-
759 return result;
executed 1 time by 1 test: return result;
Executed by:
  • tst_QTimeZone
1
760}-
761-
762#ifndef QT_NO_DATASTREAM-
763void QUtcTimeZonePrivate::serialize(QDataStream &ds) const-
764{-
765 ds << QStringLiteral("OffsetFromUtc") << QString::fromUtf8(m_id) << m_offsetFromUtc << m_name
executed 1 time by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QTimeZone
1
766 << m_abbreviation << (qint32) m_country << m_comment;-
767}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QTimeZone
1
768#endif // QT_NO_DATASTREAM-
769-
770QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9