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

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