qtimezone.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qtimezone.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-
44#include <QtCore/qdatastream.h>-
45#include <QtCore/qdatetime.h>-
46-
47#include <qdebug.h>-
48-
49#include <algorithm>-
50-
51QT_BEGIN_NAMESPACE-
52-
53// Create default time zone using appropriate backend-
54static QTimeZonePrivate *newBackendTimeZone()-
55{-
56#ifdef QT_NO_SYSTEMLOCALE-
57#ifdef QT_USE_ICU-
58 return new QIcuTimeZonePrivate();-
59#else-
60 return new QUtcTimeZonePrivate();-
61#endif // QT_USE_ICU-
62#else-
63#if defined Q_OS_MAC-
64 return new QMacTimeZonePrivate();-
65#elif defined Q_OS_ANDROID-
66 return new QAndroidTimeZonePrivate();-
67#elif defined Q_OS_UNIX-
68 return new QTzTimeZonePrivate();
executed 1 time by 1 test: return new QTzTimeZonePrivate();
Executed by:
  • tst_QTimeZone
1
69 // Registry based timezone backend not available on WinRT-
70#elif defined Q_OS_WIN-
71 return new QWinTimeZonePrivate();-
72#elif defined QT_USE_ICU-
73 return new QIcuTimeZonePrivate();-
74#else-
75 return new QUtcTimeZonePrivate();-
76#endif // System Locales-
77#endif // QT_NO_SYSTEMLOCALE-
78}-
79-
80// Create named time zone using appropriate backend-
81static QTimeZonePrivate *newBackendTimeZone(const QByteArray &ianaId)-
82{-
83#ifdef QT_NO_SYSTEMLOCALE-
84#ifdef QT_USE_ICU-
85 return new QIcuTimeZonePrivate(ianaId);-
86#else-
87 return new QUtcTimeZonePrivate(ianaId);-
88#endif // QT_USE_ICU-
89#else-
90#if defined Q_OS_MAC-
91 return new QMacTimeZonePrivate(ianaId);-
92#elif defined Q_OS_ANDROID-
93 return new QAndroidTimeZonePrivate(ianaId);-
94#elif defined Q_OS_UNIX-
95 return new QTzTimeZonePrivate(ianaId);
executed 450 times by 2 tests: return new QTzTimeZonePrivate(ianaId);
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
450
96 // Registry based timezone backend not available on WinRT-
97#elif defined Q_OS_WIN-
98 return new QWinTimeZonePrivate(ianaId);-
99#elif defined QT_USE_ICU-
100 return new QIcuTimeZonePrivate(ianaId);-
101#else-
102 return new QUtcTimeZonePrivate(ianaId);-
103#endif // System Locales-
104#endif // QT_NO_SYSTEMLOCALE-
105}-
106-
107class QTimeZoneSingleton-
108{-
109public:-
110 QTimeZoneSingleton() : backend(newBackendTimeZone()) {}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QTimeZone
1
111-
112 // The backend_tz is the tz to use in static methods such as availableTimeZoneIds() and-
113 // isTimeZoneIdAvailable() and to create named IANA time zones. This is usually the host-
114 // system, but may be different if the host resources are insufficient or if-
115 // QT_NO_SYSTEMLOCALE is set. A simple UTC backend is used if no alternative is available.-
116 QSharedDataPointer<QTimeZonePrivate> backend;-
117};-
118-
119Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz);
executed 1 time by 1 test: end of block
Executed by:
  • tst_qtimezone - unknown status
executed 1 time by 1 test: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qtimezone - unknown status
executed 469 times by 1 test: return &holder.value;
Executed by:
  • tst_QTimeZone
