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

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