guard.load() =...c::InitializedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qtimezone - unknown status
FALSEnever evaluated
0-469
120-
121/*!-
122 \class QTimeZone-
123 \inmodule QtCore-
124 \since 5.2-
125-
126 \brief The QTimeZone class converts between UTC and local time in a specific-
127 time zone.-
128-
129 \threadsafe-
130-
131 This class provides a stateless calculator for time zone conversions-
132 between UTC and the local time in a specific time zone. By default it uses-
133 the host system time zone data to perform these conversions.-
134-
135 This class is primarily designed for use in QDateTime; most applications-
136 will not need to access this class directly and should instead use-
137 QDateTime with a Qt::TimeSpec of Qt::TimeZone.-
138-
139 \note For consistency with QDateTime, QTimeZone does not account for leap-
140 seconds.-
141-
142 \section1-
143-
144 \section2 IANA Time Zone IDs-
145-
146 QTimeZone uses the IANA time zone IDs as defined in the IANA Time Zone-
147 Database (http://www.iana.org/time-zones). This is to ensure a standard ID-
148 across all supported platforms. Most platforms support the IANA IDs-
149 and the IANA Database natively, but for Windows a mapping is required to-
150 the native IDs. See below for more details.-
151-
152 The IANA IDs can and do change on a regular basis, and can vary depending-
153 on how recently the host system data was updated. As such you cannot rely-
154 on any given ID existing on any host system. You must use-
155 availableTimeZoneIds() to determine what IANA IDs are available.-
156-
157 The IANA IDs and database are also know as the Olson IDs and database,-
158 named after their creator.-
159-
160 \section2 UTC Offset Time Zones-
161-
162 A default UTC time zone backend is provided which is always guaranteed to-
163 be available. This provides a set of generic Offset From UTC time zones-
164 in the range UTC-14:00 to UTC+14:00. These time zones can be created-
165 using either the standard ISO format names "UTC+00:00" as listed by-
166 availableTimeZoneIds(), or using the number of offset seconds.-
167-
168 \section2 Windows Time Zones-
169-
170 Windows native time zone support is severely limited compared to the-
171 standard IANA TZ Database. Windows time zones cover larger geographic-
172 areas and are thus less accurate in their conversions. They also do not-
173 support as much historic conversion data and so may only be accurate for-
174 the current year.-
175-
176 QTimeZone uses a conversion table derived form the Unicode CLDR data to map-
177 between IANA IDs and Windows IDs. Depending on your version of Windows-
178 and Qt, this table may not be able to provide a valid conversion, in which-
179 "UTC" will be returned.-
180-
181 QTimeZone provides a public API to use this conversion table. The Windows ID-
182 used is the Windows Registry Key for the time zone which is also the MS-
183 Exchange EWS ID as well, but is different to the Time Zone Name (TZID) and-
184 COD code used by MS Exchange in versions before 2007.-
185-
186 \section2 System Time Zone-
187-
188 QTimeZone does not support any concept of a system or default time zone.-
189 If you require a QDateTime that uses the current system time zone at any-
190 given moment then you should use a Qt::TimeSpec of Qt::LocalTime.-
191-
192 The method systemTimeZoneId() returns the current system IANA time zone-
193 ID which on Unix-like systems will always be correct. On Windows this ID is-
194 translated from the Windows system ID using an internal translation-
195 table and the user's selected country. As a consequence there is a small-
196 chance any Windows install may have IDs not known by Qt, in which case-
197 "UTC" will be returned.-
198-
199 Creating a new QTimeZone instance using the system time zone ID will only-
200 produce a fixed named copy of the time zone, it will not change if the-
201 system time zone changes.-
202-
203 \section2 Time Zone Offsets-
204-
205 The difference between UTC and the local time in a time zone is expressed-
206 as an offset in seconds from UTC, i.e. the number of seconds to add to UTC-
207 to obtain the local time. The total offset is comprised of two component-
208 parts, the standard time offset and the daylight-saving time offset. The-
209 standard time offset is the number of seconds to add to UTC to obtain-
210 standard time in the time zone. The daylight-saving time offset is the-
211 number of seconds to add to the standard time offset to obtain-
212 daylight-saving time (abbreviated DST and sometimes called "daylight time"-
213 or "summer time") in the time zone.-
214-
215 Note that the standard and DST offsets for a time zone may change over time-
216 as countries have changed DST laws or even their standard time offset.-
217-
218 \section2 License-
219-
220 This class includes data obtained from the CLDR data files under the terms-
221 of the Unicode license.-
222-
223 \legalese-
224 COPYRIGHT AND PERMISSION NOTICE-
225-
226 Copyright © 1991-2012 Unicode, Inc. All rights reserved. Distributed under-
227 the Terms of Use in http://www.unicode.org/copyright.html.-
228-
229 Permission is hereby granted, free of charge, to any person obtaining a-
230 copy of the Unicode data files and any associated documentation (the "Data-
231 Files") or Unicode software and any associated documentation (the "Software")-
232 to deal in the Data Files or Software without restriction, including without-
233 limitation the rights to use, copy, modify, merge, publish, distribute, and/or-
234 sell copies of the Data Files or Software, and to permit persons to whom the-
235 Data Files or Software are furnished to do so, provided that (a) the above-
236 copyright notice(s) and this permission notice appear with all copies of the-
237 Data Files or Software, (b) both the above copyright notice(s) and this-
238 permission notice appear in associated documentation, and (c) there is clear-
239 notice in each modified Data File or in the Software as well as in the-
240 documentation associated with the Data File(s) or Software that the data or-
241 software has been modified.-
242 \endlegalese-
243-
244 \sa QDateTime-
245*/-
246-
247/*!-
248 \enum QTimeZone::TimeType-
249-
250 The type of time zone time, for example when requesting the name. In time-
251 zones that do not apply DST, all three values may return the same result.-
252-
253 \value StandardTime-
254 The standard time in a time zone, i.e. when Daylight-Saving is not-
255 in effect.-
256 For example when formatting a display name this will show something-
257 like "Pacific Standard Time".-
258 \value DaylightTime-
259 A time when Daylight-Saving is in effect.-
260 For example when formatting a display name this will show something-
261 like "Pacific daylight-saving time".-
262 \value GenericTime-
263 A time which is not specifically Standard or Daylight-Saving time,-
264 either an unknown time or a neutral form.-
265 For example when formatting a display name this will show something-
266 like "Pacific Time".-
267*/-
268-
269/*!-
270 \enum QTimeZone::NameType-
271-
272 The type of time zone name.-
273-
274 \value DefaultName-
275 The default form of the time zone name, e.g. LongName, ShortName or OffsetName-
276 \value LongName-
277 The long form of the time zone name, e.g. "Central European Time"-
278 \value ShortName-
279 The short form of the time zone name, usually an abbreviation, e.g. "CET"-
280 \value OffsetName-
281 The standard ISO offset form of the time zone name, e.g. "UTC+01:00"-
282*/-
283-
284/*!-
285 \class QTimeZone::OffsetData-
286 \inmodule QtCore-
287-
288 The time zone offset data for a given moment in time, i.e. the time zone-
289 offsets and abbreviation to use at that moment in time.-
290-
291 \list-
292 \li OffsetData::atUtc The datetime of the offset data in UTC time.-
293 \li OffsetData::offsetFromUtc The total offset from UTC in effect at the datetime.-
294 \li OffsetData::standardTimeOffset The standard time offset component of the total offset.-
295 \li OffsetData::daylightTimeOffset The DST offset component of the total offset.-
296 \li OffsetData::abbreviation The abbreviation in effect at the datetime.-
297 \endlist-
298-
299 For example, for time zone "Europe/Berlin" the OffsetDate in standard and DST might be:-
300-
301 \list-
302 \li atUtc = QDateTime(QDate(2013, 1, 1), QTime(0, 0, 0), Qt::UTC)-
303 \li offsetFromUtc = 3600-
304 \li standardTimeOffset = 3600-
305 \li daylightTimeOffset = 0-
306 \li abbreviation = "CET"-
307 \endlist-
308-
309 \list-
310 \li atUtc = QDateTime(QDate(2013, 6, 1), QTime(0, 0, 0), Qt::UTC)-
311 \li offsetFromUtc = 7200-
312 \li standardTimeOffset = 3600-
313 \li daylightTimeOffset = 3600-
314 \li abbreviation = "CEST"-
315 \endlist-
316*/-
317-
318/*!-
319 \typedef QTimeZone::OffsetDataList-
320-
321 Synonym for QVector<OffsetData>.-
322*/-
323-
324/*!-
325 Create a null/invalid time zone instance.-
326*/-
327-
328QTimeZone::QTimeZone() Q_DECL_NOTHROW-
329 : d(0)-
330{-
331}
executed 7098826 times by 128 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDBusMetaType
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • ...
7098826
332-
333/*!-
334 Creates an instance of the requested time zone \a ianaId.-
335-
336 The ID must be one of the available system IDs otherwise an invalid-
337 time zone will be returned.-
338-
339 \sa availableTimeZoneIds()-
340*/-
341-
342QTimeZone::QTimeZone(const QByteArray &ianaId)-
343{-
344 // Try and see if it's a valid UTC offset ID, just as quick to try create as look-up-
345 d = new QUtcTimeZonePrivate(ianaId);-
346 // If not a valid UTC offset ID then try create it with the system backend-
347 // Relies on backend not creating valid tz with invalid name-
348 if (!d->isValid())
!d->isValid()Description
TRUEevaluated 450 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 44 times by 1 test
Evaluated by:
  • tst_QTimeZone
44-450
349 d = newBackendTimeZone(ianaId);
executed 450 times by 2 tests: d = newBackendTimeZone(ianaId);
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
450
350}
executed 494 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
494
351-
352/*!-
353 Creates an instance of a time zone with the requested Offset from UTC of-
354 \a offsetSeconds.-
355-
356 The \a offsetSeconds from UTC must be in the range -14 hours to +14 hours-
357 otherwise an invalid time zone will be returned.-
358*/-
359-
360QTimeZone::QTimeZone(int offsetSeconds)-
361{-
362 // offsetSeconds must fall between -14:00 and +14:00 hours-
363 if (offsetSeconds >= -50400 && offsetSeconds <= 50400)
offsetSeconds >= -50400Description
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
offsetSeconds <= 50400Description
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
1-8
364 d = new QUtcTimeZonePrivate(offsetSeconds);
executed 7 times by 2 tests: d = new QUtcTimeZonePrivate(offsetSeconds);
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
7
365 else-
366 d = 0;
executed 2 times by 1 test: d = 0;
Executed by:
  • tst_QTimeZone
2
367}-
368-
369/*!-
370 Creates a custom time zone with an ID of \a ianaId and an offset from UTC-
371 of \a offsetSeconds. The \a name will be the name used by displayName()-
372 for the LongName, the \a abbreviation will be used by displayName() for the-
373 ShortName and by abbreviation(), and the optional \a country will be used-
374 by country(). The \a comment is an optional note that may be displayed in-
375 a GUI to assist users in selecting a time zone.-
376-
377 The \a ianaId must not be one of the available system IDs returned by-
378 availableTimeZoneIds(). The \a offsetSeconds from UTC must be in the range-
379 -14 hours to +14 hours.-
380-
381 If the custom time zone does not have a specific country then set it to the-
382 default value of QLocale::AnyCountry.-
383*/-
384-
385QTimeZone::QTimeZone(const QByteArray &ianaId, int offsetSeconds, const QString &name,-
386 const QString &abbreviation, QLocale::Country country, const QString &comment)-
387 : d()-
388{-
389 if (!isTimeZoneIdAvailable(ianaId))
!isTimeZoneIdAvailable(ianaId)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEnever evaluated
0-3
390 d = new QUtcTimeZonePrivate(ianaId, offsetSeconds, name, abbreviation, country, comment);
executed 3 times by 1 test: d = new QUtcTimeZonePrivate(ianaId, offsetSeconds, name, abbreviation, country, comment);
Executed by:
  • tst_QTimeZone
3
391}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QTimeZone
3
392-
393/*!-
394 \internal-
395-
396 Private. Create time zone with given private backend-
397*/-
398-
399QTimeZone::QTimeZone(QTimeZonePrivate &dd)-
400 : d(&dd)-
401{-
402}
never executed: end of block
0
403-
404/*!-
405 Copy constructor, copy \a other to this.-
406*/-
407-
408QTimeZone::QTimeZone(const QTimeZone &other)-
409 : d(other.d)-
410{-
411}
executed 7013235 times by 103 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • tst_QFile
  • tst_QFileDialog2
  • ...
7013235
412-
413/*!-
414 Destroys the time zone.-
415*/-
416-
417QTimeZone::~QTimeZone()-
418{-
419}-
420-
421/*!-
422 \fn QTimeZone::swap(QTimeZone &other)-
423-
424 Swaps this time zone instance with \a other. This function is very-
425 fast and never fails.-
426*/-
427-
428/*!-
429 Assignment operator, assign \a other to this.-
430*/-
431-
432QTimeZone &QTimeZone::operator=(const QTimeZone &other)-
433{-
434 d = other.d;-
435 return *this;
executed 485 times by 2 tests: return *this;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
485
436}-
437-
438/*-
439 \fn void QTimeZone::swap(QTimeZone &other)-
440-
441 Swaps this timezone with \a other. This function is very fast and-
442 never fails.-
443*/-
444-
445/*!-
446 \fn QTimeZone &QTimeZone::operator=(QTimeZone &&other)-
447-
448 Move-assigns \a other to this QTimeZone instance, transferring the-
449 ownership of the managed pointer to this instance.-
450*/-
451-
452/*!-
453 Returns \c true if this time zone is equal to the \a other time zone.-
454*/-
455-
456bool QTimeZone::operator==(const QTimeZone &other) const-
457{-
458 if (d && other.d)-
459 return (*d == *other.d);
executed 19 times by 2 tests: return (*d == *other.d);
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
19
460 else-
461 return (d == other.d);
executed 2 times by 1 test: return (d == other.d);
Executed by:
  • tst_QTimeZone
2
462}-
463-
464/*!-
465 Returns \c true if this time zone is not equal to the \a other time zone.-
466*/-
467-
468bool QTimeZone::operator!=(const QTimeZone &other) const-
469{-
470 if (d && other.d)-
471 return (*d != *other.d);
executed 2 times by 1 test: return (*d != *other.d);
Executed by:
  • tst_QTimeZone
2
472 else-
473 return (d != other.d);
executed 2 times by 1 test: return (d != other.d);
Executed by:
  • tst_QTimeZone
2
474}-
475-
476/*!-
477 Returns \c true if this time zone is valid.-
478*/-
479-
480bool QTimeZone::isValid() const-
481{-
482 if (d)
dDescription
TRUEevaluated 11641 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 23 times by 1 test
Evaluated by:
  • tst_QTimeZone
23-11641
483 return d->isValid();
executed 11641 times by 2 tests: return d->isValid();
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
11641
484 else-
485 return false;
executed 23 times by 1 test: return false;
Executed by:
  • tst_QTimeZone
23
486}-
487-
488/*!-
489 Returns the IANA ID for the time zone.-
490-
491 IANA IDs are used on all platforms. On Windows these are translated-
492 from the Windows ID into the closest IANA ID for the time zone and country.-
493*/-
494-
495QByteArray QTimeZone::id() const-
496{-
497 if (d)
dDescription
TRUEevaluated 469 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
1-469
498 return d->id();
executed 469 times by 2 tests: return d->id();
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
469
499 else-
500 return QByteArray();
executed 1 time by 1 test: return QByteArray();
Executed by:
  • tst_QTimeZone
1
501}-
502-
503/*!-
504 Returns the country for the time zone.-
505*/-
506-
507QLocale::Country QTimeZone::country() const-
508{-
509 if (isValid())
isValid()Description
TRUEevaluated 464 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
1-464
510 return d->country();
executed 464 times by 1 test: return d->country();
Executed by:
  • tst_QTimeZone
464
511 else-
512 return QLocale::AnyCountry;
executed 1 time by 1 test: return QLocale::AnyCountry;
Executed by:
  • tst_QTimeZone
1
513}-
514-
515/*!-
516 Returns any comment for the time zone.-
517-
518 A comment may be provided by the host platform to assist users in-
519 choosing the correct time zone. Depending on the platform this may not-
520 be localized.-
521*/-
522-
523QString QTimeZone::comment() const-
524{-
525 if (isValid())
isValid()Description
TRUEevaluated 463 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
1-463
526 return d->comment();
executed 463 times by 1 test: return d->comment();
Executed by:
  • tst_QTimeZone
463
527 else-
528 return QString();
executed 1 time by 1 test: return QString();
Executed by:
  • tst_QTimeZone
1
529}-
530-
531/*!-
532 Returns the localized time zone display name at the given \a atDateTime-
533 for the given \a nameType in the given \a locale. The \a nameType and-
534 \a locale requested may not be supported on all platforms, in which case-
535 the best available option will be returned.-
536-
537 If the \a locale is not provided then the application default locale will-
538 be used.-
539-
540 The display name may change depending on DST or historical events.-
541-
542 \sa abbreviation()-
543*/-
544-
545QString QTimeZone::displayName(const QDateTime &atDateTime, NameType nameType,-
546 const QLocale &locale) const-
547{-
548 if (isValid())
isValid()Description
TRUEevaluated 461 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
1-461
549 return d->displayName(atDateTime.toMSecsSinceEpoch(), nameType, locale);
executed 461 times by 1 test: return d->displayName(atDateTime.toMSecsSinceEpoch(), nameType, locale);
Executed by:
  • tst_QTimeZone
461
550 else-
551 return QString();
executed 1 time by 1 test: return QString();
Executed by:
  • tst_QTimeZone
1
552}-
553-
554/*!-
555 Returns the localized time zone display name for the given \a timeType-
556 and \a nameType in the given \a locale. The \a nameType and \a locale-
557 requested may not be supported on all platforms, in which case the best-
558 available option will be returned.-
559-
560 If the \a locale is not provided then the application default locale will-
561 be used.-
562-
563 Where the time zone display names have changed over time then the most-
564 recent names will be used.-
565-
566 \sa abbreviation()-
567*/-
568-
569QString QTimeZone::displayName(TimeType timeType, NameType nameType,-
570 const QLocale &locale) const-
571{-
572 if (isValid())
isValid()Description
TRUEevaluated 925 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
1-925
573 return d->displayName(timeType, nameType, locale);
executed 925 times by 1 test: return d->displayName(timeType, nameType, locale);
Executed by:
  • tst_QTimeZone
925
574 else-
575 return QString();
executed 1 time by 1 test: return QString();
Executed by:
  • tst_QTimeZone
1
576}-
577-
578/*!-
579 Returns the time zone abbreviation at the given \a atDateTime. The-
580 abbreviation may change depending on DST or even historical events.-
581-
582 Note that the abbreviation is not guaranteed to be unique to this time zone-
583 and should not be used in place of the ID or display name.-
584-
585 \sa displayName()-
586*/-
587-
588QString QTimeZone::abbreviation(const QDateTime &atDateTime) const-
589{-
590 if (isValid())
isValid()Description
TRUEevaluated 463 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
1-463
591 return d->abbreviation(atDateTime.toMSecsSinceEpoch());
executed 463 times by 1 test: return d->abbreviation(atDateTime.toMSecsSinceEpoch());
Executed by:
  • tst_QTimeZone
463
592 else-
593 return QString();
executed 1 time by 1 test: return QString();
Executed by:
  • tst_QTimeZone
1
594}-
595-
596/*!-
597 Returns the total effective offset at the given \a atDateTime, i.e. the-
598 number of seconds to add to UTC to obtain the local time. This includes-
599 any DST offset that may be in effect, i.e. it is the sum of-
600 standardTimeOffset() and daylightTimeOffset() for the given datetime.-
601-
602 For example, for the time zone "Europe/Berlin" the standard time offset is-
603 +3600 seconds and the DST offset is +3600 seconds. During standard time-
604 offsetFromUtc() will return +3600 (UTC+01:00), and during DST it will-
605 return +7200 (UTC+02:00).-
606-
607 \sa standardTimeOffset(), daylightTimeOffset()-
608*/-
609-
610int QTimeZone::offsetFromUtc(const QDateTime &atDateTime) const-
611{-
612 if (isValid())
isValid()Description
TRUEevaluated 467 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTimeZone
2-467
613 return d->offsetFromUtc(atDateTime.toMSecsSinceEpoch());
executed 467 times by 1 test: return d->offsetFromUtc(atDateTime.toMSecsSinceEpoch());
Executed by:
  • tst_QTimeZone
467
614 else-
615 return 0;
executed 2 times by 1 test: return 0;
Executed by:
  • tst_QTimeZone
2
616}-
617-
618/*!-
619 Returns the standard time offset at the given \a atDateTime, i.e. the-
620 number of seconds to add to UTC to obtain the local Standard Time. This-
621 excludes any DST offset that may be in effect.-
622-
623 For example, for the time zone "Europe/Berlin" the standard time offset is-
624 +3600 seconds. During both standard and DST offsetFromUtc() will return-
625 +3600 (UTC+01:00).-
626-
627 \sa offsetFromUtc(), daylightTimeOffset()-
628*/-
629-
630int QTimeZone::standardTimeOffset(const QDateTime &atDateTime) const-
631{-
632 if (isValid())
isValid()Description
TRUEevaluated 466 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTimeZone
2-466
633 return d->standardTimeOffset(atDateTime.toMSecsSinceEpoch());
executed 466 times by 1 test: return d->standardTimeOffset(atDateTime.toMSecsSinceEpoch());
Executed by:
  • tst_QTimeZone
466
634 else-
635 return 0;
executed 2 times by 1 test: return 0;
Executed by:
  • tst_QTimeZone
2
636}-
637-
638/*!-
639 Returns the daylight-saving time offset at the given \a atDateTime,-
640 i.e. the number of seconds to add to the standard time offset to obtain the-
641 local daylight-saving time.-
642-
643 For example, for the time zone "Europe/Berlin" the DST offset is +3600-
644 seconds. During standard time daylightTimeOffset() will return 0, and when-
645 daylight-saving is in effect it will return +3600.-
646-
647 \sa offsetFromUtc(), standardTimeOffset()-
648*/-
649-
650int QTimeZone::daylightTimeOffset(const QDateTime &atDateTime) const-
651{-
652 if (hasDaylightTime())
hasDaylightTime()Description
TRUEevaluated 291 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 177 times by 1 test
Evaluated by:
  • tst_QTimeZone
177-291
653 return d->daylightTimeOffset(atDateTime.toMSecsSinceEpoch());
executed 291 times by 1 test: return d->daylightTimeOffset(atDateTime.toMSecsSinceEpoch());
Executed by:
  • tst_QTimeZone
291
654 else-
655 return 0;
executed 177 times by 1 test: return 0;
Executed by:
  • tst_QTimeZone
177
656}-
657-
658/*!-
659 Returns \c true if the time zone has practiced daylight-saving at any time.-
660-
661 \sa isDaylightTime(), daylightTimeOffset()-
662*/-
663-
664bool QTimeZone::hasDaylightTime() const-
665{-
666 if (isValid())
isValid()Description
TRUEevaluated 1391 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QTimeZone
5-1391
667 return d->hasDaylightTime();
executed 1391 times by 1 test: return d->hasDaylightTime();
Executed by:
  • tst_QTimeZone
1391
668 else-
669 return false;
executed 5 times by 1 test: return false;
Executed by:
  • tst_QTimeZone
5
670}-
671-
672/*!-
673 Returns \c true if daylight-saving was in effect at the given \a atDateTime.-
674-
675 \sa hasDaylightTime(), daylightTimeOffset()-
676*/-
677-
678bool QTimeZone::isDaylightTime(const QDateTime &atDateTime) const-
679{-
680 if (hasDaylightTime())
hasDaylightTime()Description
TRUEevaluated 291 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 174 times by 1 test
Evaluated by:
  • tst_QTimeZone
174-291
681 return d->isDaylightTime(atDateTime.toMSecsSinceEpoch());
executed 291 times by 1 test: return d->isDaylightTime(atDateTime.toMSecsSinceEpoch());
Executed by:
  • tst_QTimeZone
291
682 else-
683 return false;
executed 174 times by 1 test: return false;
Executed by:
  • tst_QTimeZone
174
684}-
685-
686/*!-
687 Returns the effective offset details at the given \a forDateTime. This is-
688 the equivalent of calling offsetFromUtc(), abbreviation(), etc individually but is-
689 more efficient.-
690-
691 \sa offsetFromUtc(), standardTimeOffset(), daylightTimeOffset(), abbreviation()-
692*/-
693-
694QTimeZone::OffsetData QTimeZone::offsetData(const QDateTime &forDateTime) const-
695{-
696 if (hasTransitions())
hasTransitions()Description
TRUEevaluated 421 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 41 times by 1 test
Evaluated by:
  • tst_QTimeZone
41-421
697 return d->toOffsetData(d->data(forDateTime.toMSecsSinceEpoch()));
executed 421 times by 1 test: return d->toOffsetData(d->data(forDateTime.toMSecsSinceEpoch()));
Executed by:
  • tst_QTimeZone
421
698 else-
699 return d->invalidOffsetData();
executed 41 times by 1 test: return d->invalidOffsetData();
Executed by:
  • tst_QTimeZone
41
700}-
701-
702/*!-
703 Returns \c true if the system backend supports obtaining transitions.-
704-
705 Transitions are changes in the time-zone: these happen when DST turns on or-
706 off and when authorities alter the offsets for the time-zone.-
707-
708 \sa nextTransition(), previousTransition(), transitions()-
709*/-
710-
711bool QTimeZone::hasTransitions() const-
712{-
713 if (isValid())
isValid()Description
TRUEevaluated 5538 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTimeZone
4-5538
714 return d->hasTransitions();
executed 5538 times by 1 test: return d->hasTransitions();
Executed by:
  • tst_QTimeZone
5538
715 else-
716 return false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_QTimeZone
4
717}-
718-
719/*!-
720 Returns the first time zone Transition after the given \a afterDateTime.-
721 This is most useful when you have a Transition time and wish to find the-
722 Transition after it.-
723-
724 If there is no transition after the given \a afterDateTime then an invalid-
725 OffsetData will be returned with an invalid QDateTime.-
726-
727 The given \a afterDateTime is exclusive.-
728-
729 \sa hasTransitions(), previousTransition(), transitions()-
730*/-
731-
732QTimeZone::OffsetData QTimeZone::nextTransition(const QDateTime &afterDateTime) const-
733{-
734 if (hasTransitions())
hasTransitions()Description
TRUEevaluated 2107 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 201 times by 1 test
Evaluated by:
  • tst_QTimeZone
201-2107
735 return d->toOffsetData(d->nextTransition(afterDateTime.toMSecsSinceEpoch()));
executed 2107 times by 1 test: return d->toOffsetData(d->nextTransition(afterDateTime.toMSecsSinceEpoch()));
Executed by:
  • tst_QTimeZone
2107
736 else-
737 return d->invalidOffsetData();
executed 201 times by 1 test: return d->invalidOffsetData();
Executed by:
  • tst_QTimeZone
201
738}-
739-
740/*!-
741 Returns the first time zone Transition before the given \a beforeDateTime.-
742 This is most useful when you have a Transition time and wish to find the-
743 Transition before it.-
744-
745 If there is no transition before the given \a beforeDateTime then an invalid-
746 OffsetData will be returned with an invalid QDateTime.-
747-
748 The given \a beforeDateTime is exclusive.-
749-
750 \sa hasTransitions(), nextTransition(), transitions()-
751*/-
752-
753QTimeZone::OffsetData QTimeZone::previousTransition(const QDateTime &beforeDateTime) const-
754{-
755 if (hasTransitions())
hasTransitions()Description
TRUEevaluated 2107 times by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 201 times by 1 test
Evaluated by:
  • tst_QTimeZone
201-2107
756 return d->toOffsetData(d->previousTransition(beforeDateTime.toMSecsSinceEpoch()));
executed 2107 times by 1 test: return d->toOffsetData(d->previousTransition(beforeDateTime.toMSecsSinceEpoch()));
Executed by:
  • tst_QTimeZone
2107
757 else-
758 return d->invalidOffsetData();
executed 201 times by 1 test: return d->invalidOffsetData();
Executed by:
  • tst_QTimeZone
201
759}-
760-
761/*!-
762 Returns a list of all time zone transitions between the given datetimes.-
763-
764 The given \a fromDateTime and \a toDateTime are inclusive.-
765-
766 \sa hasTransitions(), nextTransition(), previousTransition()-
767*/-
768-
769QTimeZone::OffsetDataList QTimeZone::transitions(const QDateTime &fromDateTime,-
770 const QDateTime &toDateTime) const-
771{-
772 OffsetDataList list;-
773 if (hasTransitions()) {
hasTransitions()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEnever evaluated
0-1
774 const QTimeZonePrivate::DataList plist = d->transitions(fromDateTime.toMSecsSinceEpoch(),-
775 toDateTime.toMSecsSinceEpoch());-
776 list.reserve(plist.count());-
777 for (const QTimeZonePrivate::Data &pdata : plist)-
778 list.append(d->toOffsetData(pdata));
executed 2 times by 1 test: list.append(d->toOffsetData(pdata));
Executed by:
  • tst_QTimeZone
2
779 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QTimeZone
1
780 return list;
executed 1 time by 1 test: return list;
Executed by:
  • tst_QTimeZone
1
781}-
782-
783// Static methods-
784-
785/*!-
786 Returns the current system time zone IANA ID.-
787-
788 On Windows this ID is translated from the Windows ID using an internal-
789 translation table and the user's selected country. As a consequence there-
790 is a small chance any Windows install may have IDs not known by Qt, in-
791 which case "UTC" will be returned.-
792*/-
793-
794QByteArray QTimeZone::systemTimeZoneId()-
795{-
796 return global_tz->backend->systemTimeZoneId();
never executed: return global_tz->backend->systemTimeZoneId();
0
797}-
798-
799/*!-
800 \since 5.5-
801 Returns a QTimeZone object that refers to the local system time, as-
802 specified by systemTimeZoneId().-
803-
804 \sa utc()-
805*/-
806QTimeZone QTimeZone::systemTimeZone()-
807{-
808 return QTimeZone(QTimeZone::systemTimeZoneId());
never executed: return QTimeZone(QTimeZone::systemTimeZoneId());
0
809}-
810-
811/*!-
812 \since 5.5-
813 Returns a QTimeZone object that refers to UTC (Universal Time Coordinated).-
814-
815 \sa systemTimeZone()-
816*/-
817QTimeZone QTimeZone::utc()-
818{-
819 return QTimeZone(QTimeZonePrivate::utcQByteArray());
never executed: return QTimeZone(QTimeZonePrivate::utcQByteArray());
0
820}-
821-
822/*!-
823 Returns \c true if a given time zone \a ianaId is available on this system.-
824-
825 \sa availableTimeZoneIds()-
826*/-
827-
828bool QTimeZone::isTimeZoneIdAvailable(const QByteArray &ianaId)-
829{-
830 // isValidId is not strictly required, but faster to weed out invalid-
831 // IDs as availableTimeZoneIds() may be slow-
832 if (!QTimeZonePrivate::isValidId(ianaId))
!QTimeZonePriv...alidId(ianaId)Description
TRUEnever evaluated
FALSEevaluated 464 times by 1 test
Evaluated by:
  • tst_QTimeZone
0-464
833 return false;
never executed: return false;
0
834 const QList<QByteArray> tzIds = availableTimeZoneIds();-
835 return std::binary_search(tzIds.begin(), tzIds.end(), ianaId);
executed 464 times by 1 test: return std::binary_search(tzIds.begin(), tzIds.end(), ianaId);
Executed by:
  • tst_QTimeZone
464
836}-
837-
838static QList<QByteArray> set_union(const QList<QByteArray> &l1, const QList<QByteArray> &l2)-
839{-
840 QList<QByteArray> result;-
841 result.reserve(l1.size() + l2.size());-
842 std::set_union(l1.begin(), l1.end(),-
843 l2.begin(), l2.end(),-
844 std::back_inserter(result));-
845 return result;
executed 469 times by 1 test: return result;
Executed by:
  • tst_QTimeZone
469
846}-
847-
848/*!-
849 Returns a list of all available IANA time zone IDs on this system.-
850-
851 \sa isTimeZoneIdAvailable()-
852*/-
853-
854QList<QByteArray> QTimeZone::availableTimeZoneIds()-
855{-
856 return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(),
executed 467 times by 1 test: return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(), global_tz->backend->availableTimeZoneIds());
Executed by:
  • tst_QTimeZone
467
857 global_tz->backend->availableTimeZoneIds());
executed 467 times by 1 test: return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(), global_tz->backend->availableTimeZoneIds());
Executed by:
  • tst_QTimeZone
467
858}-
859-
860/*!-
861 Returns a list of all available IANA time zone IDs for a given \a country.-
862-
863 As a special case, a \a country of Qt::AnyCountry returns those time zones-
864 that do not have any country related to them, such as UTC. If you require-
865 a list of all time zone IDs for all countries then use the standard-
866 availableTimeZoneIds() method.-
867-
868 \sa isTimeZoneIdAvailable()-
869*/-
870-
871QList<QByteArray> QTimeZone::availableTimeZoneIds(QLocale::Country country)-
872{-
873 return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(country),
executed 1 time by 1 test: return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(country), global_tz->backend->availableTimeZoneIds(country));
Executed by:
  • tst_QTimeZone
1
874 global_tz->backend->availableTimeZoneIds(country));
executed 1 time by 1 test: return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(country), global_tz->backend->availableTimeZoneIds(country));
Executed by:
  • tst_QTimeZone
1
875}-
876-
877/*!-
878 Returns a list of all available IANA time zone IDs with a given standard-
879 time offset of \a offsetSeconds.-
880-
881 \sa isTimeZoneIdAvailable()-
882*/-
883-
884QList<QByteArray> QTimeZone::availableTimeZoneIds(int offsetSeconds)-
885{-
886 return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(offsetSeconds),
executed 1 time by 1 test: return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(offsetSeconds), global_tz->backend->availableTimeZoneIds(offsetSeconds));
Executed by:
  • tst_QTimeZone
1
887 global_tz->backend->availableTimeZoneIds(offsetSeconds));
executed 1 time by 1 test: return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(offsetSeconds), global_tz->backend->availableTimeZoneIds(offsetSeconds));
Executed by:
  • tst_QTimeZone
1
888}-
889-
890/*!-
891 Returns the Windows ID equivalent to the given \a ianaId.-
892-
893 \sa windowsIdToDefaultIanaId(), windowsIdToIanaIds()-
894*/-
895-
896QByteArray QTimeZone::ianaIdToWindowsId(const QByteArray &ianaId)-
897{-
898 return QTimeZonePrivate::ianaIdToWindowsId(ianaId);
executed 5 times by 1 test: return QTimeZonePrivate::ianaIdToWindowsId(ianaId);
Executed by:
  • tst_QTimeZone
5
899}-
900-
901/*!-
902 Returns the default IANA ID for a given \a windowsId.-
903-
904 Because a Windows ID can cover several IANA IDs in several different-
905 countries, this function returns the most frequently used IANA ID with no-
906 regard for the country and should thus be used with care. It is usually-
907 best to request the default for a specific country.-
908-
909 \sa ianaIdToWindowsId(), windowsIdToIanaIds()-
910*/-
911-
912QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId)-
913{-
914 return QTimeZonePrivate::windowsIdToDefaultIanaId(windowsId);
executed 2 times by 1 test: return QTimeZonePrivate::windowsIdToDefaultIanaId(windowsId);
Executed by:
  • tst_QTimeZone
2
915}-
916-
917/*!-
918 Returns the default IANA ID for a given \a windowsId and \a country.-
919-
920 Because a Windows ID can cover several IANA IDs within a given country,-
921 the most frequently used IANA ID in that country is returned.-
922-
923 As a special case, QLocale::AnyCountry returns the default of those IANA IDs-
924 that do not have any specific country.-
925-
926 \sa ianaIdToWindowsId(), windowsIdToIanaIds()-
927*/-
928-
929QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId,-
930 QLocale::Country country)-
931{-
932 return QTimeZonePrivate::windowsIdToDefaultIanaId(windowsId, country);
executed 2 times by 1 test: return QTimeZonePrivate::windowsIdToDefaultIanaId(windowsId, country);
Executed by:
  • tst_QTimeZone
2
933}-
934-
935/*!-
936 Returns all the IANA IDs for a given \a windowsId.-
937-
938 The returned list is sorted alphabetically.-
939-
940 \sa ianaIdToWindowsId(), windowsIdToDefaultIanaId()-
941*/-
942-
943QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId)-
944{-
945 return QTimeZonePrivate::windowsIdToIanaIds(windowsId);
executed 2 times by 1 test: return QTimeZonePrivate::windowsIdToIanaIds(windowsId);
Executed by:
  • tst_QTimeZone
2
946}-
947-
948/*!-
949 Returns all the IANA IDs for a given \a windowsId and \a country.-
950-
951 As a special case QLocale::AnyCountry returns those IANA IDs that do-
952 not have any specific country.-
953-
954 The returned list is in order of frequency of usage, i.e. larger zones-
955 within a country are listed first.-
956-
957 \sa ianaIdToWindowsId(), windowsIdToDefaultIanaId()-
958*/-
959-
960QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,-
961 QLocale::Country country)-
962{-
963 return QTimeZonePrivate::windowsIdToIanaIds(windowsId, country);
executed 6 times by 1 test: return QTimeZonePrivate::windowsIdToIanaIds(windowsId, country);
Executed by:
  • tst_QTimeZone
6
964}-
965-
966#ifndef QT_NO_DATASTREAM-
967QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)-
968{-
969 tz.d->serialize(ds);-
970 return ds;
executed 3 times by 2 tests: return ds;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
3
971}-
972-
973QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)-
974{-
975 QString ianaId;-
976 ds >> ianaId;-
977 if (ianaId == QLatin1String("OffsetFromUtc")) {
ianaId == QLat...ffsetFromUtc")Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTimeZone
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
1-2
978 int utcOffset;-
979 QString name;-
980 QString abbreviation;-
981 int country;-
982 QString comment;-
983 ds >> ianaId >> utcOffset >> name >> abbreviation >> country >> comment;-
984 tz = QTimeZone(ianaId.toUtf8(), utcOffset, name, abbreviation, (QLocale::Country) country, comment);-
985 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_QTimeZone
1
986 tz = QTimeZone(ianaId.toUtf8());-
987 }
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
2
988 return ds;
executed 3 times by 2 tests: return ds;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
3
989}-
990#endif // QT_NO_DATASTREAM-
991-
992#ifndef QT_NO_DEBUG_STREAM-
993QDebug operator<<(QDebug dbg, const QTimeZone &tz)-
994{-
995 QDebugStateSaver saver(dbg);-
996 //TODO Include backend and data version details?-
997 dbg.nospace() << "QTimeZone(" << QString::fromUtf8(tz.id()) << ')';-
998 return dbg;
never executed: return dbg;
0
999}-
1000#endif-
1001-
1002QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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