qdatetime.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qdatetime.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2016 Intel Corporation.-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtCore module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include "qplatformdefs.h"-
42#include "private/qdatetime_p.h"-
43#include "private/qdatetimeparser_p.h"-
44-
45#include "qdatastream.h"-
46#include "qset.h"-
47#include "qlocale.h"-
48#include "qdatetime.h"-
49#include "qtimezoneprivate_p.h"-
50#include "qregexp.h"-
51#include "qdebug.h"-
52#ifndef Q_OS_WIN-
53#include <locale.h>-
54#endif-
55-
56#include <cmath>-
57#include <time.h>-
58#ifdef Q_OS_WIN-
59# include <qt_windows.h>-
60# ifdef Q_OS_WINCE-
61# include "qfunctions_wince.h"-
62# endif-
63# ifdef Q_OS_WINRT-
64# include "qfunctions_winrt.h"-
65# endif-
66#endif-
67-
68#if defined(Q_OS_MAC)-
69#include <private/qcore_mac_p.h>-
70#endif-
71-
72QT_BEGIN_NAMESPACE-
73-
74Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QDateTimePrivate>, defaultDateTimePrivate, (new QDateTimePrivate()))
executed 326 times by 128 tests: end of block
Executed by:
  • tst_languagechange - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qabstractslider - unknown status
  • tst_qaccessibility - unknown status
  • tst_qasn1element - unknown status
  • tst_qatomicint - unknown status
  • tst_qauthenticator - unknown status
  • tst_qbuttongroup - unknown status
  • tst_qcalendarwidget - unknown status
  • tst_qcolordialog - unknown status
  • tst_qcombobox - unknown status
  • tst_qcommandlinkbutton - unknown status
  • tst_qcompleter - unknown status
  • tst_qcoreapplication - unknown status
  • tst_qdatastream - unknown status
  • tst_qdate - unknown status
  • tst_qdatetime - unknown status
  • tst_qdatetimeedit - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbuscpp2xml - unknown status
  • tst_qdbusmarshall - unknown status
  • ...
executed 326 times by 128 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_languagechange - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qabstractslider - unknown status
  • tst_qaccessibility - unknown status
  • tst_qasn1element - unknown status
  • tst_qatomicint - unknown status
  • tst_qauthenticator - unknown status
  • tst_qbuttongroup - unknown status
  • tst_qcalendarwidget - unknown status
  • tst_qcolordialog - unknown status
  • tst_qcombobox - unknown status
  • tst_qcommandlinkbutton - unknown status
  • tst_qcompleter - unknown status
  • tst_qcoreapplication - unknown status
  • tst_qdatastream - unknown status
  • tst_qdate - unknown status
  • tst_qdatetime - unknown status
  • tst_qdatetimeedit - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbuscpp2xml - unknown status
  • tst_qdbusmarshall - unknown status
  • ...
executed 7100330 times by 127 tests: return &holder.value;
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
  • ...
guard.load() =...c::InitializedDescription
TRUEevaluated 326 times by 128 tests
Evaluated by:
  • tst_languagechange - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qabstractslider - unknown status
  • tst_qaccessibility - unknown status
  • tst_qasn1element - unknown status
  • tst_qatomicint - unknown status
  • tst_qauthenticator - unknown status
  • tst_qbuttongroup - unknown status
  • tst_qcalendarwidget - unknown status
  • tst_qcolordialog - unknown status
  • tst_qcombobox - unknown status
  • tst_qcommandlinkbutton - unknown status
  • tst_qcompleter - unknown status
  • tst_qcoreapplication - unknown status
  • tst_qdatastream - unknown status
  • tst_qdate - unknown status
  • tst_qdatetime - unknown status
  • tst_qdatetimeedit - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbuscpp2xml - unknown status
  • tst_qdbusmarshall - unknown status
  • ...
FALSEnever evaluated
0-7100330
75-
76/*****************************************************************************-
77 Date/Time Constants-
78 *****************************************************************************/-
79-
80enum {-
81 SECS_PER_DAY = 86400,-
82 MSECS_PER_DAY = 86400000,-
83 SECS_PER_HOUR = 3600,-
84 MSECS_PER_HOUR = 3600000,-
85 SECS_PER_MIN = 60,-
86 MSECS_PER_MIN = 60000,-
87 TIME_T_MAX = 2145916799, // int maximum 2037-12-31T23:59:59 UTC-
88 JULIAN_DAY_FOR_EPOCH = 2440588 // result of julianDayFromDate(1970, 1, 1)-
89};-
90-
91/*****************************************************************************-
92 QDate static helper functions-
93 *****************************************************************************/-
94-
95static inline QDate fixedDate(int y, int m, int d)-
96{-
97 QDate result(y, m, 1);-
98 result.setDate(y, m, qMin(d, result.daysInMonth()));-
99 return result;
executed 288 times by 4 tests: return result;
Executed by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
288
100}-
101-
102/*-
103 Division, rounding down (rather than towards zero).-
104-
105 From C++11 onwards, integer division is defined to round towards zero, so we-
106 can rely on that when implementing this. This is only used with denominator b-
107 > 0, so we only have to treat negative numerator, a, specially.-
108 */-
109static inline qint64 floordiv(qint64 a, int b)-
110{-
111 return (a - (a < 0 ? b - 1 : 0)) / b;
executed 96372952 times by 106 tests: return (a - (a < 0 ? b - 1 : 0)) / b;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
96372952
112}-
113-
114static inline int floordiv(int a, int b)-
115{-
116 return (a - (a < 0 ? b - 1 : 0)) / b;
executed 138065546 times by 106 tests: return (a - (a < 0 ? b - 1 : 0)) / b;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
138065546
117}-
118-
119static inline qint64 julianDayFromDate(int year, int month, int day)-
120{-
121 // Adjust for no year 0-
122 if (year < 0)
year < 0Description
TRUEevaluated 239374 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 21340606 times by 106 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
239374-21340606
123 ++year;
executed 239374 times by 2 tests: ++year;
Executed by:
  • tst_QDate
  • tst_QDateTime
239374
124-
125/*-
126 * Math from The Calendar FAQ at http://www.tondering.dk/claus/cal/julperiod.php-
127 * This formula is correct for all julian days, when using mathematical integer-
128 * division (round to negative infinity), not c++11 integer division (round to zero)-
129 */-
130 int a = floordiv(14 - month, 12);-
131 qint64 y = (qint64)year + 4800 - a;-
132 int m = month + 12 * a - 3;-
133 return day + floordiv(153 * m + 2, 5) + 365 * y + floordiv(y, 4) - floordiv(y, 100) + floordiv(y, 400) - 32045;
executed 21563880 times by 106 tests: return day + floordiv(153 * m + 2, 5) + 365 * y + floordiv(y, 4) - floordiv(y, 100) + floordiv(y, 400) - 32045;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
21563880
134}-
135-
136struct ParsedDate-
137{-
138 int year, month, day;-
139};-
140-
141// prevent this function from being inlined into all 10 users-
142Q_NEVER_INLINE-
143static ParsedDate getDateFromJulianDay(qint64 julianDay)-
144{-
145/*-
146 * Math from The Calendar FAQ at http://www.tondering.dk/claus/cal/julperiod.php-
147 * This formula is correct for all julian days, when using mathematical integer-
148 * division (round to negative infinity), not c++11 integer division (round to zero)-
149 */-
150 qint64 a = julianDay + 32044;-
151 qint64 b = floordiv(4 * a + 3, 146097);-
152 int c = a - floordiv(146097 * b, 4);-
153-
154 int d = floordiv(4 * c + 3, 1461);-
155 int e = c - floordiv(1461 * d, 4);-
156 int m = floordiv(5 * e + 2, 153);-
157-
158 int day = e - floordiv(153 * m + 2, 5) + 1;-
159 int month = m + 3 - 12 * floordiv(m, 10);-
160 int year = 100 * b + d - 4800 + floordiv(m, 10);-
161-
162 // Adjust for no year 0-
163 if (year <= 0)
year <= 0Description
TRUEevaluated 715840 times by 5 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEevaluated 15118575 times by 103 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
715840-15118575
164 --year ;
executed 715840 times by 5 tests: --year ;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
715840
165-
166 const ParsedDate result = { year, month, day };-
167 return result;
executed 15841708 times by 103 tests: return result;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
15841708
168}-
169-
170/*****************************************************************************-
171 Date/Time formatting helper functions-
172 *****************************************************************************/-
173-
174static const char monthDays[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };-
175-
176#ifndef QT_NO_TEXTDATE-
177static const char qt_shortMonthNames[][4] = {-
178 "Jan", "Feb", "Mar", "Apr", "May", "Jun",-
179 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };-
180-
181static int qt_monthNumberFromShortName(QStringRef shortName)-
182{-
183 for (unsigned int i = 0; i < sizeof(qt_shortMonthNames) / sizeof(qt_shortMonthNames[0]); ++i) {
i < sizeof(qt_...MonthNames[0])Description
TRUEevaluated 579 times by 4 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QTime
FALSEevaluated 25 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
25-579
184 if (shortName == QLatin1String(qt_shortMonthNames[i], 3))
shortName == Q...thNames[i], 3)Description
TRUEevaluated 90 times by 4 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QTime
FALSEevaluated 489 times by 4 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QTime
90-489
185 return i + 1;
executed 90 times by 4 tests: return i + 1;
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QTime
90
186 }
executed 489 times by 4 tests: end of block
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QTime
489
187 return -1;
executed 25 times by 3 tests: return -1;
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
25
188}-
189static int qt_monthNumberFromShortName(const QString &shortName)-
190{
executed 48 times by 3 tests: return qt_monthNumberFromShortName(QStringRef(&shortName));
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
return qt_monthNumberFromShortName(QStringRef(&shortName)); }
executed 48 times by 3 tests: return qt_monthNumberFromShortName(QStringRef(&shortName));
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
48
191-
192static int fromShortMonthName(const QStringRef &monthName)-
193{-
194 // Assume that English monthnames are the default-
195 int month = qt_monthNumberFromShortName(monthName);-
196 if (month != -1)
month != -1Description
TRUEevaluated 51 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
16-51
197 return month;
executed 51 times by 3 tests: return month;
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
51
198 // If English names can't be found, search the localized ones-
199 for (int i = 1; i <= 12; ++i) {
i <= 12Description
TRUEevaluated 192 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
16-192
200 if (monthName == QDate::shortMonthName(i))
monthName == Q...rtMonthName(i)Description
TRUEnever evaluated
FALSEevaluated 192 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
0-192
201 return i;
never executed: return i;
0
202 }
executed 192 times by 2 tests: end of block
Executed by:
  • tst_QDate
  • tst_QDateTime
192
203 return -1;
executed 16 times by 2 tests: return -1;
Executed by:
  • tst_QDate
  • tst_QDateTime
16
204}-
205#endif // QT_NO_TEXTDATE-
206-
207#ifndef QT_NO_DATESTRING-
208struct ParsedRfcDateTime {-
209 QDate date;-
210 QTime time;-
211 int utcOffset;-
212};-
213-
214static ParsedRfcDateTime rfcDateImpl(const QString &s)-
215{-
216 ParsedRfcDateTime result;-
217-
218 // Matches "Wdy, DD Mon YYYY HH:mm:ss ±hhmm" (Wdy, being optional)-
219 QRegExp rex(QStringLiteral("^(?:[A-Z][a-z]+,)?[ \\t]*(\\d{1,2})[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d)(?::(\\d\\d))?)?[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?"));
executed 71 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
71
220 if (s.indexOf(rex) == 0) {
s.indexOf(rex) == 0Description
TRUEevaluated 33 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
FALSEevaluated 38 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
33-38
221 const QStringList cap = rex.capturedTexts();-
222 result.date = QDate(cap[3].toInt(), qt_monthNumberFromShortName(cap[2]), cap[1].toInt());-
223 if (!cap[4].isEmpty())
!cap[4].isEmpty()Description
TRUEevaluated 27 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
6-27
224 result.time = QTime(cap[4].toInt(), cap[5].toInt(), cap[6].toInt());
executed 27 times by 3 tests: result.time = QTime(cap[4].toInt(), cap[5].toInt(), cap[6].toInt());
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
27
225 const bool positiveOffset = (cap[7] == QLatin1String("+"));-
226 const int hourOffset = cap[8].toInt();-
227 const int minOffset = cap[9].toInt();-
228 result.utcOffset = ((hourOffset * 60 + minOffset) * (positiveOffset ? 60 : -60));-
229 } else {
executed 33 times by 3 tests: end of block
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
33
230 // Matches "Wdy Mon DD HH:mm:ss YYYY"-
231 QRegExp rex(QStringLiteral("^[A-Z][a-z]+[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d):(\\d\\d))?[ \\t]+(\\d\\d\\d\\d)[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?"));
executed 38 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
38
232 if (s.indexOf(rex) == 0) {
s.indexOf(rex) == 0Description
TRUEevaluated 15 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
FALSEevaluated 23 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
15-23
233 const QStringList cap = rex.capturedTexts();-
234 result.date = QDate(cap[6].toInt(), qt_monthNumberFromShortName(cap[1]), cap[2].toInt());-
235 if (!cap[3].isEmpty())
!cap[3].isEmpty()Description
TRUEevaluated 12 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
FALSEevaluated 3 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
3-12
236 result.time = QTime(cap[3].toInt(), cap[4].toInt(), cap[5].toInt());
executed 12 times by 3 tests: result.time = QTime(cap[3].toInt(), cap[4].toInt(), cap[5].toInt());
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
12
237 const bool positiveOffset = (cap[7] == QLatin1String("+"));-
238 const int hourOffset = cap[8].toInt();-
239 const int minOffset = cap[9].toInt();-
240 result.utcOffset = ((hourOffset * 60 + minOffset) * (positiveOffset ? 60 : -60));-
241 }
executed 15 times by 3 tests: end of block
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
15
242 }
executed 38 times by 3 tests: end of block
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
38
243-
244 return result;
executed 71 times by 3 tests: return result;
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QTime
71
245}-
246#endif // QT_NO_DATESTRING-
247-
248// Return offset in [+-]HH:mm format-
249static QString toOffsetString(Qt::DateFormat format, int offset)-
250{-
251 return QString::asprintf("%c%02d%s%02d",
executed 98 times by 2 tests: return QString::asprintf("%c%02d%s%02d", offset >= 0 ? '+' : '-', qAbs(offset) / SECS_PER_HOUR, format == Qt::TextDate ? "" : ":", (qAbs(offset) / 60) % 60);
Executed by:
  • tst_QDateTime
  • tst_selftests - unknown status
98
252 offset >= 0 ? '+' : '-',
executed 98 times by 2 tests: return QString::asprintf("%c%02d%s%02d", offset >= 0 ? '+' : '-', qAbs(offset) / SECS_PER_HOUR, format == Qt::TextDate ? "" : ":", (qAbs(offset) / 60) % 60);
Executed by:
  • tst_QDateTime
  • tst_selftests - unknown status
98
253 qAbs(offset) / SECS_PER_HOUR,
executed 98 times by 2 tests: return QString::asprintf("%c%02d%s%02d", offset >= 0 ? '+' : '-', qAbs(offset) / SECS_PER_HOUR, format == Qt::TextDate ? "" : ":", (qAbs(offset) / 60) % 60);
Executed by:
  • tst_QDateTime
  • tst_selftests - unknown status
98
254 // Qt::ISODate puts : between the hours and minutes, but Qt:TextDate does not:
executed 98 times by 2 tests: return QString::asprintf("%c%02d%s%02d", offset >= 0 ? '+' : '-', qAbs(offset) / SECS_PER_HOUR, format == Qt::TextDate ? "" : ":", (qAbs(offset) / 60) % 60);
Executed by:
  • tst_QDateTime
  • tst_selftests - unknown status
98
255 format == Qt::TextDate ? "" : ":",
executed 98 times by 2 tests: return QString::asprintf("%c%02d%s%02d", offset >= 0 ? '+' : '-', qAbs(offset) / SECS_PER_HOUR, format == Qt::TextDate ? "" : ":", (qAbs(offset) / 60) % 60);
Executed by:
  • tst_QDateTime
  • tst_selftests - unknown status
98
256 (qAbs(offset) / 60) % 60);
executed 98 times by 2 tests: return QString::asprintf("%c%02d%s%02d", offset >= 0 ? '+' : '-', qAbs(offset) / SECS_PER_HOUR, format == Qt::TextDate ? "" : ":", (qAbs(offset) / 60) % 60);
Executed by:
  • tst_QDateTime
  • tst_selftests - unknown status
98
257}-
258-
259// Parse offset in [+-]HH[[:]mm] format-
260static int fromOffsetString(const QStringRef &offsetString, bool *valid) Q_DECL_NOTHROW-
261{-
262 *valid = false;-
263-
264 const int size = offsetString.size();-
265 if (size < 2 || size > 6)
size < 2Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QDateTime
size > 6Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QDateTime
0-22
266 return 0;
never executed: return 0;
0
267-
268 // sign will be +1 for a positive and -1 for a negative offset-
269 int sign;-
270-
271 // First char must be + or --
272 const QChar signChar = offsetString.at(0);-
273 if (signChar == QLatin1Char('+'))
signChar == QLatin1Char('+')Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QDateTime
11
274 sign = 1;
executed 11 times by 1 test: sign = 1;
Executed by:
  • tst_QDateTime
11
275 else if (signChar == QLatin1Char('-'))
signChar == QLatin1Char('-')Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
1-10
276 sign = -1;
executed 10 times by 1 test: sign = -1;
Executed by:
  • tst_QDateTime
10
277 else-
278 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QDateTime
1
279-
280 // Split the hour and minute parts-
281 const QStringRef time = offsetString.mid(1);-
282 int hhLen = time.indexOf(QLatin1Char(':'));-
283 int mmIndex;-
284 if (hhLen == -1)
hhLen == -1Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QDateTime
8-13
285 mmIndex = hhLen = 2; // [+-]HHmm or [+-]HH format
executed 13 times by 1 test: mmIndex = hhLen = 2;
Executed by:
  • tst_QDateTime
13
286 else-
287 mmIndex = hhLen + 1;
executed 8 times by 1 test: mmIndex = hhLen + 1;
Executed by:
  • tst_QDateTime
8
288-
289 const QStringRef hhRef = time.left(hhLen);-
290 bool ok = false;-
291 const int hour = hhRef.toInt(&ok);-
292 if (!ok)
!okDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 19 times by 1 test
Evaluated by:
  • tst_QDateTime
2-19
293 return 0;
executed 2 times by 1 test: return 0;
Executed by:
  • tst_QDateTime
2
294-
295 const QStringRef mmRef = time.mid(mmIndex);-
296 const int minute = mmRef.isEmpty() ? 0 : mmRef.toInt(&ok);
mmRef.isEmpty()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 15 times by 1 test
Evaluated by:
  • tst_QDateTime
4-15
297 if (!ok || minute < 0 || minute > 59)
!okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QDateTime
minute < 0Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QDateTime
minute > 59Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QDateTime
0-18
298 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QDateTime
1
299-
300 *valid = true;-
301 return sign * ((hour * 60) + minute) * 60;
executed 18 times by 1 test: return sign * ((hour * 60) + minute) * 60;
Executed by:
  • tst_QDateTime
18
302}-
303-
304/*****************************************************************************-
305 QDate member functions-
306 *****************************************************************************/-
307-
308/*!-
309 \since 4.5-
310-
311 \enum QDate::MonthNameType-
312-
313 This enum describes the types of the string representation used-
314 for the month name.-
315-
316 \value DateFormat This type of name can be used for date-to-string formatting.-
317 \value StandaloneFormat This type is used when you need to enumerate months or weekdays.-
318 Usually standalone names are represented in singular forms with-
319 capitalized first letter.-
320*/-
321-
322/*!-
323 \class QDate-
324 \inmodule QtCore-
325 \reentrant-
326 \brief The QDate class provides date functions.-
327-
328-
329 A QDate object contains a calendar date, i.e. year, month, and day-
330 numbers, in the Gregorian calendar. It can read the current date-
331 from the system clock. It provides functions for comparing dates,-
332 and for manipulating dates. For example, it is possible to add-
333 and subtract days, months, and years to dates.-
334-
335 A QDate object is typically created by giving the year,-
336 month, and day numbers explicitly. Note that QDate interprets two-
337 digit years as is, i.e., years 0 - 99. A QDate can also be-
338 constructed with the static function currentDate(), which creates-
339 a QDate object containing the system clock's date. An explicit-
340 date can also be set using setDate(). The fromString() function-
341 returns a QDate given a string and a date format which is used to-
342 interpret the date within the string.-
343-
344 The year(), month(), and day() functions provide access to the-
345 year, month, and day numbers. Also, dayOfWeek() and dayOfYear()-
346 functions are provided. The same information is provided in-
347 textual format by the toString(), shortDayName(), longDayName(),-
348 shortMonthName(), and longMonthName() functions.-
349-
350 QDate provides a full set of operators to compare two QDate-
351 objects where smaller means earlier, and larger means later.-
352-
353 You can increment (or decrement) a date by a given number of days-
354 using addDays(). Similarly you can use addMonths() and addYears().-
355 The daysTo() function returns the number of days between two-
356 dates.-
357-
358 The daysInMonth() and daysInYear() functions return how many days-
359 there are in this date's month and year, respectively. The-
360 isLeapYear() function indicates whether a date is in a leap year.-
361-
362 \section1-
363-
364 \section2 No Year 0-
365-
366 There is no year 0. Dates in that year are considered invalid. The-
367 year -1 is the year "1 before Christ" or "1 before current era."-
368 The day before 1 January 1 CE is 31 December 1 BCE.-
369-
370 \section2 Range of Valid Dates-
371-
372 Dates are stored internally as a Julian Day number, an integer count of-
373 every day in a contiguous range, with 24 November 4714 BCE in the Gregorian-
374 calendar being Julian Day 0 (1 January 4713 BCE in the Julian calendar).-
375 As well as being an efficient and accurate way of storing an absolute date,-
376 it is suitable for converting a Date into other calendar systems such as-
377 Hebrew, Islamic or Chinese. The Julian Day number can be obtained using-
378 QDate::toJulianDay() and can be set using QDate::fromJulianDay().-
379-
380 The range of dates able to be stored by QDate as a Julian Day number is-
381 for technical reasons limited to between -784350574879 and 784354017364,-
382 which means from before 2 billion BCE to after 2 billion CE.-
383-
384 \sa QTime, QDateTime, QDateEdit, QDateTimeEdit, QCalendarWidget-
385*/-
386-
387/*!-
388 \fn QDate::QDate()-
389-
390 Constructs a null date. Null dates are invalid.-
391-
392 \sa isNull(), isValid()-
393*/-
394-
395/*!-
396 Constructs a date with year \a y, month \a m and day \a d.-
397-
398 If the specified date is invalid, the date is not set and-
399 isValid() returns \c false.-
400-
401 \warning Years 1 to 99 are interpreted as is. Year 0 is invalid.-
402-
403 \sa isValid()-
404*/-
405-
406QDate::QDate(int y, int m, int d)-
407{-
408 setDate(y, m, d);-
409}
executed 21012299 times by 106 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
21012299
410-
411-
412/*!-
413 \fn bool QDate::isNull() const-
414-
415 Returns \c true if the date is null; otherwise returns \c false. A null-
416 date is invalid.-
417-
418 \note The behavior of this function is equivalent to isValid().-
419-
420 \sa isValid()-
421*/-
422-
423-
424/*!-
425 \fn bool QDate::isValid() const-
426-
427 Returns \c true if this date is valid; otherwise returns \c false.-
428-
429 \sa isNull()-
430*/-
431-
432-
433/*!-
434 Returns the year of this date. Negative numbers indicate years-
435 before 1 CE, such that year -44 is 44 BCE.-
436-
437 Returns 0 if the date is invalid.-
438-
439 \sa month(), day()-
440*/-
441-
442int QDate::year() const-
443{-
444 if (isNull())
isNull()Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 621887 times by 42 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QCalendarWidget
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • ...
24-621887
445 return 0;
executed 24 times by 2 tests: return 0;
Executed by:
  • tst_QDate
  • tst_QDateTime
24
446-
447 return getDateFromJulianDay(jd).year;
executed 621887 times by 42 tests: return getDateFromJulianDay(jd).year;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QCalendarWidget
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • ...
621887
448}-
449-
450/*!-
451 Returns the number corresponding to the month of this date, using-
452 the following convention:-
453-
454 \list-
455 \li 1 = "January"-
456 \li 2 = "February"-
457 \li 3 = "March"-
458 \li 4 = "April"-
459 \li 5 = "May"-
460 \li 6 = "June"-
461 \li 7 = "July"-
462 \li 8 = "August"-
463 \li 9 = "September"-
464 \li 10 = "October"-
465 \li 11 = "November"-
466 \li 12 = "December"-
467 \endlist-
468-
469 Returns 0 if the date is invalid.-
470-
471 \sa year(), day()-
472*/-
473-
474int QDate::month() const-
475{-
476 if (isNull())
isNull()Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 611545 times by 41 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QCalendarWidget
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • ...
24-611545
477 return 0;
executed 24 times by 2 tests: return 0;
Executed by:
  • tst_QDate
  • tst_QDateTime
24
478-
479 return getDateFromJulianDay(jd).month;
executed 611545 times by 41 tests: return getDateFromJulianDay(jd).month;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QCalendarWidget
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • ...
611545
480}-
481-
482/*!-
483 Returns the day of the month (1 to 31) of this date.-
484-
485 Returns 0 if the date is invalid.-
486-
487 \sa year(), month(), dayOfWeek()-
488*/-
489-
490int QDate::day() const-
491{-
492 if (isNull())
isNull()Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 647403 times by 40 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QCalendarWidget
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • ...
24-647403
493 return 0;
executed 24 times by 2 tests: return 0;
Executed by:
  • tst_QDate
  • tst_QDateTime
24
494-
495 return getDateFromJulianDay(jd).day;
executed 647403 times by 40 tests: return getDateFromJulianDay(jd).day;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QCalendarWidget
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • ...
647403
496}-
497-
498/*!-
499 Returns the weekday (1 = Monday to 7 = Sunday) for this date.-
500-
501 Returns 0 if the date is invalid.-
502-
503 \sa day(), dayOfYear(), Qt::DayOfWeek-
504*/-
505-
506int QDate::dayOfWeek() const-
507{-
508 if (isNull())
isNull()Description
TRUEevaluated 77 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEevaluated 39478 times by 17 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
  • tst_QTimeZone
  • tst_QXmlStream
  • tst_qmakelib
77-39478
509 return 0;
executed 77 times by 3 tests: return 0;
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
77
510-
511 if (jd >= 0)
jd >= 0Description
TRUEevaluated 39470 times by 17 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
  • tst_QTimeZone
  • tst_QXmlStream
  • tst_qmakelib
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QDate
8-39470
512 return (jd % 7) + 1;
executed 39470 times by 17 tests: return (jd % 7) + 1;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
  • tst_QTimeZone
  • tst_QXmlStream
  • tst_qmakelib
39470
513 else-
514 return ((jd + 1) % 7) + 7;
executed 8 times by 1 test: return ((jd + 1) % 7) + 7;
Executed by:
  • tst_QDate
8
515}-
516-
517/*!-
518 Returns the day of the year (1 to 365 or 366 on leap years) for-
519 this date.-
520-
521 Returns 0 if the date is invalid.-
522-
523 \sa day(), dayOfWeek()-
524*/-
525-
526int QDate::dayOfYear() const-
527{-
528 if (isNull())
isNull()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 1907 times by 3 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
1-1907
529 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QDate
1
530-
531 return jd - julianDayFromDate(year(), 1, 1) + 1;
executed 1907 times by 3 tests: return jd - julianDayFromDate(year(), 1, 1) + 1;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
1907
532}-
533-
534/*!-
535 Returns the number of days in the month (28 to 31) for this date.-
536-
537 Returns 0 if the date is invalid.-
538-
539 \sa day(), daysInYear()-
540*/-
541-
542int QDate::daysInMonth() const-
543{-
544 if (isNull())
isNull()Description
TRUEevaluated 41 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTimeEdit
FALSEevaluated 4510 times by 8 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
  • tst_QTime
41-4510
545 return 0;
executed 41 times by 2 tests: return 0;
Executed by:
  • tst_QDate
  • tst_QDateTimeEdit
41
546-
547 const ParsedDate pd = getDateFromJulianDay(jd);-
548 if (pd.month == 2 && isLeapYear(pd.year))
pd.month == 2Description
TRUEevaluated 223 times by 7 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
FALSEevaluated 4287 times by 8 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
  • tst_QTime
isLeapYear(pd.year)Description
TRUEevaluated 159 times by 7 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
FALSEevaluated 64 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
64-4287
549 return 29;
executed 159 times by 7 tests: return 29;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
159
550 else-
551 return monthDays[pd.month];
executed 4351 times by 8 tests: return monthDays[pd.month];
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
  • tst_QTime
4351
552}-
553-
554/*!-
555 Returns the number of days in the year (365 or 366) for this date.-
556-
557 Returns 0 if the date is invalid.-
558-
559 \sa day(), daysInMonth()-
560*/-
561-
562int QDate::daysInYear() const-
563{-
564 if (isNull())
isNull()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QDate
1-4
565 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QDate
1
566-
567 return isLeapYear(getDateFromJulianDay(jd).year) ? 366 : 365;
executed 4 times by 1 test: return isLeapYear(getDateFromJulianDay(jd).year) ? 366 : 365;
Executed by:
  • tst_QDate
4
568}-
569-
570/*!-
571 Returns the week number (1 to 53), and stores the year in-
572 *\a{yearNumber} unless \a yearNumber is null (the default).-
573-
574 Returns 0 if the date is invalid.-
575-
576 In accordance with ISO 8601, weeks start on Monday and the first-
577 Thursday of a year is always in week 1 of that year. Most years-
578 have 52 weeks, but some have 53.-
579-
580 *\a{yearNumber} is not always the same as year(). For example, 1-
581 January 2000 has week number 52 in the year 1999, and 31 December-
582 2002 has week number 1 in the year 2003.-
583-
584 \sa isValid()-
585*/-
586-
587int QDate::weekNumber(int *yearNumber) const-
588{-
589 if (!isValid())
!isValid()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 1894 times by 3 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
3-1894
590 return 0;
executed 3 times by 1 test: return 0;
Executed by:
  • tst_QDate
3
591-
592 int year = QDate::year();-
593 int yday = dayOfYear();-
594 int wday = dayOfWeek();-
595-
596 int week = (yday - wday + 10) / 7;-
597-
598 if (week == 0) {
week == 0Description
TRUEevaluated 172 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 1722 times by 3 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
172-1722
599 // last week of previous year-
600 --year;-
601 week = (yday + 365 + (QDate::isLeapYear(year) ? 1 : 0) - wday + 10) / 7;
QDate::isLeapYear(year)Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 130 times by 1 test
Evaluated by:
  • tst_QDate
42-130
602 Q_ASSERT(week == 52 || week == 53);-
603 } else if (week == 53) {
executed 172 times by 1 test: end of block
Executed by:
  • tst_QDate
week == 53Description
TRUEevaluated 315 times by 2 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
FALSEevaluated 1407 times by 3 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
172-1407
604 // maybe first week of next year-
605 int w = (yday - 365 - (QDate::isLeapYear(year) ? 1 : 0) - wday + 10) / 7;
QDate::isLeapYear(year)Description
TRUEevaluated 96 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 219 times by 2 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
96-219
606 if (w > 0) {
w > 0Description
TRUEevaluated 173 times by 2 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
FALSEevaluated 142 times by 1 test
Evaluated by:
  • tst_QDate
142-173
607 ++year;-
608 week = w;-
609 }
executed 173 times by 2 tests: end of block
Executed by:
  • tst_QCalendarWidget
  • tst_QDate
173
610 Q_ASSERT(week == 53 || week == 1);-
611 }
executed 315 times by 2 tests: end of block
Executed by:
  • tst_QCalendarWidget
  • tst_QDate
315
612-
613 if (yearNumber != 0)
yearNumber != 0Description
TRUEevaluated 1600 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 294 times by 2 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
294-1600
614 *yearNumber = year;
executed 1600 times by 1 test: *yearNumber = year;
Executed by:
  • tst_QDate
1600
615 return week;
executed 1894 times by 3 tests: return week;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
1894
616}-
617-
618#ifndef QT_NO_TEXTDATE-
619/*!-
620 \since 4.5-
621-
622 Returns the short name of the \a month for the representation specified-
623 by \a type.-
624-
625 The months are enumerated using the following convention:-
626-
627 \list-
628 \li 1 = "Jan"-
629 \li 2 = "Feb"-
630 \li 3 = "Mar"-
631 \li 4 = "Apr"-
632 \li 5 = "May"-
633 \li 6 = "Jun"-
634 \li 7 = "Jul"-
635 \li 8 = "Aug"-
636 \li 9 = "Sep"-
637 \li 10 = "Oct"-
638 \li 11 = "Nov"-
639 \li 12 = "Dec"-
640 \endlist-
641-
642 The month names will be localized according to the system's-
643 locale settings, i.e. using QLocale::system().-
644-
645 Returns an empty string if the date is invalid.-
646-
647 \sa toString(), longMonthName(), shortDayName(), longDayName()-
648*/-
649-
650QString QDate::shortMonthName(int month, QDate::MonthNameType type)-
651{-
652 if (month >= 1 || month <= 12) {
month >= 1Description
TRUEevaluated 624 times by 4 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_qmakelib
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
month <= 12Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
FALSEnever evaluated
0-624
653 switch (type) {-
654 case QDate::DateFormat:
executed 612 times by 4 tests: case QDate::DateFormat:
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_qmakelib
612
655 return QLocale::system().monthName(month, QLocale::ShortFormat);
executed 612 times by 4 tests: return QLocale::system().monthName(month, QLocale::ShortFormat);
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_qmakelib
612
656 case QDate::StandaloneFormat:
executed 14 times by 1 test: case QDate::StandaloneFormat:
Executed by:
  • tst_QDate
14
657 return QLocale::system().standaloneMonthName(month, QLocale::ShortFormat);
executed 14 times by 1 test: return QLocale::system().standaloneMonthName(month, QLocale::ShortFormat);
Executed by:
  • tst_QDate
14
658 }-
659 }
never executed: end of block
0
660 return QString();
never executed: return QString();
0
661}-
662-
663/*!-
664 \since 4.5-
665-
666 Returns the long name of the \a month for the representation specified-
667 by \a type.-
668-
669 The months are enumerated using the following convention:-
670-
671 \list-
672 \li 1 = "January"-
673 \li 2 = "February"-
674 \li 3 = "March"-
675 \li 4 = "April"-
676 \li 5 = "May"-
677 \li 6 = "June"-
678 \li 7 = "July"-
679 \li 8 = "August"-
680 \li 9 = "September"-
681 \li 10 = "October"-
682 \li 11 = "November"-
683 \li 12 = "December"-
684 \endlist-
685-
686 The month names will be localized according to the system's-
687 locale settings, i.e. using QLocale::system().-
688-
689 Returns an empty string if the date is invalid.-
690-
691 \sa toString(), shortMonthName(), shortDayName(), longDayName()-
692*/-
693-
694QString QDate::longMonthName(int month, MonthNameType type)-
695{-
696 if (month >= 1 && month <= 12) {
month >= 1Description
TRUEevaluated 38 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
month <= 12Description
TRUEevaluated 36 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
2-38
697 switch (type) {-
698 case QDate::DateFormat:
executed 24 times by 3 tests: case QDate::DateFormat:
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
24
699 return QLocale::system().monthName(month, QLocale::LongFormat);
executed 24 times by 3 tests: return QLocale::system().monthName(month, QLocale::LongFormat);
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
24
700 case QDate::StandaloneFormat:
executed 12 times by 1 test: case QDate::StandaloneFormat:
Executed by:
  • tst_QDate
12
701 return QLocale::system().standaloneMonthName(month, QLocale::LongFormat);
executed 12 times by 1 test: return QLocale::system().standaloneMonthName(month, QLocale::LongFormat);
Executed by:
  • tst_QDate
12
702 }-
703 }
never executed: end of block
0
704 return QString();
executed 4 times by 1 test: return QString();
Executed by:
  • tst_QDate
4
705}-
706-
707/*!-
708 \since 4.5-
709-
710 Returns the short name of the \a weekday for the representation specified-
711 by \a type.-
712-
713 The days are enumerated using the following convention:-
714-
715 \list-
716 \li 1 = "Mon"-
717 \li 2 = "Tue"-
718 \li 3 = "Wed"-
719 \li 4 = "Thu"-
720 \li 5 = "Fri"-
721 \li 6 = "Sat"-
722 \li 7 = "Sun"-
723 \endlist-
724-
725 The day names will be localized according to the system's-
726 locale settings, i.e. using QLocale::system().-
727-
728 Returns an empty string if the date is invalid.-
729-
730 \sa toString(), shortMonthName(), longMonthName(), longDayName()-
731*/-
732-
733QString QDate::shortDayName(int weekday, MonthNameType type)-
734{-
735 if (weekday >= 1 && weekday <= 7) {
weekday >= 1Description
TRUEevaluated 422 times by 4 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_qmakelib
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
weekday <= 7Description
TRUEevaluated 420 times by 4 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_qmakelib
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
2-422
736 switch (type) {-
737 case QDate::DateFormat:
executed 413 times by 4 tests: case QDate::DateFormat:
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_qmakelib
413
738 return QLocale::system().dayName(weekday, QLocale::ShortFormat);
executed 413 times by 4 tests: return QLocale::system().dayName(weekday, QLocale::ShortFormat);
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_qmakelib
413
739 case QDate::StandaloneFormat:
executed 7 times by 1 test: case QDate::StandaloneFormat:
Executed by:
  • tst_QDate
7
740 return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat);
executed 7 times by 1 test: return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat);
Executed by:
  • tst_QDate
7
741 }-
742 }
never executed: end of block
0
743 return QString();
executed 4 times by 1 test: return QString();
Executed by:
  • tst_QDate
4
744}-
745-
746/*!-
747 \since 4.5-
748-
749 Returns the long name of the \a weekday for the representation specified-
750 by \a type.-
751-
752 The days are enumerated using the following convention:-
753-
754 \list-
755 \li 1 = "Monday"-
756 \li 2 = "Tuesday"-
757 \li 3 = "Wednesday"-
758 \li 4 = "Thursday"-
759 \li 5 = "Friday"-
760 \li 6 = "Saturday"-
761 \li 7 = "Sunday"-
762 \endlist-
763-
764 The day names will be localized according to the system's-
765 locale settings, i.e. using QLocale::system().-
766-
767 Returns an empty string if the date is invalid.-
768-
769 \sa toString(), shortDayName(), shortMonthName(), longMonthName()-
770*/-
771-
772QString QDate::longDayName(int weekday, MonthNameType type)-
773{-
774 if (weekday >= 1 && weekday <= 7) {
weekday >= 1Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
weekday <= 7Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
2-23
775 switch (type) {-
776 case QDate::DateFormat:
executed 14 times by 1 test: case QDate::DateFormat:
Executed by:
  • tst_QDate
14
777 return QLocale::system().dayName(weekday, QLocale::LongFormat);
executed 14 times by 1 test: return QLocale::system().dayName(weekday, QLocale::LongFormat);
Executed by:
  • tst_QDate
14
778 case QDate::StandaloneFormat:
executed 7 times by 1 test: case QDate::StandaloneFormat:
Executed by:
  • tst_QDate
7
779 return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat);
executed 7 times by 1 test: return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat);
Executed by:
  • tst_QDate
7
780 }-
781 }
never executed: end of block
0
782 return QString();
executed 4 times by 1 test: return QString();
Executed by:
  • tst_QDate
4
783}-
784#endif //QT_NO_TEXTDATE-
785-
786#ifndef QT_NO_DATESTRING-
787-
788#ifndef QT_NO_TEXTDATE-
789static QString toStringTextDate(QDate date)-
790{-
791 const ParsedDate pd = getDateFromJulianDay(date.toJulianDay());-
792 static const QLatin1Char sp(' ');-
793 return date.shortDayName(date.dayOfWeek()) + sp
executed 2 times by 1 test: return date.shortDayName(date.dayOfWeek()) + sp + date.shortMonthName(pd.month) + sp + QString::number(pd.day) + sp + QString::number(pd.year);
Executed by:
  • tst_QDate
2
794 + date.shortMonthName(pd.month) + sp
executed 2 times by 1 test: return date.shortDayName(date.dayOfWeek()) + sp + date.shortMonthName(pd.month) + sp + QString::number(pd.day) + sp + QString::number(pd.year);
Executed by:
  • tst_QDate
2
795 + QString::number(pd.day) + sp
executed 2 times by 1 test: return date.shortDayName(date.dayOfWeek()) + sp + date.shortMonthName(pd.month) + sp + QString::number(pd.day) + sp + QString::number(pd.year);
Executed by:
  • tst_QDate
2
796 + QString::number(pd.year);
executed 2 times by 1 test: return date.shortDayName(date.dayOfWeek()) + sp + date.shortMonthName(pd.month) + sp + QString::number(pd.day) + sp + QString::number(pd.year);
Executed by:
  • tst_QDate
2
797}-
798#endif // QT_NO_TEXTDATE-
799-
800static QString toStringIsoDate(qint64 jd)-
801{-
802 const ParsedDate pd = getDateFromJulianDay(jd);-
803 if (pd.year >= 0 && pd.year <= 9999)
pd.year >= 0Description
TRUEevaluated 36 times by 5 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QVariant
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
pd.year <= 9999Description
TRUEevaluated 36 times by 5 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QVariant
FALSEnever evaluated
0-36
804 return QString::asprintf("%04d-%02d-%02d", pd.year, pd.month, pd.day);
executed 36 times by 5 tests: return QString::asprintf("%04d-%02d-%02d", pd.year, pd.month, pd.day);
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QVariant
36
805 else-
806 return QString();
executed 3 times by 2 tests: return QString();
Executed by:
  • tst_QDate
  • tst_QDateTime
3
807}-
808-
809/*!-
810 \fn QString QDate::toString(Qt::DateFormat format) const-
811-
812 \overload-
813-
814 Returns the date as a string. The \a format parameter determines-
815 the format of the string.-
816-
817 If the \a format is Qt::TextDate, the string is formatted in-
818 the default way. QDate::shortDayName() and QDate::shortMonthName()-
819 are used to generate the string, so the day and month names will-
820 be localized names using the system locale, i.e. QLocale::system(). An-
821 example of this formatting is "Sat May 20 1995".-
822-
823 If the \a format is Qt::ISODate, the string format corresponds-
824 to the ISO 8601 extended specification for representations of-
825 dates and times, taking the form YYYY-MM-DD, where YYYY is the-
826 year, MM is the month of the year (between 01 and 12), and DD is-
827 the day of the month between 01 and 31.-
828-
829 If the \a format is Qt::SystemLocaleShortDate or-
830 Qt::SystemLocaleLongDate, the string format depends on the locale-
831 settings of the system. Identical to calling-
832 QLocale::system().toString(date, QLocale::ShortFormat) or-
833 QLocale::system().toString(date, QLocale::LongFormat).-
834-
835 If the \a format is Qt::DefaultLocaleShortDate or-
836 Qt::DefaultLocaleLongDate, the string format depends on the-
837 default application locale. This is the locale set with-
838 QLocale::setDefault(), or the system locale if no default locale-
839 has been set. Identical to calling-
840 \l {QLocale::toString()}{QLocale().toString(date, QLocale::ShortFormat) } or-
841 \l {QLocale::toString()}{QLocale().toString(date, QLocale::LongFormat)}.-
842-
843 If the \a format is Qt::RFC2822Date, the string is formatted in-
844 an \l{RFC 2822} compatible way. An example of this formatting is-
845 "20 May 1995".-
846-
847 If the date is invalid, an empty string will be returned.-
848-
849 \warning The Qt::ISODate format is only valid for years in the-
850 range 0 to 9999. This restriction may apply to locale-aware-
851 formats as well, depending on the locale settings.-
852-
853 \sa fromString(), shortDayName(), shortMonthName(), QLocale::toString()-
854*/-
855QString QDate::toString(Qt::DateFormat format) const-
856{-
857 if (!isValid())
!isValid()Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QVariant
FALSEevaluated 98 times by 5 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QVariant
2-98
858 return QString();
executed 2 times by 2 tests: return QString();
Executed by:
  • tst_QDate
  • tst_QVariant
2
859-
860 switch (format) {-
861 case Qt::SystemLocaleDate:
never executed: case Qt::SystemLocaleDate:
0
862 case Qt::SystemLocaleShortDate:
executed 14 times by 1 test: case Qt::SystemLocaleShortDate:
Executed by:
  • tst_QDate
14
863 return QLocale::system().toString(*this, QLocale::ShortFormat);
executed 14 times by 1 test: return QLocale::system().toString(*this, QLocale::ShortFormat);
Executed by:
  • tst_QDate
14
864 case Qt::SystemLocaleLongDate:
executed 14 times by 1 test: case Qt::SystemLocaleLongDate:
Executed by:
  • tst_QDate
14
865 return QLocale::system().toString(*this, QLocale::LongFormat);
executed 14 times by 1 test: return QLocale::system().toString(*this, QLocale::LongFormat);
Executed by:
  • tst_QDate
14
866 case Qt::LocaleDate:
never executed: case Qt::LocaleDate:
0
867 case Qt::DefaultLocaleShortDate:
executed 14 times by 1 test: case Qt::DefaultLocaleShortDate:
Executed by:
  • tst_QDate
14
868 return QLocale().toString(*this, QLocale::ShortFormat);
executed 14 times by 1 test: return QLocale().toString(*this, QLocale::ShortFormat);
Executed by:
  • tst_QDate
14
869 case Qt::DefaultLocaleLongDate:
executed 14 times by 1 test: case Qt::DefaultLocaleLongDate:
Executed by:
  • tst_QDate
14
870 return QLocale().toString(*this, QLocale::LongFormat);
executed 14 times by 1 test: return QLocale().toString(*this, QLocale::LongFormat);
Executed by:
  • tst_QDate
14
871 case Qt::RFC2822Date:
executed 1 time by 1 test: case Qt::RFC2822Date:
Executed by:
  • tst_QDate
1
872 return QLocale::c().toString(*this, QStringLiteral("dd MMM yyyy"));
executed 1 time by 1 test: return QLocale::c().toString(*this, ([]() -> QString { enum { Size = sizeof(u"" "dd MMM yyyy")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "dd MMM yyyy" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));
Executed by:
  • tst_QDate
executed 1 time by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QDate
1
873 default:
never executed: default:
0
874#ifndef QT_NO_TEXTDATE-
875 case Qt::TextDate:
executed 2 times by 1 test: case Qt::TextDate:
Executed by:
  • tst_QDate
2
876 return toStringTextDate(*this);
executed 2 times by 1 test: return toStringTextDate(*this);
Executed by:
  • tst_QDate
2
877#endif-
878 case Qt::ISODate:
executed 39 times by 5 tests: case Qt::ISODate:
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QVariant
39
879 return toStringIsoDate(jd);
executed 39 times by 5 tests: return toStringIsoDate(jd);
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QVariant
39
880 }-
881}-
882-
883/*!-
884 Returns the date as a string. The \a format parameter determines-
885 the format of the result string.-
886-
887 These expressions may be used:-
888-
889 \table-
890 \header \li Expression \li Output-
891 \row \li d \li the day as number without a leading zero (1 to 31)-
892 \row \li dd \li the day as number with a leading zero (01 to 31)-
893 \row \li ddd-
894 \li the abbreviated localized day name (e.g. 'Mon' to 'Sun').-
895 Uses the system locale to localize the name, i.e. QLocale::system().-
896 \row \li dddd-
897 \li the long localized day name (e.g. 'Monday' to 'Sunday').-
898 Uses the system locale to localize the name, i.e. QLocale::system().-
899 \row \li M \li the month as number without a leading zero (1 to 12)-
900 \row \li MM \li the month as number with a leading zero (01 to 12)-
901 \row \li MMM-
902 \li the abbreviated localized month name (e.g. 'Jan' to 'Dec').-
903 Uses the system locale to localize the name, i.e. QLocale::system().-
904 \row \li MMMM-
905 \li the long localized month name (e.g. 'January' to 'December').-
906 Uses the system locale to localize the name, i.e. QLocale::system().-
907 \row \li yy \li the year as two digit number (00 to 99)-
908 \row \li yyyy \li the year as four digit number. If the year is negative,-
909 a minus sign is prepended in addition.-
910 \endtable-
911-
912 All other input characters will be ignored. Any sequence of characters that-
913 are enclosed in single quotes will be treated as text and not be used as an-
914 expression. Two consecutive single quotes ("''") are replaced by a singlequote-
915 in the output. Formats without separators (e.g. "ddMM") are currently not supported.-
916-
917 Example format strings (assuming that the QDate is the 20 July-
918 1969):-
919-
920 \table-
921 \header \li Format \li Result-
922 \row \li dd.MM.yyyy \li 20.07.1969-
923 \row \li ddd MMMM d yy \li Sun July 20 69-
924 \row \li 'The day is' dddd \li The day is Sunday-
925 \endtable-
926-
927 If the datetime is invalid, an empty string will be returned.-
928-
929 \sa fromString(), QDateTime::toString(), QTime::toString(), QLocale::toString()-
930-
931*/-
932QString QDate::toString(const QString& format) const-
933{-
934 return QLocale::system().toString(*this, format);
executed 13977 times by 8 tests: return QLocale::system().toString(*this, format);
Executed by:
  • tst_QCalendarWidget
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QVariant
13977
935}-
936#endif //QT_NO_DATESTRING-
937-
938/*!-
939 \fn bool QDate::setYMD(int y, int m, int d)-
940-
941 \deprecated in 5.0, use setDate() instead.-
942-
943 Sets the date's year \a y, month \a m, and day \a d.-
944-
945 If \a y is in the range 0 to 99, it is interpreted as 1900 to-
946 1999.-
947 Returns \c false if the date is invalid.-
948-
949 Use setDate() instead.-
950*/-
951-
952/*!-
953 \since 4.2-
954-
955 Sets the date's \a year, \a month, and \a day. Returns \c true if-
956 the date is valid; otherwise returns \c false.-
957-
958 If the specified date is invalid, the QDate object is set to be-
959 invalid.-
960-
961 \sa isValid()-
962*/-
963bool QDate::setDate(int year, int month, int day)-
964{-
965 if (isValid(year, month, day))
isValid(year, month, day)Description
TRUEevaluated 21571360 times by 106 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
FALSEevaluated 11380 times by 6 tests
Evaluated by:
  • tst_QDBusMarshall
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCookie
  • tst_QTime
11380-21571360
966 jd = julianDayFromDate(year, month, day);
executed 21573166 times by 106 tests: jd = julianDayFromDate(year, month, day);
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
21573166
967 else-
968 jd = nullJd();
executed 11380 times by 6 tests: jd = nullJd();
Executed by:
  • tst_QDBusMarshall
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCookie
  • tst_QTime
11380
969-
970 return isValid();
executed 21589453 times by 106 tests: return isValid();
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
21589453
971}-
972-
973/*!-
974 \since 4.5-
975-
976 Extracts the date's year, month, and day, and assigns them to-
977 *\a year, *\a month, and *\a day. The pointers may be null.-
978-
979 Returns 0 if the date is invalid.-
980-
981 \note In Qt versions prior to 5.7, this function is marked as non-\c{const}.-
982-
983 \sa year(), month(), day(), isValid()-
984*/-
985void QDate::getDate(int *year, int *month, int *day) const-
986{-
987 ParsedDate pd = { 0, 0, 0 };-
988 if (isValid())
isValid()Description
TRUEevaluated 13951235 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
3-13951235
989 pd = getDateFromJulianDay(jd);
executed 13956030 times by 101 tests: pd = getDateFromJulianDay(jd);
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13956030
990-
991 if (year)
yearDescription
TRUEevaluated 13956030 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDateTime
3-13956030
992 *year = pd.year;
executed 13956030 times by 101 tests: *year = pd.year;
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13956030
993 if (month)
monthDescription
TRUEevaluated 13955044 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDateTime
3-13955044
994 *month = pd.month;
executed 13956030 times by 101 tests: *month = pd.month;
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13956030
995 if (day)
dayDescription
TRUEevaluated 13942777 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDateTime
3-13942777
996 *day = pd.day;
executed 13954660 times by 101 tests: *day = pd.day;
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13954660
997}
executed 13941005 times by 101 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13941005
998-
999#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)-
1000/*!-
1001 \overload-
1002 \internal-
1003*/-
1004void QDate::getDate(int *year, int *month, int *day)-
1005{-
1006 qAsConst(*this).getDate(year, month, day);-
1007}
executed 13947892 times by 101 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13947892
1008#endif // < Qt 6-
1009-
1010/*!-
1011 Returns a QDate object containing a date \a ndays later than the-
1012 date of this object (or earlier if \a ndays is negative).-
1013-
1014 Returns a null date if the current date is invalid or the new date is-
1015 out of range.-
1016-
1017 \sa addMonths(), addYears(), daysTo()-
1018*/-
1019-
1020QDate QDate::addDays(qint64 ndays) const-
1021{-
1022 if (isNull())
isNull()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 630822 times by 13 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
  • tst_QTimeZone
1-630822
1023 return QDate();
executed 1 time by 1 test: return QDate();
Executed by:
  • tst_QDate
1
1024-
1025 // Due to limits on minJd() and maxJd() we know that any overflow-
1026 // will be invalid and caught by fromJulianDay().-
1027 return fromJulianDay(jd + ndays);
executed 630822 times by 13 tests: return fromJulianDay(jd + ndays);
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
  • tst_QTimeZone
630822
1028}-
1029-
1030/*!-
1031 Returns a QDate object containing a date \a nmonths later than the-
1032 date of this object (or earlier if \a nmonths is negative).-
1033-
1034 \note If the ending day/month combination does not exist in the-
1035 resulting month/year, this function will return a date that is the-
1036 latest valid date.-
1037-
1038 \sa addDays(), addYears()-
1039*/-
1040-
1041QDate QDate::addMonths(int nmonths) const-
1042{-
1043 if (!isValid())
!isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 172 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
1-172
1044 return QDate();
executed 1 time by 1 test: return QDate();
Executed by:
  • tst_QDate
1
1045 if (!nmonths)
!nmonthsDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 168 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
4-168
1046 return *this;
executed 4 times by 1 test: return *this;
Executed by:
  • tst_QDateTime
4
1047-
1048 int old_y, y, m, d;-
1049 {-
1050 const ParsedDate pd = getDateFromJulianDay(jd);-
1051 y = pd.year;-
1052 m = pd.month;-
1053 d = pd.day;-
1054 }-
1055 old_y = y;-
1056-
1057 bool increasing = nmonths > 0;-
1058-
1059 while (nmonths != 0) {
nmonths != 0Description
TRUEevaluated 188 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEevaluated 168 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
168-188
1060 if (nmonths < 0 && nmonths + 12 <= 0) {
nmonths < 0Description
TRUEevaluated 97 times by 3 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 91 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
nmonths + 12 <= 0Description
TRUEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 82 times by 3 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
15-97
1061 y--;-
1062 nmonths+=12;-
1063 } else if (nmonths < 0) {
executed 15 times by 2 tests: end of block
Executed by:
  • tst_QDate
  • tst_QDateTime
nmonths < 0Description
TRUEevaluated 82 times by 3 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 91 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
15-91
1064 m+= nmonths;-
1065 nmonths = 0;-
1066 if (m <= 0) {
m <= 0Description
TRUEevaluated 49 times by 3 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 33 times by 3 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
33-49
1067 --y;-
1068 m += 12;-
1069 }
executed 49 times by 3 tests: end of block
Executed by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
49
1070 } else if (nmonths - 12 >= 0) {
executed 82 times by 3 tests: end of block
Executed by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
nmonths - 12 >= 0Description
TRUEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 75 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
16-82
1071 y++;-
1072 nmonths -= 12;-
1073 } else if (m == 12) {
executed 16 times by 2 tests: end of block
Executed by:
  • tst_QDate
  • tst_QDateTime
m == 12Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 73 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
2-73
1074 y++;-
1075 m = 0;-
1076 } else {
executed 2 times by 1 test: end of block
Executed by:
  • tst_QDate
2
1077 m += nmonths;-
1078 nmonths = 0;-
1079 if (m > 12) {
m > 12Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 72 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
1-72
1080 ++y;-
1081 m -= 12;-
1082 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QDate
1
1083 }
executed 73 times by 4 tests: end of block
Executed by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
73
1084 }-
1085-
1086 // was there a sign change?-
1087 if ((old_y > 0 && y <= 0) ||
old_y > 0Description
TRUEevaluated 165 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDate
y <= 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 163 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
2-165
1088 (old_y < 0 && y >= 0))
old_y < 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 163 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
y >= 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
1-163
1089 // yes, adjust the date by +1 or -1 years-
1090 y += increasing ? +1 : -1;
executed 4 times by 1 test: y += increasing ? +1 : -1;
Executed by:
  • tst_QDate
increasingDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
2-4
1091-
1092 return fixedDate(y, m, d);
executed 168 times by 4 tests: return fixedDate(y, m, d);
Executed by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
168
1093}-
1094-
1095/*!-
1096 Returns a QDate object containing a date \a nyears later than the-
1097 date of this object (or earlier if \a nyears is negative).-
1098-
1099 \note If the ending day/month combination does not exist in the-
1100 resulting year (i.e., if the date was Feb 29 and the final year is-
1101 not a leap year), this function will return a date that is the-
1102 latest valid date (that is, Feb 28).-
1103-
1104 \sa addDays(), addMonths()-
1105*/-
1106-
1107QDate QDate::addYears(int nyears) const-
1108{-
1109 if (!isValid())
!isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 120 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
1-120
1110 return QDate();
executed 1 time by 1 test: return QDate();
Executed by:
  • tst_QDate
1
1111-
1112 ParsedDate pd = getDateFromJulianDay(jd);-
1113-
1114 int old_y = pd.year;-
1115 pd.year += nyears;-
1116-
1117 // was there a sign change?-
1118 if ((old_y > 0 && pd.year <= 0) ||
old_y > 0Description
TRUEevaluated 99 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEevaluated 21 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
pd.year <= 0Description
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 91 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
8-99
1119 (old_y < 0 && pd.year >= 0))
old_y < 0Description
TRUEevaluated 21 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 91 times by 4 tests
Evaluated by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
pd.year >= 0Description
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 13 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
8-91
1120 // yes, adjust the date by +1 or -1 years-
1121 pd.year += nyears > 0 ? +1 : -1;
executed 16 times by 2 tests: pd.year += nyears > 0 ? +1 : -1;
Executed by:
  • tst_QDate
  • tst_QDateTime
nyears > 0Description
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
8-16
1122-
1123 return fixedDate(pd.year, pd.month, pd.day);
executed 120 times by 4 tests: return fixedDate(pd.year, pd.month, pd.day);
Executed by:
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
120
1124}-
1125-
1126/*!-
1127 Returns the number of days from this date to \a d (which is-
1128 negative if \a d is earlier than this date).-
1129-
1130 Returns 0 if either date is invalid.-
1131-
1132 Example:-
1133 \snippet code/src_corelib_tools_qdatetime.cpp 0-
1134-
1135 \sa addDays()-
1136*/-
1137-
1138qint64 QDate::daysTo(const QDate &d) const-
1139{-
1140 if (isNull() || d.isNull())
isNull()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 18592 times by 13 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
d.isNull()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 18591 times by 13 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
1-18592
1141 return 0;
executed 2 times by 1 test: return 0;
Executed by:
  • tst_QDate
2
1142-
1143 // Due to limits on minJd() and maxJd() we know this will never overflow-
1144 return d.jd - jd;
executed 18591 times by 13 tests: return d.jd - jd;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
18591
1145}-
1146-
1147-
1148/*!-
1149 \fn bool QDate::operator==(const QDate &d) const-
1150-
1151 Returns \c true if this date is equal to \a d; otherwise returns-
1152 false.-
1153-
1154*/-
1155-
1156/*!-
1157 \fn bool QDate::operator!=(const QDate &d) const-
1158-
1159 Returns \c true if this date is different from \a d; otherwise-
1160 returns \c false.-
1161*/-
1162-
1163/*!-
1164 \fn bool QDate::operator<(const QDate &d) const-
1165-
1166 Returns \c true if this date is earlier than \a d; otherwise returns-
1167 false.-
1168*/-
1169-
1170/*!-
1171 \fn bool QDate::operator<=(const QDate &d) const-
1172-
1173 Returns \c true if this date is earlier than or equal to \a d;-
1174 otherwise returns \c false.-
1175*/-
1176-
1177/*!-
1178 \fn bool QDate::operator>(const QDate &d) const-
1179-
1180 Returns \c true if this date is later than \a d; otherwise returns-
1181 false.-
1182*/-
1183-
1184/*!-
1185 \fn bool QDate::operator>=(const QDate &d) const-
1186-
1187 Returns \c true if this date is later than or equal to \a d;-
1188 otherwise returns \c false.-
1189*/-
1190-
1191/*!-
1192 \fn QDate::currentDate()-
1193 Returns the current date, as reported by the system clock.-
1194-
1195 \sa QTime::currentTime(), QDateTime::currentDateTime()-
1196*/-
1197-
1198#ifndef QT_NO_DATESTRING-
1199/*!-
1200 \fn QDate QDate::fromString(const QString &string, Qt::DateFormat format)-
1201-
1202 Returns the QDate represented by the \a string, using the-
1203 \a format given, or an invalid date if the string cannot be-
1204 parsed.-
1205-
1206 Note for Qt::TextDate: It is recommended that you use the-
1207 English short month names (e.g. "Jan"). Although localized month-
1208 names can also be used, they depend on the user's locale settings.-
1209-
1210 \sa toString(), QLocale::toDate()-
1211*/-
1212QDate QDate::fromString(const QString& string, Qt::DateFormat format)-
1213{-
1214 if (string.isEmpty())
string.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 111 times by 5 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
2-111
1215 return QDate();
executed 2 times by 1 test: return QDate();
Executed by:
  • tst_QDate
2
1216-
1217 switch (format) {-
1218 case Qt::SystemLocaleDate:
never executed: case Qt::SystemLocaleDate:
0
1219 case Qt::SystemLocaleShortDate:
never executed: case Qt::SystemLocaleShortDate:
0
1220 return QLocale::system().toDate(string, QLocale::ShortFormat);
never executed: return QLocale::system().toDate(string, QLocale::ShortFormat);
0
1221 case Qt::SystemLocaleLongDate:
never executed: case Qt::SystemLocaleLongDate:
0
1222 return QLocale::system().toDate(string, QLocale::LongFormat);
never executed: return QLocale::system().toDate(string, QLocale::LongFormat);
0
1223 case Qt::LocaleDate:
never executed: case Qt::LocaleDate:
0
1224 case Qt::DefaultLocaleShortDate:
never executed: case Qt::DefaultLocaleShortDate:
0
1225 return QLocale().toDate(string, QLocale::ShortFormat);
never executed: return QLocale().toDate(string, QLocale::ShortFormat);
0
1226 case Qt::DefaultLocaleLongDate:
never executed: case Qt::DefaultLocaleLongDate:
0
1227 return QLocale().toDate(string, QLocale::LongFormat);
never executed: return QLocale().toDate(string, QLocale::LongFormat);
0
1228 case Qt::RFC2822Date:
executed 21 times by 1 test: case Qt::RFC2822Date:
Executed by:
  • tst_QDate
21
1229 return rfcDateImpl(string).date;
executed 21 times by 1 test: return rfcDateImpl(string).date;
Executed by:
  • tst_QDate
21
1230 default:
never executed: default:
0
1231#ifndef QT_NO_TEXTDATE-
1232 case Qt::TextDate: {
executed 14 times by 1 test: case Qt::TextDate:
Executed by:
  • tst_QDate
14
1233 QVector<QStringRef> parts = string.splitRef(QLatin1Char(' '), QString::SkipEmptyParts);-
1234-
1235 if (parts.count() != 4)
parts.count() != 4Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_QDate
1-13
1236 return QDate();
executed 1 time by 1 test: return QDate();
Executed by:
  • tst_QDate
1
1237-
1238 QStringRef monthName = parts.at(1);-
1239 const int month = fromShortMonthName(monthName);-
1240 if (month == -1) {
month == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QDate
1-12
1241 // Month name matches neither English nor other localised name.-
1242 return QDate();
executed 1 time by 1 test: return QDate();
Executed by:
  • tst_QDate
1
1243 }-
1244-
1245 bool ok = false;-
1246 int year = parts.at(3).toInt(&ok);-
1247 if (!ok)
!okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QDate
1-11
1248 return QDate();
executed 1 time by 1 test: return QDate();
Executed by:
  • tst_QDate
1
1249-
1250 return QDate(year, month, parts.at(2).toInt());
executed 11 times by 1 test: return QDate(year, month, parts.at(2).toInt());
Executed by:
  • tst_QDate
11
1251 }-
1252#endif // QT_NO_TEXTDATE-
1253 case Qt::ISODate: {
executed 76 times by 5 tests: case Qt::ISODate:
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
76
1254 // Semi-strict parsing, must be long enough and have non-numeric separators-
1255 if (string.size() < 10 || string.at(4).isDigit() || string.at(7).isDigit()
string.size() < 10Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QVariant
FALSEevaluated 75 times by 5 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
string.at(4).isDigit()Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
FALSEevaluated 69 times by 5 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
string.at(7).isDigit()Description
TRUEnever evaluated
FALSEevaluated 69 times by 5 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
0-75
1256 || (string.size() > 10 && string.at(10).isDigit())) {
string.size() > 10Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 66 times by 5 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
string.at(10).isDigit()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDate
1-66
1257 return QDate();
executed 8 times by 3 tests: return QDate();
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QVariant
8
1258 }-
1259 const int year = string.midRef(0, 4).toInt();-
1260 if (year <= 0 || year > 9999)
year <= 0Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QVariant
FALSEevaluated 64 times by 5 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
year > 9999Description
TRUEnever evaluated
FALSEevaluated 64 times by 5 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
0-64
1261 return QDate();
executed 4 times by 2 tests: return QDate();
Executed by:
  • tst_QDate
  • tst_QVariant
4
1262 return QDate(year, string.midRef(5, 2).toInt(), string.midRef(8, 2).toInt());
executed 64 times by 5 tests: return QDate(year, string.midRef(5, 2).toInt(), string.midRef(8, 2).toInt());
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
64
1263 }-
1264 }-
1265 return QDate();
never executed: return QDate();
0
1266}-
1267-
1268/*!-
1269 \fn QDate::fromString(const QString &string, const QString &format)-
1270-
1271 Returns the QDate represented by the \a string, using the \a-
1272 format given, or an invalid date if the string cannot be parsed.-
1273-
1274 These expressions may be used for the format:-
1275-
1276 \table-
1277 \header \li Expression \li Output-
1278 \row \li d \li The day as a number without a leading zero (1 to 31)-
1279 \row \li dd \li The day as a number with a leading zero (01 to 31)-
1280 \row \li ddd-
1281 \li The abbreviated localized day name (e.g. 'Mon' to 'Sun').-
1282 Uses the system locale to localize the name, i.e. QLocale::system().-
1283 \row \li dddd-
1284 \li The long localized day name (e.g. 'Monday' to 'Sunday').-
1285 Uses the system locale to localize the name, i.e. QLocale::system().-
1286 \row \li M \li The month as a number without a leading zero (1 to 12)-
1287 \row \li MM \li The month as a number with a leading zero (01 to 12)-
1288 \row \li MMM-
1289 \li The abbreviated localized month name (e.g. 'Jan' to 'Dec').-
1290 Uses the system locale to localize the name, i.e. QLocale::system().-
1291 \row \li MMMM-
1292 \li The long localized month name (e.g. 'January' to 'December').-
1293 Uses the system locale to localize the name, i.e. QLocale::system().-
1294 \row \li yy \li The year as two digit number (00 to 99)-
1295 \row \li yyyy \li The year as four digit number. If the year is negative,-
1296 a minus sign is prepended in addition.-
1297 \endtable-
1298-
1299 All other input characters will be treated as text. Any sequence-
1300 of characters that are enclosed in single quotes will also be-
1301 treated as text and will not be used as an expression. For example:-
1302-
1303 \snippet code/src_corelib_tools_qdatetime.cpp 1-
1304-
1305 If the format is not satisfied, an invalid QDate is returned. The-
1306 expressions that don't expect leading zeroes (d, M) will be-
1307 greedy. This means that they will use two digits even if this-
1308 will put them outside the accepted range of values and leaves too-
1309 few digits for other sections. For example, the following format-
1310 string could have meant January 30 but the M will grab two-
1311 digits, resulting in an invalid date:-
1312-
1313 \snippet code/src_corelib_tools_qdatetime.cpp 2-
1314-
1315 For any field that is not represented in the format the following-
1316 defaults are used:-
1317-
1318 \table-
1319 \header \li Field \li Default value-
1320 \row \li Year \li 1900-
1321 \row \li Month \li 1-
1322 \row \li Day \li 1-
1323 \endtable-
1324-
1325 The following examples demonstrate the default values:-
1326-
1327 \snippet code/src_corelib_tools_qdatetime.cpp 3-
1328-
1329 \sa toString(), QDateTime::fromString(), QTime::fromString(),-
1330 QLocale::toDate()-
1331*/-
1332-
1333QDate QDate::fromString(const QString &string, const QString &format)-
1334{-
1335 QDate date;-
1336#ifndef QT_BOOTSTRAPPED-
1337 QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString);-
1338 if (dt.parseFormat(format))
dt.parseFormat(format)Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_QDate
FALSEnever evaluated
0-44
1339 dt.fromString(string, &date, 0);
executed 44 times by 1 test: dt.fromString(string, &date, 0);
Executed by:
  • tst_QDate
44
1340#else-
1341 Q_UNUSED(string);-
1342 Q_UNUSED(format);-
1343#endif-
1344 return date;
executed 44 times by 1 test: return date;
Executed by:
  • tst_QDate
44
1345}-
1346#endif // QT_NO_DATESTRING-
1347-
1348/*!-
1349 \overload-
1350-
1351 Returns \c true if the specified date (\a year, \a month, and \a-
1352 day) is valid; otherwise returns \c false.-
1353-
1354 Example:-
1355 \snippet code/src_corelib_tools_qdatetime.cpp 4-
1356-
1357 \sa isNull(), setDate()-
1358*/-
1359-
1360bool QDate::isValid(int year, int month, int day)-
1361{-
1362 // there is no year 0 in the Gregorian calendar-
1363 if (year == 0)
year == 0Description
TRUEevaluated 143 times by 4 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QTime
FALSEevaluated 21594977 times by 106 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
143-21594977
1364 return false;
executed 143 times by 4 tests: return false;
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QTime
143
1365-
1366 return (day > 0 && month > 0 && month <= 12) &&
executed 21588267 times by 106 tests: return (day > 0 && month > 0 && month <= 12) && (day <= monthDays[month] || (day == 29 && month == 2 && isLeapYear(year)));
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
21588267
1367 (day <= monthDays[month] || (day == 29 && month == 2 && isLeapYear(year)));
executed 21588267 times by 106 tests: return (day > 0 && month > 0 && month <= 12) && (day <= monthDays[month] || (day == 29 && month == 2 && isLeapYear(year)));
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
21588267
1368}-
1369-
1370/*!-
1371 \fn bool QDate::isLeapYear(int year)-
1372-
1373 Returns \c true if the specified \a year is a leap year; otherwise-
1374 returns \c false.-
1375*/-
1376-
1377bool QDate::isLeapYear(int y)-
1378{-
1379 // No year 0 in Gregorian calendar, so -1, -5, -9 etc are leap years-
1380 if ( y < 1)
y < 1Description
TRUEevaluated 9596 times by 1 test
Evaluated by:
  • tst_QDate
FALSEevaluated 27921 times by 9 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QStyleSheetStyle
  • tst_QTimeZone
9596-27921
1381 ++y;
executed 9596 times by 1 test: ++y;
Executed by:
  • tst_QDate
9596
1382-
1383 return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
executed 37517 times by 9 tests: return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QStyleSheetStyle
  • tst_QTimeZone
37517
1384}-
1385-
1386/*! \fn static QDate QDate::fromJulianDay(qint64 jd)-
1387-
1388 Converts the Julian day \a jd to a QDate.-
1389-
1390 \sa toJulianDay()-
1391*/-
1392-
1393/*! \fn int QDate::toJulianDay() const-
1394-
1395 Converts the date to a Julian day.-
1396-
1397 \sa fromJulianDay()-
1398*/-
1399-
1400/*****************************************************************************-
1401 QTime member functions-
1402 *****************************************************************************/-
1403-
1404/*!-
1405 \class QTime-
1406 \inmodule QtCore-
1407 \reentrant-
1408-
1409 \brief The QTime class provides clock time functions.-
1410-
1411-
1412 A QTime object contains a clock time, i.e. the number of hours,-
1413 minutes, seconds, and milliseconds since midnight. It can read the-
1414 current time from the system clock and measure a span of elapsed-
1415 time. It provides functions for comparing times and for-
1416 manipulating a time by adding a number of milliseconds.-
1417-
1418 QTime uses the 24-hour clock format; it has no concept of AM/PM.-
1419 Unlike QDateTime, QTime knows nothing about time zones or-
1420 daylight-saving time (DST).-
1421-
1422 A QTime object is typically created either by giving the number-
1423 of hours, minutes, seconds, and milliseconds explicitly, or by-
1424 using the static function currentTime(), which creates a QTime-
1425 object that contains the system's local time. Note that the-
1426 accuracy depends on the accuracy of the underlying operating-
1427 system; not all systems provide 1-millisecond accuracy.-
1428-
1429 The hour(), minute(), second(), and msec() functions provide-
1430 access to the number of hours, minutes, seconds, and milliseconds-
1431 of the time. The same information is provided in textual format by-
1432 the toString() function.-
1433-
1434 QTime provides a full set of operators to compare two QTime-
1435 objects. QTime A is considered smaller than QTime B if A is-
1436 earlier than B.-
1437-
1438 The addSecs() and addMSecs() functions provide the time a given-
1439 number of seconds or milliseconds later than a given time.-
1440 Correspondingly, the number of seconds or milliseconds-
1441 between two times can be found using secsTo() or msecsTo().-
1442-
1443 QTime can be used to measure a span of elapsed time using the-
1444 start(), restart(), and elapsed() functions.-
1445-
1446 \sa QDate, QDateTime-
1447*/-
1448-
1449/*!-
1450 \fn QTime::QTime()-
1451-
1452 Constructs a null time object. A null time can be a QTime(0, 0, 0, 0)-
1453 (i.e., midnight) object, except that isNull() returns \c true and isValid()-
1454 returns \c false.-
1455-
1456 \sa isNull(), isValid()-
1457*/-
1458-
1459/*!-
1460 Constructs a time with hour \a h, minute \a m, seconds \a s and-
1461 milliseconds \a ms.-
1462-
1463 \a h must be in the range 0 to 23, \a m and \a s must be in the-
1464 range 0 to 59, and \a ms must be in the range 0 to 999.-
1465-
1466 \sa isValid()-
1467*/-
1468-
1469QTime::QTime(int h, int m, int s, int ms)-
1470{-
1471 setHMS(h, m, s, ms);-
1472}
executed 20948141 times by 107 tests: end of block
Executed by:
  • tst_Collections
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • ...
20948141
1473-
1474-
1475/*!-
1476 \fn bool QTime::isNull() const-
1477-
1478 Returns \c true if the time is null (i.e., the QTime object was-
1479 constructed using the default constructor); otherwise returns-
1480 false. A null time is also an invalid time.-
1481-
1482 \sa isValid()-
1483*/-
1484-
1485/*!-
1486 Returns \c true if the time is valid; otherwise returns \c false. For example,-
1487 the time 23:30:55.746 is valid, but 24:12:30 is invalid.-
1488-
1489 \sa isNull()-
1490*/-
1491-
1492bool QTime::isValid() const-
1493{-
1494 return mds > NullTime && mds < MSECS_PER_DAY;
executed 83770922 times by 109 tests: return mds > NullTime && mds < MSECS_PER_DAY;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • 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
  • tst_QDir
  • tst_QDnsLookup
  • ...
83770922
1495}-
1496-
1497-
1498/*!-
1499 Returns the hour part (0 to 23) of the time.-
1500-
1501 Returns -1 if the time is invalid.-
1502-
1503 \sa minute(), second(), msec()-
1504*/-
1505-
1506int QTime::hour() const-
1507{-
1508 if (!isValid())
!isValid()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 13963461 times by 103 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
4-13963461
1509 return -1;
executed 4 times by 1 test: return -1;
Executed by:
  • tst_QTime
4
1510-
1511 return ds() / MSECS_PER_HOUR;
executed 13972447 times by 103 tests: return ds() / MSECS_PER_HOUR;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
13972447
1512}-
1513-
1514/*!-
1515 Returns the minute part (0 to 59) of the time.-
1516-
1517 Returns -1 if the time is invalid.-
1518-
1519 \sa hour(), second(), msec()-
1520*/-
1521-
1522int QTime::minute() const-
1523{-
1524 if (!isValid())
!isValid()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 13965934 times by 103 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
4-13965934
1525 return -1;
executed 4 times by 1 test: return -1;
Executed by:
  • tst_QTime
4
1526-
1527 return (ds() % MSECS_PER_HOUR) / MSECS_PER_MIN;
executed 13966387 times by 103 tests: return (ds() % MSECS_PER_HOUR) / MSECS_PER_MIN;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
13966387
1528}-
1529-
1530/*!-
1531 Returns the second part (0 to 59) of the time.-
1532-
1533 Returns -1 if the time is invalid.-
1534-
1535 \sa hour(), minute(), msec()-
1536*/-
1537-
1538int QTime::second() const-
1539{-
1540 if (!isValid())
!isValid()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 13964385 times by 103 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
4-13964385
1541 return -1;
executed 4 times by 1 test: return -1;
Executed by:
  • tst_QTime
4
1542-
1543 return (ds() / 1000)%SECS_PER_MIN;
executed 13948402 times by 103 tests: return (ds() / 1000)%SECS_PER_MIN;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
13948402
1544}-
1545-
1546/*!-
1547 Returns the millisecond part (0 to 999) of the time.-
1548-
1549 Returns -1 if the time is invalid.-
1550-
1551 \sa hour(), minute(), second()-
1552*/-
1553-
1554int QTime::msec() const-
1555{-
1556 if (!isValid())
!isValid()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 13962710 times by 103 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
3-13962710
1557 return -1;
executed 3 times by 1 test: return -1;
Executed by:
  • tst_QTime
3
1558-
1559 return ds() % 1000;
executed 13960494 times by 103 tests: return ds() % 1000;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
13960494
1560}-
1561-
1562#ifndef QT_NO_DATESTRING-
1563/*!-
1564 \overload-
1565-
1566 Returns the time as a string. The \a format parameter determines-
1567 the format of the string.-
1568-
1569 If \a format is Qt::TextDate, the string format is HH:mm:ss;-
1570 e.g. 1 second before midnight would be "23:59:59".-
1571-
1572 If \a format is Qt::ISODate, the string format corresponds to the-
1573 ISO 8601 extended specification for representations of dates,-
1574 which is also HH:mm:ss.-
1575-
1576 If the \a format is Qt::SystemLocaleShortDate or-
1577 Qt::SystemLocaleLongDate, the string format depends on the locale-
1578 settings of the system. Identical to calling-
1579 QLocale::system().toString(time, QLocale::ShortFormat) or-
1580 QLocale::system().toString(time, QLocale::LongFormat).-
1581-
1582 If the \a format is Qt::DefaultLocaleShortDate or-
1583 Qt::DefaultLocaleLongDate, the string format depends on the-
1584 default application locale. This is the locale set with-
1585 QLocale::setDefault(), or the system locale if no default locale-
1586 has been set. Identical to calling-
1587-
1588 \l {QLocale::toString()}{QLocale().toString(time, QLocale::ShortFormat)} or-
1589 \l {QLocale::toString()}{QLocale().toString(time, QLocale::LongFormat)}.-
1590-
1591 If the \a format is Qt::RFC2822Date, the string is formatted in-
1592 an \l{RFC 2822} compatible way. An example of this formatting is-
1593 "23:59:20".-
1594-
1595 If the time is invalid, an empty string will be returned.-
1596-
1597 \sa fromString(), QDate::toString(), QDateTime::toString(), QLocale::toString()-
1598*/-
1599-
1600QString QTime::toString(Qt::DateFormat format) const-
1601{-
1602 if (!isValid())
!isValid()Description
TRUEnever evaluated
FALSEevaluated 452 times by 8 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QFile
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QTime
  • tst_QVariant
  • tst_qmakelib
0-452
1603 return QString();
never executed: return QString();
0
1604-
1605 switch (format) {-
1606 case Qt::SystemLocaleDate:
never executed: case Qt::SystemLocaleDate:
0
1607 case Qt::SystemLocaleShortDate:
executed 2 times by 1 test: case Qt::SystemLocaleShortDate:
Executed by:
  • tst_QTime
2
1608 return QLocale::system().toString(*this, QLocale::ShortFormat);
executed 2 times by 1 test: return QLocale::system().toString(*this, QLocale::ShortFormat);
Executed by:
  • tst_QTime
2
1609 case Qt::SystemLocaleLongDate:
executed 2 times by 1 test: case Qt::SystemLocaleLongDate:
Executed by:
  • tst_QTime
2
1610 return QLocale::system().toString(*this, QLocale::LongFormat);
executed 2 times by 1 test: return QLocale::system().toString(*this, QLocale::LongFormat);
Executed by:
  • tst_QTime
2
1611 case Qt::LocaleDate:
never executed: case Qt::LocaleDate:
0
1612 case Qt::DefaultLocaleShortDate:
executed 2 times by 1 test: case Qt::DefaultLocaleShortDate:
Executed by:
  • tst_QTime
2
1613 return QLocale().toString(*this, QLocale::ShortFormat);
executed 2 times by 1 test: return QLocale().toString(*this, QLocale::ShortFormat);
Executed by:
  • tst_QTime
2
1614 case Qt::DefaultLocaleLongDate:
executed 2 times by 1 test: case Qt::DefaultLocaleLongDate:
Executed by:
  • tst_QTime
2
1615 return QLocale().toString(*this, QLocale::LongFormat);
executed 2 times by 1 test: return QLocale().toString(*this, QLocale::LongFormat);
Executed by:
  • tst_QTime
2
1616 case Qt::RFC2822Date:
executed 1 time by 1 test: case Qt::RFC2822Date:
Executed by:
  • tst_QTime
1
1617 case Qt::ISODate:
executed 32 times by 5 tests: case Qt::ISODate:
Executed by:
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QTime
  • tst_QVariant
32
1618 case Qt::TextDate:
executed 411 times by 5 tests: case Qt::TextDate:
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QFile
  • tst_QTime
  • tst_qmakelib
411
1619 default:
never executed: default:
0
1620 return QString::asprintf("%02d:%02d:%02d", hour(), minute(), second());
executed 444 times by 8 tests: return QString::asprintf("%02d:%02d:%02d", hour(), minute(), second());
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QFile
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QTime
  • tst_QVariant
  • tst_qmakelib
444
1621 }-
1622}-
1623-
1624/*!-
1625 Returns the time as a string. The \a format parameter determines-
1626 the format of the result string.-
1627-
1628 These expressions may be used:-
1629-
1630 \table-
1631 \header \li Expression \li Output-
1632 \row \li h-
1633 \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)-
1634 \row \li hh-
1635 \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)-
1636 \row \li H-
1637 \li the hour without a leading zero (0 to 23, even with AM/PM display)-
1638 \row \li HH-
1639 \li the hour with a leading zero (00 to 23, even with AM/PM display)-
1640 \row \li m \li the minute without a leading zero (0 to 59)-
1641 \row \li mm \li the minute with a leading zero (00 to 59)-
1642 \row \li s \li the second without a leading zero (0 to 59)-
1643 \row \li ss \li the second with a leading zero (00 to 59)-
1644 \row \li z \li the milliseconds without leading zeroes (0 to 999)-
1645 \row \li zzz \li the milliseconds with leading zeroes (000 to 999)-
1646 \row \li AP or A-
1647 \li use AM/PM display. \e A/AP will be replaced by either-
1648 QLocale::amText() or QLocale::pmText().-
1649 \row \li ap or a-
1650 \li use am/pm display. \e a/ap will be replaced by a lower-case version of-
1651 QLocale::amText() or QLocale::pmText().-
1652 \row \li t \li the timezone (for example "CEST")-
1653 \endtable-
1654-
1655 All other input characters will be ignored. Any sequence of characters that-
1656 are enclosed in single quotes will be treated as text and not be used as an-
1657 expression. Two consecutive single quotes ("''") are replaced by a singlequote-
1658 in the output. Formats without separators (e.g. "HHmm") are currently not supported.-
1659-
1660 Example format strings (assuming that the QTime is 14:13:09.042 and the system-
1661 locale is \c{en_US})-
1662-
1663 \table-
1664 \header \li Format \li Result-
1665 \row \li hh:mm:ss.zzz \li 14:13:09.042-
1666 \row \li h:m:s ap \li 2:13:9 pm-
1667 \row \li H:m:s a \li 14:13:9 pm-
1668 \endtable-
1669-
1670 If the time is invalid, an empty string will be returned.-
1671 If \a format is empty, the default format "hh:mm:ss" is used.-
1672-
1673 \sa fromString(), QDate::toString(), QDateTime::toString(), QLocale::toString()-
1674*/-
1675QString QTime::toString(const QString& format) const-
1676{-
1677 return QLocale::system().toString(*this, format);
executed 14782 times by 7 tests: return QLocale::system().toString(*this, format);
Executed by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QTime
  • tst_QVariant
14782
1678}-
1679#endif //QT_NO_DATESTRING-
1680/*!-
1681 Sets the time to hour \a h, minute \a m, seconds \a s and-
1682 milliseconds \a ms.-
1683-
1684 \a h must be in the range 0 to 23, \a m and \a s must be in the-
1685 range 0 to 59, and \a ms must be in the range 0 to 999.-
1686 Returns \c true if the set time is valid; otherwise returns \c false.-
1687-
1688 \sa isValid()-
1689*/-
1690-
1691bool QTime::setHMS(int h, int m, int s, int ms)-
1692{-
1693#if defined(Q_OS_WINCE)-
1694 startTick = NullTime;-
1695#endif-
1696 if (!isValid(h,m,s,ms)) {
!isValid(h,m,s,ms)Description
TRUEevaluated 238 times by 5 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QNetworkCookie
  • tst_QTime
FALSEevaluated 20948610 times by 107 tests
Evaluated by:
  • tst_Collections
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • ...
238-20948610
1697 mds = NullTime; // make this invalid-
1698 return false;
executed 238 times by 5 tests: return false;
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QNetworkCookie
  • tst_QTime
238
1699 }-
1700 mds = (h*SECS_PER_HOUR + m*SECS_PER_MIN + s)*1000 + ms;-
1701 return true;
executed 20947141 times by 107 tests: return true;
Executed by:
  • tst_Collections
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • ...
20947141
1702}-
1703-
1704/*!-
1705 Returns a QTime object containing a time \a s seconds later-
1706 than the time of this object (or earlier if \a s is negative).-
1707-
1708 Note that the time will wrap if it passes midnight.-
1709-
1710 Returns a null time if this time is invalid.-
1711-
1712 Example:-
1713-
1714 \snippet code/src_corelib_tools_qdatetime.cpp 5-
1715-
1716 \sa addMSecs(), secsTo(), QDateTime::addSecs()-
1717*/-
1718-
1719QTime QTime::addSecs(int s) const-
1720{-
1721 s %= SECS_PER_DAY;-
1722 return addMSecs(s * 1000);
executed 8 times by 3 tests: return addMSecs(s * 1000);
Executed by:
  • tst_QDateTime
  • tst_QItemDelegate
  • tst_QTime
8
1723}-
1724-
1725/*!-
1726 Returns the number of seconds from this time to \a t.-
1727 If \a t is earlier than this time, the number of seconds returned-
1728 is negative.-
1729-
1730 Because QTime measures time within a day and there are 86400-
1731 seconds in a day, the result is always between -86400 and 86400.-
1732-
1733 secsTo() does not take into account any milliseconds.-
1734-
1735 Returns 0 if either time is invalid.-
1736-
1737 \sa addSecs(), QDateTime::secsTo()-
1738*/-
1739-
1740int QTime::secsTo(const QTime &t) const-
1741{-
1742 if (!isValid() || !t.isValid())
!isValid()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTime
!t.isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QTime
1-9
1743 return 0;
executed 3 times by 1 test: return 0;
Executed by:
  • tst_QTime
3
1744-
1745 // Truncate milliseconds as we do not want to consider them.-
1746 int ourSeconds = ds() / 1000;-
1747 int theirSeconds = t.ds() / 1000;-
1748 return theirSeconds - ourSeconds;
executed 8 times by 1 test: return theirSeconds - ourSeconds;
Executed by:
  • tst_QTime
8
1749}-
1750-
1751/*!-
1752 Returns a QTime object containing a time \a ms milliseconds later-
1753 than the time of this object (or earlier if \a ms is negative).-
1754-
1755 Note that the time will wrap if it passes midnight. See addSecs()-
1756 for an example.-
1757-
1758 Returns a null time if this time is invalid.-
1759-
1760 \sa addSecs(), msecsTo(), QDateTime::addMSecs()-
1761*/-
1762-
1763QTime QTime::addMSecs(int ms) const-
1764{-
1765 QTime t;-
1766 if (isValid()) {
isValid()Description
TRUEevaluated 214 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QTime
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTime
1-214
1767 if (ms < 0) {
ms < 0Description
TRUEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkCookie
  • tst_QTime
FALSEevaluated 174 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QTime
40-174
1768 // %,/ not well-defined for -ve, so always work with +ve.-
1769 int negdays = (MSECS_PER_DAY - ms) / MSECS_PER_DAY;-
1770 t.mds = (ds() + ms + negdays * MSECS_PER_DAY) % MSECS_PER_DAY;-
1771 } else {
executed 40 times by 3 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkCookie
  • tst_QTime
40
1772 t.mds = (ds() + ms) % MSECS_PER_DAY;-
1773 }
executed 174 times by 4 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QTime
174
1774 }-
1775#if defined(Q_OS_WINCE)-
1776 if (startTick > NullTime)-
1777 t.startTick = (startTick + ms) % MSECS_PER_DAY;-
1778#endif-
1779 return t;
executed 215 times by 4 tests: return t;
Executed by:
  • tst_QDateTime
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QTime
215
1780}-
1781-
1782/*!-
1783 Returns the number of milliseconds from this time to \a t.-
1784 If \a t is earlier than this time, the number of milliseconds returned-
1785 is negative.-
1786-
1787 Because QTime measures time within a day and there are 86400-
1788 seconds in a day, the result is always between -86400000 and-
1789 86400000 ms.-
1790-
1791 Returns 0 if either time is invalid.-
1792-
1793 \sa secsTo(), addMSecs(), QDateTime::msecsTo()-
1794*/-
1795-
1796int QTime::msecsTo(const QTime &t) const-
1797{-
1798 if (!isValid() || !t.isValid())
!isValid()Description
TRUEevaluated 5 times by 3 tests
Evaluated by:
  • tst_QTextStream
  • tst_QThreadPool
  • tst_QTime
FALSEevaluated 6942460 times by 33 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractSlider
  • tst_QAtomicInt
  • tst_QCoreApplication
  • tst_QDateTimeEdit
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QFtp
  • tst_QFutureWatcher
  • tst_QGuiApplication
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QLabel
  • tst_QLocalSocket
  • tst_QMovie
  • tst_QMutex
  • tst_QNetworkReply
  • tst_QObjectPerformance
  • tst_QProcess
  • tst_QReadWriteLock
  • tst_QSharedMemory
  • tst_QSqlTableModel
  • tst_QTcpSocket
  • tst_QTextStream
  • ...
!t.isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 6943571 times by 33 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractSlider
  • tst_QAtomicInt
  • tst_QCoreApplication
  • tst_QDateTimeEdit
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QFtp
  • tst_QFutureWatcher
  • tst_QGuiApplication
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QLabel
  • tst_QLocalSocket
  • tst_QMovie
  • tst_QMutex
  • tst_QNetworkReply
  • tst_QObjectPerformance
  • tst_QProcess
  • tst_QReadWriteLock
  • tst_QSharedMemory
  • tst_QSqlTableModel
  • tst_QTcpSocket
  • tst_QTextStream
  • ...
1-6943571
1799 return 0;
executed 6 times by 3 tests: return 0;
Executed by:
  • tst_QTextStream
  • tst_QThreadPool
  • tst_QTime
6
1800#if defined(Q_OS_WINCE)-
1801 // GetLocalTime() for Windows CE has no milliseconds resolution-
1802 if (t.startTick > NullTime && startTick > NullTime)-
1803 return t.startTick - startTick;-
1804 else-
1805#endif-
1806 return t.ds() - ds();
executed 6943182 times by 33 tests: return t.ds() - ds();
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractSlider
  • tst_QAtomicInt
  • tst_QCoreApplication
  • tst_QDateTimeEdit
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QFtp
  • tst_QFutureWatcher
  • tst_QGuiApplication
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QLabel
  • tst_QLocalSocket
  • tst_QMovie
  • tst_QMutex
  • tst_QNetworkReply
  • tst_QObjectPerformance
  • tst_QProcess
  • tst_QReadWriteLock
  • tst_QSharedMemory
  • tst_QSqlTableModel
  • tst_QTcpSocket
  • tst_QTextStream
  • ...
6943182
1807}-
1808-
1809-
1810/*!-
1811 \fn bool QTime::operator==(const QTime &t) const-
1812-
1813 Returns \c true if this time is equal to \a t; otherwise returns \c false.-
1814*/-
1815-
1816/*!-
1817 \fn bool QTime::operator!=(const QTime &t) const-
1818-
1819 Returns \c true if this time is different from \a t; otherwise returns \c false.-
1820*/-
1821-
1822/*!-
1823 \fn bool QTime::operator<(const QTime &t) const-
1824-
1825 Returns \c true if this time is earlier than \a t; otherwise returns \c false.-
1826*/-
1827-
1828/*!-
1829 \fn bool QTime::operator<=(const QTime &t) const-
1830-
1831 Returns \c true if this time is earlier than or equal to \a t;-
1832 otherwise returns \c false.-
1833*/-
1834-
1835/*!-
1836 \fn bool QTime::operator>(const QTime &t) const-
1837-
1838 Returns \c true if this time is later than \a t; otherwise returns \c false.-
1839*/-
1840-
1841/*!-
1842 \fn bool QTime::operator>=(const QTime &t) const-
1843-
1844 Returns \c true if this time is later than or equal to \a t;-
1845 otherwise returns \c false.-
1846*/-
1847-
1848/*!-
1849 \fn QTime QTime::fromMSecsSinceStartOfDay(int msecs)-
1850-
1851 Returns a new QTime instance with the time set to the number of \a msecs-
1852 since the start of the day, i.e. since 00:00:00.-
1853-
1854 If \a msecs falls outside the valid range an invalid QTime will be returned.-
1855-
1856 \sa msecsSinceStartOfDay()-
1857*/-
1858-
1859/*!-
1860 \fn int QTime::msecsSinceStartOfDay() const-
1861-
1862 Returns the number of msecs since the start of the day, i.e. since 00:00:00.-
1863-
1864 \sa fromMSecsSinceStartOfDay()-
1865*/-
1866-
1867/*!-
1868 \fn QTime::currentTime()-
1869-
1870 Returns the current time as reported by the system clock.-
1871-
1872 Note that the accuracy depends on the accuracy of the underlying-
1873 operating system; not all systems provide 1-millisecond accuracy.-
1874*/-
1875-
1876#ifndef QT_NO_DATESTRING-
1877-
1878static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, bool *isMidnight24)-
1879{-
1880 if (isMidnight24)
isMidnight24Description
TRUEevaluated 54 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_QTime
  • tst_QVariant
30-54
1881 *isMidnight24 = false;
executed 54 times by 4 tests: *isMidnight24 = false;
Executed by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
54
1882-
1883 const int size = string.size();-
1884 if (size < 5)
size < 5Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 83 times by 5 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
1-83
1885 return QTime();
executed 1 time by 1 test: return QTime();
Executed by:
  • tst_QTime
1
1886-
1887 bool ok = false;-
1888 int hour = string.mid(0, 2).toInt(&ok);-
1889 if (!ok)
!okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QVariant
FALSEevaluated 82 times by 5 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
1-82
1890 return QTime();
executed 1 time by 1 test: return QTime();
Executed by:
  • tst_QVariant
1
1891 const int minute = string.mid(3, 2).toInt(&ok);-
1892 if (!ok)
!okDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 80 times by 5 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
2-80
1893 return QTime();
executed 2 times by 1 test: return QTime();
Executed by:
  • tst_QTime
2
1894 int second = 0;-
1895 int msec = 0;-
1896-
1897 if (size == 5) {
size == 5Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 74 times by 5 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
6-74
1898 // HH:mm format-
1899 second = 0;-
1900 msec = 0;-
1901 } else if (string.at(5) == QLatin1Char(',') || string.at(5) == QLatin1Char('.')) {
executed 6 times by 1 test: end of block
Executed by:
  • tst_QTime
string.at(5) =...atin1Char(',')Description
TRUEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTime
FALSEevaluated 69 times by 5 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
string.at(5) =...atin1Char('.')Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTime
FALSEevaluated 65 times by 5 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
4-69
1902 if (format == Qt::TextDate)
format == Qt::TextDateDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTime
1-8
1903 return QTime();
executed 1 time by 1 test: return QTime();
Executed by:
  • tst_QTime
1
1904 // ISODate HH:mm.ssssss format-
1905 // We only want 5 digits worth of fraction of minute. This follows the existing-
1906 // behavior that determines how milliseconds are read; 4 millisecond digits are-
1907 // read and then rounded to 3. If we read at most 5 digits for fraction of minute,-
1908 // the maximum amount of millisecond digits it will expand to once converted to-
1909 // seconds is 4. E.g. 12:34,99999 will expand to 12:34:59.9994. The milliseconds-
1910 // will then be rounded up AND clamped to 999.-
1911-
1912 const QStringRef minuteFractionStr = string.mid(6, 5);-
1913 const long minuteFractionInt = minuteFractionStr.toLong(&ok);-
1914 if (!ok)
!okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTime
1-7
1915 return QTime();
executed 1 time by 1 test: return QTime();
Executed by:
  • tst_QTime
1
1916 const float minuteFraction = double(minuteFractionInt) / (std::pow(double(10), minuteFractionStr.count()));-
1917-
1918 const float secondWithMs = minuteFraction * 60;-
1919 const float secondNoMs = std::floor(secondWithMs);-
1920 const float secondFraction = secondWithMs - secondNoMs;-
1921 second = secondNoMs;-
1922 msec = qMin(qRound(secondFraction * 1000.0), 999);-
1923 } else {
executed 7 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTime
7
1924 // HH:mm:ss or HH:mm:ss.zzz-
1925 second = string.mid(6, 2).toInt(&ok);-
1926 if (!ok)
!okDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 63 times by 5 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
2-63
1927 return QTime();
executed 2 times by 1 test: return QTime();
Executed by:
  • tst_QTime
2
1928 if (size > 8 && (string.at(8) == QLatin1Char(',') || string.at(8) == QLatin1Char('.'))) {
size > 8Description
TRUEevaluated 29 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QSqlQuery
  • tst_QTime
FALSEevaluated 34 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QTime
  • tst_QVariant
string.at(8) =...atin1Char(',')Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 18 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QSqlQuery
  • tst_QTime
string.at(8) =...atin1Char('.')Description
TRUEevaluated 15 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QSqlQuery
  • tst_QTime
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTime
3-34
1929 const QStringRef msecStr(string.mid(9, 4));-
1930 int msecInt = msecStr.isEmpty() ? 0 : msecStr.toInt(&ok);
msecStr.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 25 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QSqlQuery
  • tst_QTime
1-25
1931 if (!ok)
!okDescription
TRUEnever evaluated
FALSEevaluated 26 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QSqlQuery
  • tst_QTime
0-26
1932 return QTime();
never executed: return QTime();
0
1933 const double secondFraction(msecInt / (std::pow(double(10), msecStr.count())));-
1934 msec = qMin(qRound(secondFraction * 1000.0), 999);-
1935 }
executed 26 times by 3 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QSqlQuery
  • tst_QTime
26
1936 }
executed 63 times by 5 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
63
1937-
1938 if (format == Qt::ISODate && hour == 24 && minute == 0 && second == 0 && msec == 0) {
format == Qt::ISODateDescription
TRUEevaluated 69 times by 5 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QTime
hour == 24Description
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTime
FALSEevaluated 62 times by 5 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
minute == 0Description
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTime
FALSEnever evaluated
second == 0Description
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTime
FALSEnever evaluated
msec == 0Description
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTime
FALSEnever evaluated
0-69
1939 if (isMidnight24)
isMidnight24Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTime
2-5
1940 *isMidnight24 = true;
executed 5 times by 1 test: *isMidnight24 = true;
Executed by:
  • tst_QDateTime
5
1941 hour = 0;-
1942 }
executed 7 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTime
7
1943-
1944 return QTime(hour, minute, second, msec);
executed 76 times by 5 tests: return QTime(hour, minute, second, msec);
Executed by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QTime
  • tst_QVariant
76
1945}-
1946-
1947/*!-
1948 \fn QTime QTime::fromString(const QString &string, Qt::DateFormat format)-
1949-
1950 Returns the time represented in the \a string as a QTime using the-
1951 \a format given, or an invalid time if this is not possible.-
1952-
1953 Note that fromString() uses a "C" locale encoded string to convert-
1954 milliseconds to a float value. If the default locale is not "C",-
1955 this may result in two conversion attempts (if the conversion-
1956 fails for the default locale). This should be considered an-
1957 implementation detail.-
1958-
1959 \sa toString(), QLocale::toTime()-
1960*/-
1961QTime QTime::fromString(const QString& string, Qt::DateFormat format)-
1962{-
1963 if (string.isEmpty())
string.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTime
FALSEevaluated 50 times by 2 tests
Evaluated by:
  • tst_QTime
  • tst_QVariant
2-50
1964 return QTime();
executed 2 times by 1 test: return QTime();
Executed by:
  • tst_QTime
2
1965-
1966 switch (format) {-
1967 case Qt::SystemLocaleDate:
never executed: case Qt::SystemLocaleDate:
0
1968 case Qt::SystemLocaleShortDate:
never executed: case Qt::SystemLocaleShortDate:
0
1969 return QLocale::system().toTime(string, QLocale::ShortFormat);
never executed: return QLocale::system().toTime(string, QLocale::ShortFormat);
0
1970 case Qt::SystemLocaleLongDate:
never executed: case Qt::SystemLocaleLongDate:
0
1971 return QLocale::system().toTime(string, QLocale::LongFormat);
never executed: return QLocale::system().toTime(string, QLocale::LongFormat);
0
1972 case Qt::LocaleDate:
never executed: case Qt::LocaleDate:
0
1973 case Qt::DefaultLocaleShortDate:
never executed: case Qt::DefaultLocaleShortDate:
0
1974 return QLocale().toTime(string, QLocale::ShortFormat);
never executed: return QLocale().toTime(string, QLocale::ShortFormat);
0
1975 case Qt::DefaultLocaleLongDate:
never executed: case Qt::DefaultLocaleLongDate:
0
1976 return QLocale().toTime(string, QLocale::LongFormat);
never executed: return QLocale().toTime(string, QLocale::LongFormat);
0
1977 case Qt::RFC2822Date:
executed 20 times by 1 test: case Qt::RFC2822Date:
Executed by:
  • tst_QTime
20
1978 return rfcDateImpl(string).time;
executed 20 times by 1 test: return rfcDateImpl(string).time;
Executed by:
  • tst_QTime
20
1979 case Qt::ISODate:
executed 20 times by 2 tests: case Qt::ISODate:
Executed by:
  • tst_QTime
  • tst_QVariant
20
1980 case Qt::TextDate:
executed 10 times by 1 test: case Qt::TextDate:
Executed by:
  • tst_QTime
10
1981 default:
never executed: default:
0
1982 return fromIsoTimeString(&string, format, 0);
executed 30 times by 2 tests: return fromIsoTimeString(&string, format, 0);
Executed by:
  • tst_QTime
  • tst_QVariant
30
1983 }-
1984}-
1985-
1986/*!-
1987 \fn QTime::fromString(const QString &string, const QString &format)-
1988-
1989 Returns the QTime represented by the \a string, using the \a-
1990 format given, or an invalid time if the string cannot be parsed.-
1991-
1992 These expressions may be used for the format:-
1993-
1994 \table-
1995 \header \li Expression \li Output-
1996 \row \li h-
1997 \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)-
1998 \row \li hh-
1999 \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)-
2000 \row \li m \li the minute without a leading zero (0 to 59)-
2001 \row \li mm \li the minute with a leading zero (00 to 59)-
2002 \row \li s \li the second without a leading zero (0 to 59)-
2003 \row \li ss \li the second with a leading zero (00 to 59)-
2004 \row \li z \li the milliseconds without leading zeroes (0 to 999)-
2005 \row \li zzz \li the milliseconds with leading zeroes (000 to 999)-
2006 \row \li AP-
2007 \li interpret as an AM/PM time. \e AP must be either "AM" or "PM".-
2008 \row \li ap-
2009 \li Interpret as an AM/PM time. \e ap must be either "am" or "pm".-
2010 \endtable-
2011-
2012 All other input characters will be treated as text. Any sequence-
2013 of characters that are enclosed in single quotes will also be-
2014 treated as text and not be used as an expression.-
2015-
2016 \snippet code/src_corelib_tools_qdatetime.cpp 6-
2017-
2018 If the format is not satisfied, an invalid QTime is returned.-
2019 Expressions that do not expect leading zeroes to be given (h, m, s-
2020 and z) are greedy. This means that they will use two digits even if-
2021 this puts them outside the range of accepted values and leaves too-
2022 few digits for other sections. For example, the following string-
2023 could have meant 00:07:10, but the m will grab two digits, resulting-
2024 in an invalid time:-
2025-
2026 \snippet code/src_corelib_tools_qdatetime.cpp 7-
2027-
2028 Any field that is not represented in the format will be set to zero.-
2029 For example:-
2030-
2031 \snippet code/src_corelib_tools_qdatetime.cpp 8-
2032-
2033 \sa toString(), QDateTime::fromString(), QDate::fromString(),-
2034 QLocale::toTime()-
2035*/-
2036-
2037QTime QTime::fromString(const QString &string, const QString &format)-
2038{-
2039 QTime time;-
2040#ifndef QT_BOOTSTRAPPED-
2041 QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString);-
2042 if (dt.parseFormat(format))
dt.parseFormat(format)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QTime
FALSEnever evaluated
0-12
2043 dt.fromString(string, 0, &time);
executed 12 times by 1 test: dt.fromString(string, 0, &time);
Executed by:
  • tst_QTime
12
2044#else-
2045 Q_UNUSED(string);-
2046 Q_UNUSED(format);-
2047#endif-
2048 return time;
executed 12 times by 1 test: return time;
Executed by:
  • tst_QTime
12
2049}-
2050-
2051#endif // QT_NO_DATESTRING-
2052-
2053-
2054/*!-
2055 \overload-
2056-
2057 Returns \c true if the specified time is valid; otherwise returns-
2058 false.-
2059-
2060 The time is valid if \a h is in the range 0 to 23, \a m and-
2061 \a s are in the range 0 to 59, and \a ms is in the range 0 to 999.-
2062-
2063 Example:-
2064-
2065 \snippet code/src_corelib_tools_qdatetime.cpp 9-
2066*/-
2067-
2068bool QTime::isValid(int h, int m, int s, int ms)-
2069{-
2070 return (uint)h < 24 && (uint)m < 60 && (uint)s < 60 && (uint)ms < 1000;
executed 20961703 times by 107 tests: return (uint)h < 24 && (uint)m < 60 && (uint)s < 60 && (uint)ms < 1000;
Executed by:
  • tst_Collections
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • ...
20961703
2071}-
2072-
2073-
2074/*!-
2075 Sets this time to the current time. This is practical for timing:-
2076-
2077 \snippet code/src_corelib_tools_qdatetime.cpp 10-
2078-
2079 \sa restart(), elapsed(), currentTime()-
2080*/-
2081-
2082void QTime::start()-
2083{-
2084 *this = currentTime();-
2085}
executed 677 times by 28 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractSlider
  • tst_QAtomicInt
  • tst_QCoreApplication
  • tst_QFtp
  • tst_QFutureWatcher
  • tst_QGuiApplication
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QLabel
  • tst_QLocalSocket
  • tst_QMovie
  • tst_QMutex
  • tst_QNetworkReply
  • tst_QObjectPerformance
  • tst_QProcess
  • tst_QReadWriteLock
  • tst_QSharedMemory
  • tst_QSocks5SocketEngine
  • tst_QSqlTableModel
  • tst_QTcpSocket
  • tst_QThread
  • tst_QThreadPool
  • tst_QTimer
  • ...
677
2086-
2087/*!-
2088 Sets this time to the current time and returns the number of-
2089 milliseconds that have elapsed since the last time start() or-
2090 restart() was called.-
2091-
2092 This function is guaranteed to be atomic and is thus very handy-
2093 for repeated measurements. Call start() to start the first-
2094 measurement, and restart() for each later measurement.-
2095-
2096 Note that the counter wraps to zero 24 hours after the last call-
2097 to start() or restart().-
2098-
2099 \warning If the system's clock setting has been changed since the-
2100 last time start() or restart() was called, the result is-
2101 undefined. This can happen when daylight-saving time is turned on-
2102 or off.-
2103-
2104 \sa start(), elapsed(), currentTime()-
2105*/-
2106-
2107int QTime::restart()-
2108{-
2109 QTime t = currentTime();-
2110 int n = msecsTo(t);-
2111 if (n < 0) // passed midnight
n < 0Description
TRUEnever evaluated
FALSEevaluated 211 times by 3 tests
Evaluated by:
  • tst_QFtp
  • tst_QTextStream
  • tst_QThreadPool
0-211
2112 n += 86400*1000;
never executed: n += 86400*1000;
0
2113 *this = t;-
2114 return n;
executed 211 times by 3 tests: return n;
Executed by:
  • tst_QFtp
  • tst_QTextStream
  • tst_QThreadPool
211
2115}-
2116-
2117/*!-
2118 Returns the number of milliseconds that have elapsed since the-
2119 last time start() or restart() was called.-
2120-
2121 Note that the counter wraps to zero 24 hours after the last call-
2122 to start() or restart.-
2123-
2124 Note that the accuracy depends on the accuracy of the underlying-
2125 operating system; not all systems provide 1-millisecond accuracy.-
2126-
2127 \warning If the system's clock setting has been changed since the-
2128 last time start() or restart() was called, the result is-
2129 undefined. This can happen when daylight-saving time is turned on-
2130 or off.-
2131-
2132 \sa start(), restart()-
2133*/-
2134-
2135int QTime::elapsed() const-
2136{-
2137 int n = msecsTo(currentTime());-
2138 if (n < 0) // passed midnight
n < 0Description
TRUEnever evaluated
FALSEevaluated 6943291 times by 28 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractSlider
  • tst_QAtomicInt
  • tst_QCoreApplication
  • tst_QFtp
  • tst_QFutureWatcher
  • tst_QGuiApplication
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QLabel
  • tst_QLocalSocket
  • tst_QMovie
  • tst_QMutex
  • tst_QNetworkReply
  • tst_QObjectPerformance
  • tst_QProcess
  • tst_QReadWriteLock
  • tst_QSharedMemory
  • tst_QSqlTableModel
  • tst_QTcpSocket
  • tst_QTextStream
  • tst_QThread
  • tst_QThreadPool
  • tst_QTimer
  • ...
0-6943291
2139 n += 86400 * 1000;
never executed: n += 86400 * 1000;
0
2140 return n;
executed 6943291 times by 28 tests: return n;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractSlider
  • tst_QAtomicInt
  • tst_QCoreApplication
  • tst_QFtp
  • tst_QFutureWatcher
  • tst_QGuiApplication
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QLabel
  • tst_QLocalSocket
  • tst_QMovie
  • tst_QMutex
  • tst_QNetworkReply
  • tst_QObjectPerformance
  • tst_QProcess
  • tst_QReadWriteLock
  • tst_QSharedMemory
  • tst_QSqlTableModel
  • tst_QTcpSocket
  • tst_QTextStream
  • tst_QThread
  • tst_QThreadPool
  • tst_QTimer
  • ...
6943291
2141}-
2142-
2143/*****************************************************************************-
2144 QDateTime static helper functions-
2145 *****************************************************************************/-
2146-
2147// Calls the platform variant of tzset-
2148static void qt_tzset()-
2149{-
2150#if defined(Q_OS_WINCE)-
2151 // WinCE doesn't use tzset-
2152 return;-
2153#elif defined(Q_OS_WIN)-
2154 _tzset();-
2155#else-
2156 tzset();-
2157#endif // Q_OS_WIN-
2158}
executed 6954999 times by 98 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • tst_QFile
  • tst_QFileDialog2
  • ...
6954999
2159-
2160// Returns the platform variant of timezone, i.e. the standard time offset-
2161// The timezone external variable is documented as always holding the-
2162// Standard Time offset as seconds west of Greenwich, i.e. UTC+01:00 is -3600-
2163// Note this may not be historicaly accurate.-
2164// Relies on tzset, mktime, or localtime having been called to populate timezone-
2165static int qt_timezone()-
2166{-
2167#if defined(Q_OS_WINCE)-
2168 TIME_ZONE_INFORMATION tzi;-
2169 GetTimeZoneInformation(&tzi);-
2170 // Expressed in minutes, convert to seconds-
2171 return (tzi.Bias + tzi.StandardBias) * 60;-
2172#elif defined(_MSC_VER) && _MSC_VER >= 1400-
2173 long offset;-
2174 _get_timezone(&offset);-
2175 return offset;-
2176#elif defined(Q_OS_BSD4) && !defined(Q_OS_DARWIN)-
2177 time_t clock = time(NULL);-
2178 struct tm t;-
2179 localtime_r(&clock, &t);-
2180 // QTBUG-36080 Workaround for systems without the POSIX timezone-
2181 // variable. This solution is not very efficient but fixing it is up to-
2182 // the libc implementations.-
2183 //-
2184 // tm_gmtoff has some important differences compared to the timezone-
2185 // variable:-
2186 // - It returns the number of seconds east of UTC, and we want the-
2187 // number of seconds west of UTC.-
2188 // - It also takes DST into account, so we need to adjust it to always-
2189 // get the Standard Time offset.-
2190 return -t.tm_gmtoff + (t.tm_isdst ? (long)SECS_PER_HOUR : 0L);-
2191#elif defined(Q_OS_INTEGRITY)-
2192 return 0;-
2193#else-
2194 return timezone;
executed 7004 times by 16 tests: return timezone;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QStyleSheetStyle
  • tst_QTime
7004
2195#endif // Q_OS_WIN-
2196}-
2197-
2198// Returns the tzname, assume tzset has been called already-
2199static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus)-
2200{-
2201#if defined(Q_OS_WINCE)-
2202 TIME_ZONE_INFORMATION tzi;-
2203 DWORD res = GetTimeZoneInformation(&tzi);-
2204 if (res == TIME_ZONE_ID_UNKNOWN)-
2205 return QString();-
2206 else if (daylightStatus == QDateTimePrivate::DaylightTime)-
2207 return QString::fromWCharArray(tzi.DaylightName);-
2208 else-
2209 return QString::fromWCharArray(tzi.StandardName);-
2210#else-
2211 int isDst = (daylightStatus == QDateTimePrivate::DaylightTime) ? 1 : 0;
(daylightStatu...:DaylightTime)Description
TRUEevaluated 250 times by 11 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileInfo
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QSignalSpy
  • tst_QTime
  • tst_QVariant
FALSEevaluated 1021 times by 5 tests
Evaluated by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNoDebug
250-1021
2212#if defined(_MSC_VER) && _MSC_VER >= 1400-
2213 size_t s = 0;-
2214 char name[512];-
2215 if (_get_tzname(&s, name, 512, isDst))-
2216 return QString();-
2217 return QString::fromLocal8Bit(name);-
2218#else-
2219 return QString::fromLocal8Bit(tzname[isDst]);
executed 1271 times by 13 tests: return QString::fromLocal8Bit(tzname[isDst]);
Executed by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileInfo
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QNoDebug
  • tst_QSignalSpy
  • tst_QTime
  • tst_QVariant
1271
2220#endif // Q_OS_WIN-
2221#endif // Q_OS_WINCE-
2222}-
2223-
2224// Calls the platform variant of mktime for the given date, time and daylightStatus,-
2225// and updates the date, time, daylightStatus and abbreviation with the returned values-
2226// If the date falls outside the 1970 to 2037 range supported by mktime / time_t-
2227// then null date/time will be returned, you should adjust the date first if-
2228// you need a guaranteed result.-
2229static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStatus *daylightStatus,-
2230 QString *abbreviation, bool *ok = 0)-
2231{-
2232 const qint64 msec = time->msec();-
2233 int yy, mm, dd;-
2234 date->getDate(&yy, &mm, &dd);-
2235-
2236#if defined(Q_OS_WINCE)-
2237 // WinCE doesn't provide standard C library time functions-
2238 SYSTEMTIME st;-
2239 memset(&st, 0, sizeof(SYSTEMTIME));-
2240 st.wSecond = time->second();-
2241 st.wMinute = time->minute();-
2242 st.wHour = time->hour();-
2243 st.wDay = dd;-
2244 st.wMonth = mm;-
2245 st.wYear = yy;-
2246 FILETIME lft;-
2247 bool valid = SystemTimeToFileTime(&st, &lft);-
2248 FILETIME ft;-
2249 if (valid)-
2250 valid = LocalFileTimeToFileTime(&lft, &ft);-
2251 const time_t secsSinceEpoch = ftToTime_t(ft);-
2252 const time_t localSecs = ftToTime_t(lft);-
2253 TIME_ZONE_INFORMATION tzi;-
2254 GetTimeZoneInformation(&tzi);-
2255 bool isDaylight = false;-
2256 // Check for overflow-
2257 qint64 localDiff = qAbs(localSecs - secsSinceEpoch);-
2258 int daylightOffset = qAbs(tzi.Bias + tzi.DaylightBias) * 60;-
2259 if (localDiff > daylightOffset)-
2260 valid = false;-
2261 else-
2262 isDaylight = (localDiff == daylightOffset);-
2263 if (daylightStatus) {-
2264 if (isDaylight)-
2265 *daylightStatus = QDateTimePrivate::DaylightTime;-
2266 else-
2267 *daylightStatus = QDateTimePrivate::StandardTime;-
2268 }-
2269 if (abbreviation) {-
2270 if (isDaylight)-
2271 *abbreviation = QString::fromWCharArray(tzi.DaylightName);-
2272 else-
2273 *abbreviation = QString::fromWCharArray(tzi.StandardName);-
2274 }-
2275 if (ok)-
2276 *ok = valid;-
2277#else-
2278 // All other platforms provide standard C library time functions-
2279 tm local;-
2280 memset(&local, 0, sizeof(local)); // tm_[wy]day plus any non-standard fields-
2281 local.tm_sec = time->second();-
2282 local.tm_min = time->minute();-
2283 local.tm_hour = time->hour();-
2284 local.tm_mday = dd;-
2285 local.tm_mon = mm - 1;-
2286 local.tm_year = yy - 1900;-
2287 if (daylightStatus)
daylightStatusDescription
TRUEevaluated 13933065 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
FALSEnever evaluated
0-13933065
2288 local.tm_isdst = int(*daylightStatus);
executed 13931755 times by 101 tests: local.tm_isdst = int(*daylightStatus);
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13931755
2289 else-
2290 local.tm_isdst = -1;
never executed: local.tm_isdst = -1;
0
2291-
2292#if defined(Q_OS_WIN)-
2293 int hh = local.tm_hour;-
2294#endif // Q_OS_WIN-
2295 time_t secsSinceEpoch = mktime(&local);-
2296 if (secsSinceEpoch != time_t(-1)) {
secsSinceEpoch != time_t(-1)Description
TRUEevaluated 13931934 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_QDateTime
36-13931934
2297 *date = QDate(local.tm_year + 1900, local.tm_mon + 1, local.tm_mday);-
2298 *time = QTime(local.tm_hour, local.tm_min, local.tm_sec, msec);-
2299#if defined(Q_OS_WIN)-
2300 // Windows mktime for the missing hour subtracts 1 hour from the time-
2301 // instead of adding 1 hour. If time differs and is standard time then-
2302 // this has happened, so add 2 hours to the time and 1 hour to the msecs-
2303 if (local.tm_isdst == 0 && local.tm_hour != hh) {-
2304 if (time->hour() >= 22)-
2305 *date = date->addDays(1);-
2306 *time = time->addSecs(2 * SECS_PER_HOUR);-
2307 secsSinceEpoch += SECS_PER_HOUR;-
2308 local.tm_isdst = 1;-
2309 }-
2310#endif // Q_OS_WIN-
2311 if (local.tm_isdst >= 1) {
local.tm_isdst >= 1Description
TRUEevaluated 13906500 times by 98 tests
Evaluated 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_QDBusMarshall
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • tst_QFile
  • ...
FALSEevaluated 16578 times by 40 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • ...
16578-13906500
2312 if (daylightStatus)
daylightStatusDescription
TRUEevaluated 13911432 times by 98 tests
Evaluated 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_QDBusMarshall
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • tst_QFile
  • ...
FALSEnever evaluated
0-13911432
2313 *daylightStatus = QDateTimePrivate::DaylightTime;
executed 13919505 times by 98 tests: *daylightStatus = QDateTimePrivate::DaylightTime;
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_QDBusMarshall
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • tst_QFile
  • ...
13919505
2314 if (abbreviation)
abbreviationDescription
TRUEevaluated 250 times by 11 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileInfo
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QSignalSpy
  • tst_QTime
  • tst_QVariant
FALSEevaluated 13917167 times by 98 tests
Evaluated 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_QDBusMarshall
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • tst_QFile
  • ...
250-13917167
2315 *abbreviation = qt_tzname(QDateTimePrivate::DaylightTime);
executed 250 times by 11 tests: *abbreviation = qt_tzname(QDateTimePrivate::DaylightTime);
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileInfo
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QSignalSpy
  • tst_QTime
  • tst_QVariant
250
2316 } else if (local.tm_isdst == 0) {
executed 13909999 times by 98 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_QDBusMarshall
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • tst_QFile
  • ...
local.tm_isdst == 0Description
TRUEevaluated 16578 times by 40 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • ...
FALSEnever evaluated
0-13909999
2317 if (daylightStatus)
daylightStatusDescription
TRUEevaluated 16578 times by 40 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • ...
FALSEnever evaluated
0-16578
2318 *daylightStatus = QDateTimePrivate::StandardTime;
executed 16578 times by 40 tests: *daylightStatus = QDateTimePrivate::StandardTime;
Executed by:
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • ...
16578
2319 if (abbreviation)
abbreviationDescription
TRUEevaluated 691 times by 4 tests
Evaluated by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
FALSEevaluated 15887 times by 40 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • ...
691-15887
2320 *abbreviation = qt_tzname(QDateTimePrivate::StandardTime);
executed 691 times by 4 tests: *abbreviation = qt_tzname(QDateTimePrivate::StandardTime);
Executed by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
691
2321 } else {
executed 16578 times by 40 tests: end of block
Executed by:
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • ...
16578
2322 if (daylightStatus)
daylightStatusDescription
TRUEnever evaluated
FALSEnever evaluated
0
2323 *daylightStatus = QDateTimePrivate::UnknownDaylightTime;
never executed: *daylightStatus = QDateTimePrivate::UnknownDaylightTime;
0
2324 if (abbreviation)
abbreviationDescription
TRUEnever evaluated
FALSEnever evaluated
0
2325 *abbreviation = qt_tzname(QDateTimePrivate::StandardTime);
never executed: *abbreviation = qt_tzname(QDateTimePrivate::StandardTime);
0
2326 }
never executed: end of block
0
2327 if (ok)
okDescription
TRUEevaluated 1142 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QStyleSheetStyle
FALSEevaluated 13932348 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
1142-13932348
2328 *ok = true;
executed 1142 times by 8 tests: *ok = true;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QStyleSheetStyle
1142
2329 } else {
executed 13928513 times by 101 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13928513
2330 *date = QDate();-
2331 *time = QTime();-
2332 if (daylightStatus)
daylightStatusDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEnever evaluated
0-36
2333 *daylightStatus = QDateTimePrivate::UnknownDaylightTime;
executed 36 times by 1 test: *daylightStatus = QDateTimePrivate::UnknownDaylightTime;
Executed by:
  • tst_QDateTime
36
2334 if (abbreviation)
abbreviationDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 25 times by 1 test
Evaluated by:
  • tst_QDateTime
11-25
2335 *abbreviation = QString();
executed 11 times by 1 test: *abbreviation = QString();
Executed by:
  • tst_QDateTime
11
2336 if (ok)
okDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEnever evaluated
0-36
2337 *ok = false;
executed 36 times by 1 test: *ok = false;
Executed by:
  • tst_QDateTime
36
2338 }
executed 36 times by 1 test: end of block
Executed by:
  • tst_QDateTime
36
2339#endif // Q_OS_WINCE-
2340-
2341 return ((qint64)secsSinceEpoch * 1000) + msec;
executed 13924464 times by 101 tests: return ((qint64)secsSinceEpoch * 1000) + msec;
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13924464
2342}-
2343-
2344// Calls the platform variant of localtime for the given msecs, and updates-
2345// the date, time, and DST status with the returned values.-
2346static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localTime,-
2347 QDateTimePrivate::DaylightStatus *daylightStatus)-
2348{-
2349 const time_t secsSinceEpoch = msecsSinceEpoch / 1000;-
2350 const int msec = msecsSinceEpoch % 1000;-
2351-
2352 tm local;-
2353 bool valid = false;-
2354-
2355#if defined(Q_OS_WINCE)-
2356 FILETIME utcTime = time_tToFt(secsSinceEpoch);-
2357 FILETIME resultTime;-
2358 valid = FileTimeToLocalFileTime(&utcTime , &resultTime);-
2359 SYSTEMTIME sysTime;-
2360 if (valid)-
2361 valid = FileTimeToSystemTime(&resultTime , &sysTime);-
2362-
2363 if (valid) {-
2364 local.tm_sec = sysTime.wSecond;-
2365 local.tm_min = sysTime.wMinute;-
2366 local.tm_hour = sysTime.wHour;-
2367 local.tm_mday = sysTime.wDay;-
2368 local.tm_mon = sysTime.wMonth - 1;-
2369 local.tm_year = sysTime.wYear - 1900;-
2370 }-
2371#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)-
2372 // localtime() is required to work as if tzset() was called before it.-
2373 // localtime_r() does not have this requirement, so make an explicit call.-
2374 qt_tzset();-
2375 // Use the reentrant version of localtime() where available-
2376 // as is thread-safe and doesn't use a shared static data area-
2377 tm *res = 0;-
2378 res = localtime_r(&secsSinceEpoch, &local);-
2379 if (res)
resDescription
TRUEevaluated 6953144 times by 95 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
FALSEnever evaluated
0-6953144
2380 valid = true;
executed 6953143 times by 95 tests: valid = true;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
6953143
2381#elif defined(_MSC_VER) && _MSC_VER >= 1400-
2382 if (!_localtime64_s(&local, &secsSinceEpoch))-
2383 valid = true;-
2384#else-
2385 // Returns shared static data which may be overwritten at any time-
2386 // So copy the result asap-
2387 tm *res = 0;-
2388 res = localtime(&secsSinceEpoch);-
2389 if (res) {-
2390 local = *res;-
2391 valid = true;-
2392 }-
2393#endif-
2394 if (valid) {
validDescription
TRUEevaluated 6950715 times by 95 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
FALSEnever evaluated
0-6950715
2395 *localDate = QDate(local.tm_year + 1900, local.tm_mon + 1, local.tm_mday);-
2396 *localTime = QTime(local.tm_hour, local.tm_min, local.tm_sec, msec);-
2397 if (daylightStatus) {
daylightStatusDescription
TRUEevaluated 6953144 times by 95 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
FALSEnever evaluated
0-6953144
2398 if (local.tm_isdst > 0)
local.tm_isdst > 0Description
TRUEevaluated 6949783 times by 94 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
FALSEevaluated 690 times by 28 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCookieJar
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QSystemTrayIcon
  • tst_QTextEdit
  • ...
690-6949783
2399 *daylightStatus = QDateTimePrivate::DaylightTime;
executed 6952454 times by 94 tests: *daylightStatus = QDateTimePrivate::DaylightTime;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
6952454
2400 else if (local.tm_isdst < 0)
local.tm_isdst < 0Description
TRUEnever evaluated
FALSEevaluated 690 times by 28 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCookieJar
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QSystemTrayIcon
  • tst_QTextEdit
  • ...
0-690
2401 *daylightStatus = QDateTimePrivate::UnknownDaylightTime;
never executed: *daylightStatus = QDateTimePrivate::UnknownDaylightTime;
0
2402 else-
2403 *daylightStatus = QDateTimePrivate::StandardTime;
executed 690 times by 28 tests: *daylightStatus = QDateTimePrivate::StandardTime;
Executed by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCookieJar
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QSystemTrayIcon
  • tst_QTextEdit
  • ...
690
2404 }-
2405 return true;
executed 6950531 times by 95 tests: return true;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
6950531
2406 } else {-
2407 *localDate = QDate();-
2408 *localTime = QTime();-
2409 if (daylightStatus)
daylightStatusDescription
TRUEnever evaluated
FALSEnever evaluated
0
2410 *daylightStatus = QDateTimePrivate::UnknownDaylightTime;
never executed: *daylightStatus = QDateTimePrivate::UnknownDaylightTime;
0
2411 return false;
never executed: return false;
0
2412 }-
2413}-
2414-
2415// Converts an msecs value into a date and time-
2416static void msecsToTime(qint64 msecs, QDate *date, QTime *time)-
2417{-
2418 qint64 jd = JULIAN_DAY_FOR_EPOCH;-
2419 qint64 ds = 0;-
2420-
2421 if (qAbs(msecs) >= MSECS_PER_DAY) {
qAbs(msecs) >= MSECS_PER_DAYDescription
TRUEevaluated 21021900 times by 103 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
FALSEevaluated 1690 times by 15 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QStyleSheetStyle
  • tst_QTimeZone
  • tst_QVariant
1690-21021900
2422 jd += (msecs / MSECS_PER_DAY);-
2423 msecs %= MSECS_PER_DAY;-
2424 }
executed 21017392 times by 103 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
21017392
2425-
2426 if (msecs < 0) {
msecs < 0Description
TRUEevaluated 5847 times by 6 tests
Evaluated by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QNoDebug
  • tst_QTime
FALSEevaluated 21012031 times by 102 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
5847-21012031
2427 ds = MSECS_PER_DAY - msecs - 1;-
2428 jd -= ds / MSECS_PER_DAY;-
2429 ds = ds % MSECS_PER_DAY;-
2430 ds = MSECS_PER_DAY - ds - 1;-
2431 } else {
executed 5847 times by 6 tests: end of block
Executed by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QNoDebug
  • tst_QTime
5847
2432 ds = msecs;-
2433 }
executed 21019418 times by 102 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
21019418
2434-
2435 if (date)
dateDescription
TRUEevaluated 14039817 times by 103 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
FALSEevaluated 6984402 times by 73 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QFutureWatcher
  • ...
6984402-14039817
2436 *date = QDate::fromJulianDay(jd);
executed 14040024 times by 103 tests: *date = QDate::fromJulianDay(jd);
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
14040024
2437 if (time)
timeDescription
TRUEevaluated 20947739 times by 103 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
FALSEevaluated 71334 times by 43 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • ...
71334-20947739
2438 *time = QTime::fromMSecsSinceStartOfDay(ds);
executed 20934261 times by 103 tests: *time = QTime::fromMSecsSinceStartOfDay(ds);
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
20934261
2439}
executed 21023529 times by 103 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
21023529
2440-
2441// Converts a date/time value into msecs-
2442static qint64 timeToMSecs(const QDate &date, const QTime &time)-
2443{-
2444 return ((date.toJulianDay() - JULIAN_DAY_FOR_EPOCH) * MSECS_PER_DAY)
executed 13949302 times by 102 tests: return ((date.toJulianDay() - JULIAN_DAY_FOR_EPOCH) * MSECS_PER_DAY) + time.msecsSinceStartOfDay();
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13949302
2445 + time.msecsSinceStartOfDay();
executed 13949302 times by 102 tests: return ((date.toJulianDay() - JULIAN_DAY_FOR_EPOCH) * MSECS_PER_DAY) + time.msecsSinceStartOfDay();
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13949302
2446}-
2447-
2448// Convert an MSecs Since Epoch into Local Time-
2449static bool epochMSecsToLocalTime(qint64 msecs, QDate *localDate, QTime *localTime,-
2450 QDateTimePrivate::DaylightStatus *daylightStatus = 0)-
2451{-
2452 if (msecs < 0) {
msecs < 0Description
TRUEevaluated 85 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEevaluated 6950521 times by 95 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
85-6950521
2453 // Docs state any LocalTime before 1970-01-01 will *not* have any Daylight Time applied-
2454 // Instead just use the standard offset from UTC to convert to UTC time-
2455 qt_tzset();-
2456 msecsToTime(msecs - qt_timezone() * 1000, localDate, localTime);-
2457 if (daylightStatus)
daylightStatusDescription
TRUEevaluated 85 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEnever evaluated
0-85
2458 *daylightStatus = QDateTimePrivate::StandardTime;
executed 85 times by 2 tests: *daylightStatus = QDateTimePrivate::StandardTime;
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
85
2459 return true;
executed 85 times by 2 tests: return true;
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
85
2460 } else if (msecs > (qint64(TIME_T_MAX) * 1000)) {
msecs > (qint6...T_MAX) * 1000)Description
TRUEevaluated 58 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEevaluated 6953086 times by 95 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
58-6953086
2461 // Docs state any LocalTime after 2037-12-31 *will* have any DST applied-
2462 // but this may fall outside the supported time_t range, so need to fake it.-
2463 // Use existing method to fake the conversion, but this is deeply flawed as it may-
2464 // apply the conversion from the wrong day number, e.g. if rule is last Sunday of month-
2465 // TODO Use QTimeZone when available to apply the future rule correctly-
2466 QDate utcDate;-
2467 QTime utcTime;-
2468 msecsToTime(msecs, &utcDate, &utcTime);-
2469 int year, month, day;-
2470 utcDate.getDate(&year, &month, &day);-
2471 // 2037 is not a leap year, so make sure date isn't Feb 29-
2472 if (month == 2 && day == 29)
month == 2Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
day == 29Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QDateTime
3-49
2473 --day;
executed 3 times by 1 test: --day;
Executed by:
  • tst_QDateTime
3
2474 QDate fakeDate(2037, month, day);-
2475 qint64 fakeMsecs = QDateTime(fakeDate, utcTime, Qt::UTC).toMSecsSinceEpoch();-
2476 bool res = qt_localtime(fakeMsecs, localDate, localTime, daylightStatus);-
2477 *localDate = localDate->addDays(fakeDate.daysTo(utcDate));-
2478 return res;
executed 58 times by 2 tests: return res;
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
58
2479 } else {-
2480 // Falls inside time_t suported range so can use localtime-
2481 return qt_localtime(msecs, localDate, localTime, daylightStatus);
executed 6952569 times by 95 tests: return qt_localtime(msecs, localDate, localTime, daylightStatus);
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
6952569
2482 }-
2483}-
2484-
2485// Convert a LocalTime expressed in local msecs encoding and the corresponding-
2486// DST status into a UTC epoch msecs. Optionally populate the returned-
2487// values from mktime for the adjusted local date and time.-
2488static qint64 localMSecsToEpochMSecs(qint64 localMsecs,-
2489 QDateTimePrivate::DaylightStatus *daylightStatus,-
2490 QDate *localDate = 0, QTime *localTime = 0,-
2491 QString *abbreviation = 0)-
2492{-
2493 QDate dt;-
2494 QTime tm;-
2495 msecsToTime(localMsecs, &dt, &tm);-
2496-
2497 const qint64 msecsMax = qint64(TIME_T_MAX) * 1000;-
2498-
2499 if (localMsecs <= qint64(MSECS_PER_DAY)) {
localMsecs <= ...MSECS_PER_DAY)Description
TRUEevaluated 6995 times by 16 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QStyleSheetStyle
  • tst_QTime
FALSEevaluated 13934960 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
6995-13934960
2500-
2501 // Docs state any LocalTime before 1970-01-01 will *not* have any DST applied-
2502-
2503 // First, if localMsecs is within +/- 1 day of minimum time_t try mktime in case it does-
2504 // fall after minimum and needs proper DST conversion-
2505 if (localMsecs >= -qint64(MSECS_PER_DAY)) {
localMsecs >= ...MSECS_PER_DAY)Description
TRUEevaluated 1136 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QStyleSheetStyle
FALSEevaluated 5859 times by 14 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QStyleSheetStyle
  • tst_QTime
1136-5859
2506 bool valid;-
2507 qint64 utcMsecs = qt_mktime(&dt, &tm, daylightStatus, abbreviation, &valid);-
2508 if (valid && utcMsecs >= 0) {
validDescription
TRUEevaluated 1100 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QStyleSheetStyle
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_QDateTime
utcMsecs >= 0Description
TRUEevaluated 76 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkCookieJar
FALSEevaluated 1024 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QStyleSheetStyle
36-1100
2509 // mktime worked and falls in valid range, so use it-
2510 if (localDate)
localDateDescription
TRUEevaluated 30 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkCookieJar
FALSEevaluated 46 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkCookieJar
30-46
2511 *localDate = dt;
executed 30 times by 2 tests: *localDate = dt;
Executed by:
  • tst_QDateTime
  • tst_QNetworkCookieJar
30
2512 if (localTime)
localTimeDescription
TRUEevaluated 30 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkCookieJar
FALSEevaluated 46 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkCookieJar
30-46
2513 *localTime = tm;
executed 30 times by 2 tests: *localTime = tm;
Executed by:
  • tst_QDateTime
  • tst_QNetworkCookieJar
30
2514 return utcMsecs;
executed 76 times by 2 tests: return utcMsecs;
Executed by:
  • tst_QDateTime
  • tst_QNetworkCookieJar
76
2515 }-
2516 } else {
executed 1060 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QStyleSheetStyle
1060
2517 // If we don't call mktime then need to call tzset to get offset-
2518 qt_tzset();-
2519 }
executed 5859 times by 14 tests: end of block
Executed by:
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QStyleSheetStyle
  • tst_QTime
5859
2520 // Time is clearly before 1970-01-01 so just use standard offset to convert-
2521 qint64 utcMsecs = localMsecs + qt_timezone() * 1000;-
2522 if (localDate || localTime)
localDateDescription
TRUEevaluated 4896 times by 15 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QStyleSheetStyle
  • tst_QTime
FALSEevaluated 2023 times by 8 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QNoDebug
  • tst_QStyleSheetStyle
localTimeDescription
TRUEnever evaluated
FALSEevaluated 2023 times by 8 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QNoDebug
  • tst_QStyleSheetStyle
0-4896
2523 msecsToTime(localMsecs, localDate, localTime);
executed 4896 times by 15 tests: msecsToTime(localMsecs, localDate, localTime);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QStyleSheetStyle
  • tst_QTime
4896
2524 if (daylightStatus)
daylightStatusDescription
TRUEevaluated 6919 times by 16 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QStyleSheetStyle
  • tst_QTime
FALSEnever evaluated
0-6919
2525 *daylightStatus = QDateTimePrivate::StandardTime;
executed 6919 times by 16 tests: *daylightStatus = QDateTimePrivate::StandardTime;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QStyleSheetStyle
  • tst_QTime
6919
2526 if (abbreviation)
abbreviationDescription
TRUEevaluated 330 times by 4 tests
Evaluated by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNoDebug
FALSEevaluated 6589 times by 16 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QStyleSheetStyle
  • tst_QTime
330-6589
2527 *abbreviation = qt_tzname(QDateTimePrivate::StandardTime);
executed 330 times by 4 tests: *abbreviation = qt_tzname(QDateTimePrivate::StandardTime);
Executed by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNoDebug
330
2528 return utcMsecs;
executed 6919 times by 16 tests: return utcMsecs;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QStyleSheetStyle
  • tst_QTime
6919
2529-
2530 } else if (localMsecs >= msecsMax - MSECS_PER_DAY) {
localMsecs >= ... MSECS_PER_DAYDescription
TRUEevaluated 15125 times by 11 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
FALSEevaluated 13917578 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
15125-13917578
2531-
2532 // Docs state any LocalTime after 2037-12-31 *will* have any DST applied-
2533 // but this may fall outside the supported time_t range, so need to fake it.-
2534-
2535 // First, if localMsecs is within +/- 1 day of maximum time_t try mktime in case it does-
2536 // fall before maximum and can use proper DST conversion-
2537 if (localMsecs <= msecsMax + MSECS_PER_DAY) {
localMsecs <= ... MSECS_PER_DAYDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 15083 times by 11 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
42-15083
2538 bool valid;-
2539 qint64 utcMsecs = qt_mktime(&dt, &tm, daylightStatus, abbreviation, &valid);-
2540 if (valid && utcMsecs <= msecsMax) {
validDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEnever evaluated
utcMsecs <= msecsMaxDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QDateTime
0-42
2541 // mktime worked and falls in valid range, so use it-
2542 if (localDate)
localDateDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_QDateTime
9-24
2543 *localDate = dt;
executed 9 times by 1 test: *localDate = dt;
Executed by:
  • tst_QDateTime
9
2544 if (localTime)
localTimeDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_QDateTime
9-24
2545 *localTime = tm;
executed 9 times by 1 test: *localTime = tm;
Executed by:
  • tst_QDateTime
9
2546 return utcMsecs;
executed 33 times by 1 test: return utcMsecs;
Executed by:
  • tst_QDateTime
33
2547 }-
2548 }
executed 9 times by 1 test: end of block
Executed by:
  • tst_QDateTime
9
2549 // Use existing method to fake the conversion, but this is deeply flawed as it may-
2550 // apply the conversion from the wrong day number, e.g. if rule is last Sunday of month-
2551 // TODO Use QTimeZone when available to apply the future rule correctly-
2552 int year, month, day;-
2553 dt.getDate(&year, &month, &day);-
2554 // 2037 is not a leap year, so make sure date isn't Feb 29-
2555 if (month == 2 && day == 29)
month == 2Description
TRUEevaluated 75 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 15017 times by 11 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
day == 29Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_QDateTime
33-15017
2556 --day;
executed 33 times by 1 test: --day;
Executed by:
  • tst_QDateTime
33
2557 QDate fakeDate(2037, month, day);-
2558 qint64 fakeDiff = fakeDate.daysTo(dt);-
2559 qint64 utcMsecs = qt_mktime(&fakeDate, &tm, daylightStatus, abbreviation);-
2560 if (localDate)
localDateDescription
TRUEevaluated 14275 times by 11 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
FALSEevaluated 817 times by 5 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
817-14275
2561 *localDate = fakeDate.addDays(fakeDiff);
executed 14275 times by 11 tests: *localDate = fakeDate.addDays(fakeDiff);
Executed by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
14275
2562 if (localTime)
localTimeDescription
TRUEevaluated 14275 times by 11 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
FALSEevaluated 817 times by 5 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
817-14275
2563 *localTime = tm;
executed 14275 times by 11 tests: *localTime = tm;
Executed by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
14275
2564 QDate utcDate;-
2565 QTime utcTime;-
2566 msecsToTime(utcMsecs, &utcDate, &utcTime);-
2567 utcDate = utcDate.addDays(fakeDiff);-
2568 utcMsecs = timeToMSecs(utcDate, utcTime);-
2569 return utcMsecs;
executed 15092 times by 11 tests: return utcMsecs;
Executed by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
15092
2570-
2571 } else {-
2572-
2573 // Clearly falls inside 1970-2037 suported range so can use mktime-
2574 qint64 utcMsecs = qt_mktime(&dt, &tm, daylightStatus, abbreviation);-
2575 if (localDate)
localDateDescription
TRUEevaluated 13910084 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
FALSEevaluated 1877 times by 30 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QComboBox
  • tst_QDBusAbstractAdaptor
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QFileInfo
  • tst_QFrame
  • tst_QFtp
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QLabel
  • tst_QLockFile
  • tst_QMetaType
  • tst_QMimeDatabase
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPixmap
  • tst_QPixmapFilter
  • tst_QSignalSpy
  • tst_QSqlQuery
  • tst_QSqlTableModel
  • ...
1877-13910084
2576 *localDate = dt;
executed 13916853 times by 101 tests: *localDate = dt;
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13916853
2577 if (localTime)
localTimeDescription
TRUEevaluated 13916978 times by 101 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
FALSEevaluated 1877 times by 30 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QComboBox
  • tst_QDBusAbstractAdaptor
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QFileInfo
  • tst_QFrame
  • tst_QFtp
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QLabel
  • tst_QLockFile
  • tst_QMetaType
  • tst_QMimeDatabase
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPixmap
  • tst_QPixmapFilter
  • tst_QSignalSpy
  • tst_QSqlQuery
  • tst_QSqlTableModel
  • ...
1877-13916978
2578 *localTime = tm;
executed 13911926 times by 101 tests: *localTime = tm;
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13911926
2579 return utcMsecs;
executed 13897955 times by 101 tests: return utcMsecs;
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13897955
2580-
2581 }-
2582}-
2583-
2584/*****************************************************************************-
2585 QDateTimePrivate member functions-
2586 *****************************************************************************/-
2587-
2588QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,-
2589 int offsetSeconds)-
2590 : m_msecs(0),-
2591 m_spec(Qt::LocalTime),-
2592 m_offsetFromUtc(0),-
2593 m_status(0)-
2594{-
2595 setTimeSpec(toSpec, offsetSeconds);-
2596 setDateTime(toDate, toTime);-
2597}
executed 65868 times by 35 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QHttpNetworkConnection
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QSettings
  • tst_QSqlQuery
  • ...
65868
2598-
2599#ifndef QT_BOOTSTRAPPED-
2600QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime,-
2601 const QTimeZone &toTimeZone)-
2602 : m_spec(Qt::TimeZone),-
2603 m_offsetFromUtc(0),-
2604 m_timeZone(toTimeZone),-
2605 m_status(0)-
2606{-
2607 setDateTime(toDate, toTime);-
2608}
executed 22 times by 1 test: end of block
Executed by:
  • tst_QDateTime
22
2609#endif // QT_BOOTSTRAPPED-
2610-
2611void QDateTimePrivate::setTimeSpec(Qt::TimeSpec spec, int offsetSeconds)-
2612{-
2613 clearValidDateTime();-
2614 clearSetToDaylightStatus();-
2615-
2616#ifndef QT_BOOTSTRAPPED-
2617 m_timeZone = QTimeZone();-
2618#endif // QT_BOOTSTRAPPED-
2619-
2620 switch (spec) {-
2621 case Qt::OffsetFromUTC:
executed 232 times by 4 tests: case Qt::OffsetFromUTC:
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QSettings
  • tst_selftests - unknown status
232
2622 if (offsetSeconds == 0) {
offsetSeconds == 0Description
TRUEevaluated 74 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
FALSEevaluated 158 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QSettings
  • tst_selftests - unknown status
74-158
2623 m_spec = Qt::UTC;-
2624 m_offsetFromUtc = 0;-
2625 } else {
executed 74 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
74
2626 m_spec = Qt::OffsetFromUTC;-
2627 m_offsetFromUtc = offsetSeconds;-
2628 }
executed 158 times by 4 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QSettings
  • tst_selftests - unknown status
158
2629 break;
executed 232 times by 4 tests: break;
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QSettings
  • tst_selftests - unknown status
232
2630 case Qt::TimeZone:
never executed: case Qt::TimeZone:
0
2631 // Use system time zone instead-
2632 m_spec = Qt::LocalTime;-
2633 m_offsetFromUtc = 0;-
2634 break;
never executed: break;
0
2635 case Qt::UTC:
executed 60671 times by 27 tests: case Qt::UTC:
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QPrinter
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
  • tst_QVariant
  • tst_QXmlInputSource
  • ...
60671
2636 case Qt::LocalTime:
executed 6970249 times by 102 tests: case Qt::LocalTime:
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
6970249
2637 m_spec = spec;-
2638 m_offsetFromUtc = 0;-
2639 break;
executed 7029386 times by 108 tests: break;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
7029386
2640 }-
2641}
executed 7030619 times by 108 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
7030619
2642-
2643void QDateTimePrivate::setDateTime(const QDate &date, const QTime &time)-
2644{-
2645 // If the date is valid and the time is not we set time to 00:00:00-
2646 QTime useTime = time;-
2647 if (!useTime.isValid() && date.isValid())
!useTime.isValid()Description
TRUEevaluated 1616 times by 14 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QStyleSheetStyle
  • tst_QTimeZone
  • tst_QVariant
FALSEevaluated 7021350 times by 106 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
date.isValid()Description
TRUEevaluated 1320 times by 6 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
  • tst_QTimeZone
FALSEevaluated 296 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QFtp
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
296-7021350
2648 useTime = QTime::fromMSecsSinceStartOfDay(0);
executed 1320 times by 6 tests: useTime = QTime::fromMSecsSinceStartOfDay(0);
Executed by:
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
  • tst_QTimeZone
1320
2649-
2650 StatusFlags newStatus;-
2651-
2652 // Set date value and status-
2653 qint64 days = 0;-
2654 if (date.isValid()) {
date.isValid()Description
TRUEevaluated 7025544 times by 106 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
FALSEevaluated 340 times by 10 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
340-7025544
2655 days = date.toJulianDay() - JULIAN_DAY_FOR_EPOCH;-
2656 newStatus = ValidDate;-
2657 } else if (date.isNull()) {
executed 7025544 times by 106 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
date.isNull()Description
TRUEevaluated 340 times by 10 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
FALSEnever evaluated
0-7025544
2658 newStatus = NullDate;-
2659 }
executed 340 times by 10 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
340
2660-
2661 // Set time value and status-
2662 int ds = 0;-
2663 if (useTime.isValid()) {
useTime.isValid()Description
TRUEevaluated 7025588 times by 106 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
FALSEevaluated 296 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QFtp
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
296-7025588
2664 ds = useTime.msecsSinceStartOfDay();-
2665 newStatus |= ValidTime;-
2666 } else if (time.isNull()) {
executed 7025588 times by 106 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
time.isNull()Description
TRUEevaluated 296 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QFtp
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
FALSEnever evaluated
0-7025588
2667 newStatus |= NullTime;-
2668 }
executed 296 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QFtp
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
296
2669-
2670 // Set msecs serial value-
2671 m_msecs = (days * MSECS_PER_DAY) + ds;-
2672 m_status = newStatus;-
2673-
2674 // Set if date and time are valid-
2675 checkValidDateTime();-
2676}
executed 7024909 times by 106 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
7024909
2677-
2678QPair<QDate, QTime> QDateTimePrivate::getDateTime() const-
2679{-
2680 QPair<QDate, QTime> result;-
2681 msecsToTime(m_msecs, &result.first, &result.second);-
2682-
2683 if (isNullDate())
isNullDate()Description
TRUEevaluated 122 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
FALSEevaluated 7294 times by 13 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSqlTableModel
  • tst_QVariant
  • tst_qmakelib
122-7294
2684 result.first = QDate();
executed 122 times by 5 tests: result.first = QDate();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
122
2685-
2686 if (isNullTime())
isNullTime()Description
TRUEevaluated 122 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
FALSEevaluated 7294 times by 13 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSqlTableModel
  • tst_QVariant
  • tst_qmakelib
122-7294
2687 result.second = QTime();
executed 122 times by 5 tests: result.second = QTime();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
122
2688-
2689 return result;
executed 7416 times by 14 tests: return result;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSqlTableModel
  • tst_QVariant
  • tst_qmakelib
7416
2690}-
2691-
2692// Set the Daylight Status if LocalTime set via msecs-
2693void QDateTimePrivate::setDaylightStatus(QDateTimePrivate::DaylightStatus status)-
2694{-
2695 if (status == DaylightTime) {
status == DaylightTimeDescription
TRUEevaluated 6952454 times by 94 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
FALSEevaluated 775 times by 28 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCookieJar
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QSystemTrayIcon
  • tst_QTextEdit
  • ...
775-6952454
2696 m_status = m_status & ~SetToStandardTime;-
2697 m_status = m_status | SetToDaylightTime;-
2698 } else if (status == StandardTime) {
executed 6949731 times by 94 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
status == StandardTimeDescription
TRUEevaluated 775 times by 28 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCookieJar
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QSystemTrayIcon
  • tst_QTextEdit
  • ...
FALSEnever evaluated
0-6949731
2699 m_status = m_status & ~SetToDaylightTime;-
2700 m_status = m_status | SetToStandardTime;-
2701 } else {
executed 775 times by 28 tests: end of block
Executed by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCookieJar
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QSystemTrayIcon
  • tst_QTextEdit
  • ...
775
2702 clearSetToDaylightStatus();-
2703 }
never executed: end of block
0
2704}-
2705-
2706// Get the DST Status if LocalTime set via msecs-
2707QDateTimePrivate::DaylightStatus QDateTimePrivate::daylightStatus() const-
2708{-
2709 if ((m_status & SetToDaylightTime) == SetToDaylightTime)
(m_status & Se...ToDaylightTimeDescription
TRUEevaluated 6950825 times by 94 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
FALSEevaluated 6982577 times by 102 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
6950825-6982577
2710 return DaylightTime;
executed 6953018 times by 94 tests: return DaylightTime;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
6953018
2711 if ((m_status & SetToStandardTime) == SetToStandardTime)
(m_status & Se...ToStandardTimeDescription
TRUEevaluated 1597 times by 28 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCookieJar
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QSystemTrayIcon
  • tst_QTextEdit
  • ...
FALSEevaluated 6980347 times by 102 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
1597-6980347
2712 return StandardTime;
executed 1597 times by 28 tests: return StandardTime;
Executed by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QNetworkCookieJar
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QSystemTrayIcon
  • tst_QTextEdit
  • ...
1597
2713 return UnknownDaylightTime;
executed 6979957 times by 102 tests: return UnknownDaylightTime;
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
6979957
2714}-
2715-
2716qint64 QDateTimePrivate::toMSecsSinceEpoch() const-
2717{-
2718 switch (m_spec) {-
2719 case Qt::OffsetFromUTC:
executed 191 times by 3 tests: case Qt::OffsetFromUTC:
Executed by:
  • tst_QDateTime
  • tst_QSettings
  • tst_selftests - unknown status
191
2720 case Qt::UTC:
executed 134509 times by 23 tests: case Qt::UTC:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_selftests - unknown status
134509
2721 return (m_msecs - (m_offsetFromUtc * 1000));
executed 134700 times by 24 tests: return (m_msecs - (m_offsetFromUtc * 1000));
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_selftests - unknown status
134700
2722-
2723 case Qt::LocalTime: {
executed 3536 times by 26 tests: case Qt::LocalTime:
Executed by:
  • tst_NetworkSelfTest
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QDBusAbstractAdaptor
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QFrame
  • tst_QFtp
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QLabel
  • tst_QLockFile
  • tst_QMimeDatabase
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPixmap
  • tst_QPixmapFilter
  • tst_QSqlQuery
  • tst_QSqlTableModel
  • tst_QSslCertificate
  • tst_QStyle
  • tst_QStyleSheetStyle
  • ...
3536
2724 // recalculate the local timezone-
2725 DaylightStatus status = daylightStatus();-
2726 return localMSecsToEpochMSecs(m_msecs, &status);
executed 3536 times by 26 tests: return localMSecsToEpochMSecs(m_msecs, &status);
Executed by:
  • tst_NetworkSelfTest
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QDBusAbstractAdaptor
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QFrame
  • tst_QFtp
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QLabel
  • tst_QLockFile
  • tst_QMimeDatabase
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPixmap
  • tst_QPixmapFilter
  • tst_QSqlQuery
  • tst_QSqlTableModel
  • tst_QSslCertificate
  • tst_QStyle
  • tst_QStyleSheetStyle
  • ...
3536
2727 }-
2728-
2729 case Qt::TimeZone:
executed 490 times by 2 tests: case Qt::TimeZone:
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
490
2730#ifdef QT_BOOTSTRAPPED-
2731 return 0;-
2732#else-
2733 return zoneMSecsToEpochMSecs(m_msecs, m_timeZone);
executed 490 times by 2 tests: return zoneMSecsToEpochMSecs(m_msecs, m_timeZone);
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
490
2734#endif-
2735 }-
2736 Q_UNREACHABLE();-
2737 return 0;
never executed: return 0;
0
2738}-
2739-
2740// Check the UTC / offsetFromUTC validity-
2741void QDateTimePrivate::checkValidDateTime()-
2742{-
2743 switch (m_spec) {-
2744 case Qt::OffsetFromUTC:
executed 204 times by 4 tests: case Qt::OffsetFromUTC:
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QSettings
  • tst_selftests - unknown status
204
2745 case Qt::UTC:
executed 49310 times by 24 tests: case Qt::UTC:
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
  • tst_QVariant
  • tst_Spdy
  • tst_selftests - unknown status
49310
2746 // for these, a valid date and a valid time imply a valid QDateTime-
2747 if (isValidDate() && isValidTime())
isValidDate()Description
TRUEevaluated 48991 times by 24 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
  • tst_Spdy
  • tst_selftests - unknown status
FALSEevaluated 523 times by 6 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QVariant
isValidTime()Description
TRUEevaluated 48991 times by 24 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
  • tst_Spdy
  • tst_selftests - unknown status
FALSEnever evaluated
0-48991
2748 setValidDateTime();
executed 48991 times by 24 tests: setValidDateTime();
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
  • tst_Spdy
  • tst_selftests - unknown status
48991
2749 else-
2750 clearValidDateTime();
executed 523 times by 6 tests: clearValidDateTime();
Executed by:
  • tst_QDateTime
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QVariant
523
2751 break;
executed 49514 times by 25 tests: break;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
  • tst_QVariant
  • tst_Spdy
  • tst_selftests - unknown status
49514
2752 case Qt::TimeZone:
executed 22 times by 1 test: case Qt::TimeZone:
Executed by:
  • tst_QDateTime
22
2753 case Qt::LocalTime:
executed 6974689 times by 102 tests: case Qt::LocalTime:
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
6974689
2754 // for these, we need to check whether the timezone is valid and whether-
2755 // the time is valid in that timezone. Expensive, but no other option.-
2756 refreshDateTime();-
2757 break;
executed 6977946 times by 102 tests: break;
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
6977946
2758 }-
2759}
executed 7027460 times by 106 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • ...
7027460
2760-
2761// Refresh the LocalTime validity and offset-
2762void QDateTimePrivate::refreshDateTime()-
2763{-
2764 switch (m_spec) {-
2765 case Qt::OffsetFromUTC:
never executed: case Qt::OffsetFromUTC:
0
2766 case Qt::UTC:
never executed: case Qt::UTC:
0
2767 // Always set by setDateTime so just return-
2768 return;
never executed: return;
0
2769 case Qt::TimeZone:
executed 525 times by 2 tests: case Qt::TimeZone:
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
525
2770 case Qt::LocalTime:
executed 13931153 times by 102 tests: case Qt::LocalTime:
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13931153
2771 break;
executed 13931678 times by 102 tests: break;
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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13931678
2772 }-
2773-
2774 // If not valid date and time then is invalid-
2775 if (!isValidDate() || !isValidTime()) {
!isValidDate()Description
TRUEevaluated 366 times by 10 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
FALSEevaluated 13931312 times by 102 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
!isValidTime()Description
TRUEnever evaluated
FALSEevaluated 13931312 times by 102 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
0-13931312
2776 clearValidDateTime();-
2777 m_offsetFromUtc = 0;-
2778 return;
executed 366 times by 10 tests: return;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QMetaType
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
366
2779 }-
2780-
2781#ifndef QT_BOOTSTRAPPED-
2782 // If not valid time zone then is invalid-
2783 if (m_spec == Qt::TimeZone && !m_timeZone.isValid()) {
m_spec == Qt::TimeZoneDescription
TRUEevaluated 504 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 13930808 times by 102 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
!m_timeZone.isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 503 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
1-13930808
2784 clearValidDateTime();-
2785 m_offsetFromUtc = 0;-
2786 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QDateTime
1
2787 }-
2788#endif // QT_BOOTSTRAPPED-
2789-
2790 // We have a valid date and time and a Qt::LocalTime or Qt::TimeZone that needs calculating-
2791 // LocalTime and TimeZone might fall into a "missing" DST transition hour-
2792 // Calling toEpochMSecs will adjust the returned date/time if it does-
2793 QDate testDate;-
2794 QTime testTime;-
2795 qint64 epochMSecs = 0;-
2796 if (m_spec == Qt::LocalTime) {
m_spec == Qt::LocalTimeDescription
TRUEevaluated 13930808 times by 102 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
FALSEevaluated 503 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
503-13930808
2797 DaylightStatus status = daylightStatus();-
2798 epochMSecs = localMSecsToEpochMSecs(m_msecs, &status, &testDate, &testTime);-
2799#ifndef QT_BOOTSTRAPPED-
2800 } else {
executed 13930808 times by 102 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13930808
2801 epochMSecs = zoneMSecsToEpochMSecs(m_msecs, m_timeZone, &testDate, &testTime);-
2802#endif // QT_BOOTSTRAPPED-
2803 }
executed 503 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
503
2804 if (timeToMSecs(testDate, testTime) == m_msecs) {
timeToMSecs(te...me) == m_msecsDescription
TRUEevaluated 13931307 times by 102 tests
Evaluated 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QDateTime
4-13931307
2805 setValidDateTime();-
2806 // Cache the offset to use in toMSecsSinceEpoch()-
2807 m_offsetFromUtc = (m_msecs - epochMSecs) / 1000;-
2808 } else {
executed 13931307 times by 102 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_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QErrorMessage
  • ...
13931307
2809 clearValidDateTime();-
2810 m_offsetFromUtc = 0;-
2811 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QDateTime
4
2812}-
2813-
2814#ifndef QT_BOOTSTRAPPED-
2815// Convert a TimeZone time expressed in zone msecs encoding into a UTC epoch msecs-
2816qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone &zone,-
2817 QDate *localDate, QTime *localTime)-
2818{-
2819 // Get the effective data from QTimeZone-
2820 QTimeZonePrivate::Data data = zone.d->dataForLocalTime(zoneMSecs);-
2821 // Docs state any LocalTime before 1970-01-01 will *not* have any DST applied-
2822 // but all affected times afterwards will have DST applied.-
2823 if (data.atMSecsSinceEpoch >= 0) {
data.atMSecsSinceEpoch >= 0Description
TRUEevaluated 988 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QTimeZone
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QDateTime
5-988
2824 msecsToTime(data.atMSecsSinceEpoch + (data.offsetFromUtc * 1000), localDate, localTime);-
2825 return data.atMSecsSinceEpoch;
executed 988 times by 2 tests: return data.atMSecsSinceEpoch;
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
988
2826 } else {-
2827 msecsToTime(zoneMSecs, localDate, localTime);-
2828 return zoneMSecs - (data.standardTimeOffset * 1000);
executed 5 times by 1 test: return zoneMSecs - (data.standardTimeOffset * 1000);
Executed by:
  • tst_QDateTime
5
2829 }-
2830}-
2831#endif // QT_BOOTSTRAPPED-
2832-
2833/*****************************************************************************-
2834 QDateTime member functions-
2835 *****************************************************************************/-
2836-
2837/*!-
2838 \class QDateTime-
2839 \inmodule QtCore-
2840 \ingroup shared-
2841 \reentrant-
2842 \brief The QDateTime class provides date and time functions.-
2843-
2844-
2845 A QDateTime object contains a calendar date and a clock time (a-
2846 "datetime"). It is a combination of the QDate and QTime classes.-
2847 It can read the current datetime from the system clock. It-
2848 provides functions for comparing datetimes and for manipulating a-
2849 datetime by adding a number of seconds, days, months, or years.-
2850-
2851 A QDateTime object is typically created either by giving a date-
2852 and time explicitly in the constructor, or by using the static-
2853 function currentDateTime() that returns a QDateTime object set-
2854 to the system clock's time. The date and time can be changed with-
2855 setDate() and setTime(). A datetime can also be set using the-
2856 setTime_t() function that takes a POSIX-standard "number of-
2857 seconds since 00:00:00 on January 1, 1970" value. The fromString()-
2858 function returns a QDateTime, given a string and a date format-
2859 used to interpret the date within the string.-
2860-
2861 The date() and time() functions provide access to the date and-
2862 time parts of the datetime. The same information is provided in-
2863 textual format by the toString() function.-
2864-
2865 QDateTime provides a full set of operators to compare two-
2866 QDateTime objects, where smaller means earlier and larger means-
2867 later.-
2868-
2869 You can increment (or decrement) a datetime by a given number of-
2870 milliseconds using addMSecs(), seconds using addSecs(), or days-
2871 using addDays(). Similarly, you can use addMonths() and addYears().-
2872 The daysTo() function returns the number of days between two datetimes,-
2873 secsTo() returns the number of seconds between two datetimes, and-
2874 msecsTo() returns the number of milliseconds between two datetimes.-
2875-
2876 QDateTime can store datetimes as \l{Qt::LocalTime}{local time} or-
2877 as \l{Qt::UTC}{UTC}. QDateTime::currentDateTime() returns a-
2878 QDateTime expressed as local time; use toUTC() to convert it to-
2879 UTC. You can also use timeSpec() to find out if a QDateTime-
2880 object stores a UTC time or a local time. Operations such as-
2881 addSecs() and secsTo() are aware of daylight-saving time (DST).-
2882-
2883 \note QDateTime does not account for leap seconds.-
2884-
2885 \section1-
2886-
2887 \section2 No Year 0-
2888-
2889 There is no year 0. Dates in that year are considered invalid. The-
2890 year -1 is the year "1 before Christ" or "1 before current era."-
2891 The day before 1 January 1 CE is 31 December 1 BCE.-
2892-
2893 \section2 Range of Valid Dates-
2894-
2895 The range of valid values able to be stored in QDateTime is dependent on-
2896 the internal storage implementation. QDateTime is currently stored in a-
2897 qint64 as a serial msecs value encoding the date and time. This restricts-
2898 the date range to about +/- 292 million years, compared to the QDate range-
2899 of +/- 2 billion years. Care must be taken when creating a QDateTime with-
2900 extreme values that you do not overflow the storage. The exact range of-
2901 supported values varies depending on the Qt::TimeSpec and time zone.-
2902-
2903 \section2-
2904 Use of System Timezone-
2905-
2906 QDateTime uses the system's time zone information to determine the-
2907 offset of local time from UTC. If the system is not configured-
2908 correctly or not up-to-date, QDateTime will give wrong results as-
2909 well.-
2910-
2911 \section2 Daylight-Saving Time (DST)-
2912-
2913 QDateTime takes into account the system's time zone information-
2914 when dealing with DST. On modern Unix systems, this means it-
2915 applies the correct historical DST data whenever possible. On-
2916 Windows, where the system doesn't support historical DST data,-
2917 historical accuracy is not maintained with respect to DST.-
2918-
2919 The range of valid dates taking DST into account is 1970-01-01 to-
2920 the present, and rules are in place for handling DST correctly-
2921 until 2037-12-31, but these could change. For dates falling-
2922 outside that range, QDateTime makes a \e{best guess} using the-
2923 rules for year 1970 or 2037, but we can't guarantee accuracy. This-
2924 means QDateTime doesn't take into account changes in a locale's-
2925 time zone before 1970, even if the system's time zone database-
2926 supports that information.-
2927-
2928 QDateTime takes into consideration the Standard Time to Daylight-Saving Time-
2929 transition. For example if the transition is at 2am and the clock goes-
2930 forward to 3am, then there is a "missing" hour from 02:00:00 to 02:59:59.999-
2931 which QDateTime considers to be invalid. Any date maths performed-
2932 will take this missing hour into account and return a valid result.-
2933-
2934 \section2 Offset From UTC-
2935-
2936 A Qt::TimeSpec of Qt::OffsetFromUTC is also supported. This allows you-
2937 to define a QDateTime relative to UTC at a fixed offset of a given number-
2938 of seconds from UTC. For example, an offset of +3600 seconds is one hour-
2939 ahead of UTC and is usually written in ISO standard notation as-
2940 "UTC+01:00". Daylight-Saving Time never applies with this TimeSpec.-
2941-
2942 There is no explicit size restriction to the offset seconds, but there is-
2943 an implicit limit imposed when using the toString() and fromString()-
2944 methods which use a format of [+|-]hh:mm, effectively limiting the range-
2945 to +/- 99 hours and 59 minutes and whole minutes only. Note that currently-
2946 no time zone lies outside the range of +/- 14 hours.-
2947-
2948 \section2 Time Zone Support-
2949-
2950 A Qt::TimeSpec of Qt::TimeZone is also supported in conjunction with the-
2951 QTimeZone class. This allows you to define a datetime in a named time zone-
2952 adhering to a consistent set of daylight-saving transition rules. For-
2953 example a time zone of "Europe/Berlin" will apply the daylight-saving-
2954 rules as used in Germany since 1970. Note that the transition rules-
2955 applied depend on the platform support. See the QTimeZone documentation-
2956 for more details.-
2957-
2958 \sa QDate, QTime, QDateTimeEdit, QTimeZone-
2959*/-
2960-
2961/*!-
2962 Constructs a null datetime (i.e. null date and null time). A null-
2963 datetime is invalid, since the date is invalid.-
2964-
2965 \sa isValid()-
2966*/-
2967QDateTime::QDateTime()-
2968 : d(*defaultDateTimePrivate())-
2969{-
2970}
executed 7103614 times by 127 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
  • ...
7103614
2971-
2972-
2973/*!-
2974 Constructs a datetime with the given \a date, a valid-
2975 time(00:00:00.000), and sets the timeSpec() to Qt::LocalTime.-
2976*/-
2977-
2978QDateTime::QDateTime(const QDate &date)-
2979 : d(new QDateTimePrivate(date, QTime(0, 0, 0), Qt::LocalTime, 0))-
2980{-
2981}
executed 6 times by 3 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QVariant
6
2982-
2983/*!-
2984 Constructs a datetime with the given \a date and \a time, using-
2985 the time specification defined by \a spec.-
2986-
2987 If \a date is valid and \a time is not, the time will be set to midnight.-
2988-
2989 If \a spec is Qt::OffsetFromUTC then it will be set to Qt::UTC, i.e. an-
2990 offset of 0 seconds. To create a Qt::OffsetFromUTC datetime use the-
2991 correct constructor.-
2992-
2993 If \a spec is Qt::TimeZone then the spec will be set to Qt::LocalTime,-
2994 i.e. the current system time zone. To create a Qt::TimeZone datetime-
2995 use the correct constructor.-
2996*/-
2997-
2998QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)-
2999 : d(new QDateTimePrivate(date, time, spec, 0))-
3000{-
3001}
executed 65590 times by 34 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QHttpNetworkConnection
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QNoDebug
  • tst_QSqlQuery
  • tst_QSslCertificate
  • ...
65590
3002-
3003/*!-
3004 \since 5.2-
3005-
3006 Constructs a datetime with the given \a date and \a time, using-
3007 the time specification defined by \a spec and \a offsetSeconds seconds.-
3008-
3009 If \a date is valid and \a time is not, the time will be set to midnight.-
3010-
3011 If the \a spec is not Qt::OffsetFromUTC then \a offsetSeconds will be ignored.-
3012-
3013 If the \a spec is Qt::OffsetFromUTC and \a offsetSeconds is 0 then the-
3014 timeSpec() will be set to Qt::UTC, i.e. an offset of 0 seconds.-
3015-
3016 If \a spec is Qt::TimeZone then the spec will be set to Qt::LocalTime,-
3017 i.e. the current system time zone. To create a Qt::TimeZone datetime-
3018 use the correct constructor.-
3019*/-
3020-
3021QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, int offsetSeconds)-
3022 : d(new QDateTimePrivate(date, time, spec, offsetSeconds))-
3023{-
3024}
executed 272 times by 7 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QSqlQuery
  • tst_QVariant
  • tst_selftests - unknown status
272
3025-
3026#ifndef QT_BOOTSTRAPPED-
3027/*!-
3028 \since 5.2-
3029-
3030 Constructs a datetime with the given \a date and \a time, using-
3031 the Time Zone specified by \a timeZone.-
3032-
3033 If \a date is valid and \a time is not, the time will be set to 00:00:00.-
3034-
3035 If \a timeZone is invalid then the datetime will be invalid.-
3036*/-
3037-
3038QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone)-
3039 : d(new QDateTimePrivate(date, time, timeZone))-
3040{-
3041}
executed 22 times by 1 test: end of block
Executed by:
  • tst_QDateTime
22
3042#endif // QT_BOOTSTRAPPED-
3043-
3044/*!-
3045 Constructs a copy of the \a other datetime.-
3046*/-
3047-
3048QDateTime::QDateTime(const QDateTime &other)-
3049 : d(other.d)-
3050{-
3051}
executed 479775 times by 63 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QButtonGroup
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFontDialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QGroupBox
  • tst_QHttpNetworkConnection
  • tst_QIcon
  • ...
479775
3052-
3053/*!-
3054 Destroys the datetime.-
3055*/-
3056QDateTime::~QDateTime()-
3057{-
3058}-
3059-
3060/*!-
3061 Makes a copy of the \a other datetime and returns a reference to the-
3062 copy.-
3063*/-
3064-
3065QDateTime &QDateTime::operator=(const QDateTime &other)-
3066{-
3067 d = other.d;-
3068 return *this;
executed 1834 times by 12 tests: return *this;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSslCertificate
  • tst_QSslSocket
1834
3069}-
3070/*!-
3071 \fn void QDateTime::swap(QDateTime &other)-
3072 \since 5.0-
3073-
3074 Swaps this datetime with \a other. This operation is very fast-
3075 and never fails.-
3076*/-
3077-
3078/*!-
3079 Returns \c true if both the date and the time are null; otherwise-
3080 returns \c false. A null datetime is invalid.-
3081-
3082 \sa QDate::isNull(), QTime::isNull(), isValid()-
3083*/-
3084-
3085bool QDateTime::isNull() const-
3086{-
3087 return d->isNullDate() && d->isNullTime();
executed 4899 times by 10 tests: return d->isNullDate() && d->isNullTime();
Executed by:
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSqlQuery
  • tst_QStyleSheetStyle
  • tst_QVariant
  • tst_QXmlStream
4899
3088}-
3089-
3090/*!-
3091 Returns \c true if both the date and the time are valid and they are valid in-
3092 the current Qt::TimeSpec, otherwise returns \c false.-
3093-
3094 If the timeSpec() is Qt::LocalTime or Qt::TimeZone then the date and time are-
3095 checked to see if they fall in the Standard Time to Daylight-Saving Time transition-
3096 hour, i.e. if the transition is at 2am and the clock goes forward to 3am-
3097 then the time from 02:00:00 to 02:59:59.999 is considered to be invalid.-
3098-
3099 \sa QDate::isValid(), QTime::isValid()-
3100*/-
3101-
3102bool QDateTime::isValid() const-
3103{-
3104 return (d->isValidDateTime());
executed 110720 times by 76 tests: return (d->isValidDateTime());
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontDialog
  • tst_QFrame
  • tst_QFtp
  • ...
110720
3105}-
3106-
3107/*!-
3108 Returns the date part of the datetime.-
3109-
3110 \sa setDate(), time(), timeSpec()-
3111*/-
3112-
3113QDate QDateTime::date() const-
3114{-
3115 if (d->isNullDate())
d->isNullDate()Description
TRUEevaluated 71 times by 6 tests
Evaluated by:
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDBusMetaType
  • tst_QDateTime
  • tst_qdbuscpp2xml
  • tst_qdbuscpp2xml - unknown status
FALSEevaluated 70844 times by 43 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • ...
71-70844
3116 return QDate();
executed 71 times by 6 tests: return QDate();
Executed by:
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDBusMetaType
  • tst_QDateTime
  • tst_qdbuscpp2xml
  • tst_qdbuscpp2xml - unknown status
71
3117 QDate dt;-
3118 msecsToTime(d->m_msecs, &dt, 0);-
3119 return dt;
executed 70844 times by 43 tests: return dt;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QItemDelegate
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • ...
70844
3120}-
3121-
3122/*!-
3123 Returns the time part of the datetime.-
3124-
3125 \sa setTime(), date(), timeSpec()-
3126*/-
3127-
3128QTime QDateTime::time() const-
3129{-
3130 if (d->isNullTime())
d->isNullTime()Description
TRUEevaluated 70 times by 6 tests
Evaluated by:
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDBusMetaType
  • tst_QDateTime
  • tst_qdbuscpp2xml
  • tst_qdbuscpp2xml - unknown status
FALSEevaluated 6983912 times by 72 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QFutureWatcher
  • ...
70-6983912
3131 return QTime();
executed 70 times by 6 tests: return QTime();
Executed by:
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDBusMetaType
  • tst_QDateTime
  • tst_qdbuscpp2xml
  • tst_qdbuscpp2xml - unknown status
70
3132 QTime tm;-
3133 msecsToTime(d->m_msecs, 0, &tm);-
3134 return tm;
executed 6983912 times by 72 tests: return tm;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFtp
  • tst_QFutureWatcher
  • ...
6983912
3135}-
3136-
3137/*!-
3138 Returns the time specification of the datetime.-
3139-
3140 \sa setTimeSpec(), date(), time(), Qt::TimeSpec-
3141*/-
3142-
3143Qt::TimeSpec QDateTime::timeSpec() const-
3144{-
3145 return d->m_spec;
executed 2071 times by 18 tests: return d->m_spec;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDBusMetaType
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNoDebug
  • tst_QSettings
  • tst_QVariant
  • tst_qdbuscpp2xml
  • tst_qdbuscpp2xml - unknown status
  • tst_qmakelib
2071
3146}-
3147-
3148#ifndef QT_BOOTSTRAPPED-
3149/*!-
3150 \since 5.2-
3151-
3152 Returns the time zone of the datetime.-
3153-
3154 If the timeSpec() is Qt::LocalTime then an instance of the current system-
3155 time zone will be returned. Note however that if you copy this time zone-
3156 the instance will not remain in sync if the system time zone changes.-
3157-
3158 \sa setTimeZone(), Qt::TimeSpec-
3159*/-
3160-
3161QTimeZone QDateTime::timeZone() const-
3162{-
3163 switch (d->m_spec) {-
3164 case Qt::UTC:
never executed: case Qt::UTC:
0
3165 return QTimeZone::utc();
never executed: return QTimeZone::utc();
0
3166 case Qt::OffsetFromUTC:
executed 1 time by 1 test: case Qt::OffsetFromUTC:
Executed by:
  • tst_QDateTime
1
3167 return QTimeZone(d->m_offsetFromUtc);
executed 1 time by 1 test: return QTimeZone(d->m_offsetFromUtc);
Executed by:
  • tst_QDateTime
1
3168 case Qt::TimeZone:
executed 22 times by 1 test: case Qt::TimeZone:
Executed by:
  • tst_QDateTime
22
3169 Q_ASSERT(d->m_timeZone.isValid());-
3170 return d->m_timeZone;
executed 22 times by 1 test: return d->m_timeZone;
Executed by:
  • tst_QDateTime
22
3171 case Qt::LocalTime:
never executed: case Qt::LocalTime:
0
3172 return QTimeZone::systemTimeZone();
never executed: return QTimeZone::systemTimeZone();
0
3173 }-
3174 return QTimeZone();
never executed: return QTimeZone();
0
3175}-
3176#endif // QT_BOOTSTRAPPED-
3177-
3178/*!-
3179 \since 5.2-
3180-
3181 Returns the current Offset From UTC in seconds.-
3182-
3183 If the timeSpec() is Qt::OffsetFromUTC this will be the value originally set.-
3184-
3185 If the timeSpec() is Qt::TimeZone this will be the offset effective in the-
3186 Time Zone including any Daylight-Saving Offset.-
3187-
3188 If the timeSpec() is Qt::LocalTime this will be the difference between the-
3189 Local Time and UTC including any Daylight-Saving Offset.-
3190-
3191 If the timeSpec() is Qt::UTC this will be 0.-
3192-
3193 \sa setOffsetFromUtc()-
3194*/-
3195-
3196int QDateTime::offsetFromUtc() const-
3197{-
3198 return d->m_offsetFromUtc;
executed 580 times by 4 tests: return d->m_offsetFromUtc;
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QSettings
  • tst_QTimeZone
580
3199}-
3200-
3201/*!-
3202 \since 5.2-
3203-
3204 Returns the Time Zone Abbreviation for the datetime.-
3205-
3206 If the timeSpec() is Qt::UTC this will be "UTC".-
3207-
3208 If the timeSpec() is Qt::OffsetFromUTC this will be in the format-
3209 "UTC[+-]00:00".-
3210-
3211 If the timeSpec() is Qt::LocalTime then the host system is queried for the-
3212 correct abbreviation.-
3213-
3214 Note that abbreviations may or may not be localized.-
3215-
3216 Note too that the abbreviation is not guaranteed to be a unique value,-
3217 i.e. different time zones may have the same abbreviation.-
3218-
3219 \sa timeSpec()-
3220*/-
3221-
3222QString QDateTime::timeZoneAbbreviation() const-
3223{-
3224 switch (d->m_spec) {-
3225 case Qt::UTC:
executed 982 times by 6 tests: case Qt::UTC:
Executed by:
  • tst_QAsn1Element
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkReply
  • tst_QSslCertificate
  • tst_selftests - unknown status
982
3226 return QTimeZonePrivate::utcQString();
executed 982 times by 6 tests: return QTimeZonePrivate::utcQString();
Executed by:
  • tst_QAsn1Element
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkReply
  • tst_QSslCertificate
  • tst_selftests - unknown status
982
3227 case Qt::OffsetFromUTC:
executed 88 times by 2 tests: case Qt::OffsetFromUTC:
Executed by:
  • tst_QDateTime
  • tst_selftests - unknown status
88
3228 return QTimeZonePrivate::utcQString() + toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
executed 88 times by 2 tests: return QTimeZonePrivate::utcQString() + toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
Executed by:
  • tst_QDateTime
  • tst_selftests - unknown status
88
3229 case Qt::TimeZone:
executed 467 times by 2 tests: case Qt::TimeZone:
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
467
3230#ifdef QT_BOOTSTRAPPED-
3231 break;-
3232#else-
3233 return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch());
executed 467 times by 2 tests: return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch());
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
467
3234#endif // QT_BOOTSTRAPPED-
3235 case Qt::LocalTime: {
executed 1249 times by 13 tests: case Qt::LocalTime:
Executed by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileInfo
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QNoDebug
  • tst_QSignalSpy
  • tst_QTime
  • tst_QVariant
1249
3236 QString abbrev;-
3237 QDateTimePrivate::DaylightStatus status = d->daylightStatus();-
3238 localMSecsToEpochMSecs(d->m_msecs, &status, 0, 0, &abbrev);-
3239 return abbrev;
executed 1249 times by 13 tests: return abbrev;
Executed by:
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileInfo
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QNoDebug
  • tst_QSignalSpy
  • tst_QTime
  • tst_QVariant
1249
3240 }-
3241 }-
3242 return QString();
never executed: return QString();
0
3243}-
3244-
3245/*!-
3246 \since 5.2-
3247-
3248 Returns if this datetime falls in Daylight-Saving Time.-
3249-
3250 If the Qt::TimeSpec is not Qt::LocalTime or Qt::TimeZone then will always-
3251 return false.-
3252-
3253 \sa timeSpec()-
3254*/-
3255-
3256bool QDateTime::isDaylightTime() const-
3257{-
3258 switch (d->m_spec) {-
3259 case Qt::UTC:
executed 2 times by 1 test: case Qt::UTC:
Executed by:
  • tst_QDateTime
2
3260 case Qt::OffsetFromUTC:
executed 2 times by 1 test: case Qt::OffsetFromUTC:
Executed by:
  • tst_QDateTime
2
3261 return false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_QDateTime
4
3262 case Qt::TimeZone:
executed 3 times by 1 test: case Qt::TimeZone:
Executed by:
  • tst_QDateTime
3
3263#ifdef QT_BOOTSTRAPPED-
3264 break;-
3265#else-
3266 return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch());
executed 3 times by 1 test: return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch());
Executed by:
  • tst_QDateTime
3
3267#endif // QT_BOOTSTRAPPED-
3268 case Qt::LocalTime: {
executed 2 times by 1 test: case Qt::LocalTime:
Executed by:
  • tst_QDateTime
2
3269 QDateTimePrivate::DaylightStatus status = d->daylightStatus();-
3270 if (status == QDateTimePrivate::UnknownDaylightTime)
status == QDat...wnDaylightTimeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEnever evaluated
0-2
3271 localMSecsToEpochMSecs(d->m_msecs, &status);
executed 2 times by 1 test: localMSecsToEpochMSecs(d->m_msecs, &status);
Executed by:
  • tst_QDateTime
2
3272 return (status == QDateTimePrivate::DaylightTime);
executed 2 times by 1 test: return (status == QDateTimePrivate::DaylightTime);
Executed by:
  • tst_QDateTime
2
3273 }-
3274 }-
3275 return false;
never executed: return false;
0
3276}-
3277-
3278/*!-
3279 Sets the date part of this datetime to \a date. If no time is set yet, it-
3280 is set to midnight. If \a date is invalid, this QDateTime becomes invalid.-
3281-
3282 \sa date(), setTime(), setTimeSpec()-
3283*/-
3284-
3285void QDateTime::setDate(const QDate &date)-
3286{-
3287 d->setDateTime(date, time());-
3288}
executed 133 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QFtp
133
3289-
3290/*!-
3291 Sets the time part of this datetime to \a time. If \a time is not valid,-
3292 this function sets it to midnight. Therefore, it's possible to clear any-
3293 set time in a QDateTime by setting it to a default QTime:-
3294-
3295 \code-
3296 QDateTime dt = QDateTime::currentDateTime();-
3297 dt.setTime(QTime());-
3298 \endcode-
3299-
3300 \sa time(), setDate(), setTimeSpec()-
3301*/-
3302-
3303void QDateTime::setTime(const QTime &time)-
3304{-
3305 d->setDateTime(date(), time);-
3306}
executed 134 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkCookie
134
3307-
3308/*!-
3309 Sets the time specification used in this datetime to \a spec.-
3310 The datetime will refer to a different point in time.-
3311-
3312 If \a spec is Qt::OffsetFromUTC then the timeSpec() will be set-
3313 to Qt::UTC, i.e. an effective offset of 0.-
3314-
3315 If \a spec is Qt::TimeZone then the spec will be set to Qt::LocalTime,-
3316 i.e. the current system time zone.-
3317-
3318 Example:-
3319 \snippet code/src_corelib_tools_qdatetime.cpp 19-
3320-
3321 \sa timeSpec(), setDate(), setTime(), setTimeZone(), Qt::TimeSpec-
3322*/-
3323-
3324void QDateTime::setTimeSpec(Qt::TimeSpec spec)-
3325{-
3326 QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)-
3327 d->setTimeSpec(spec, 0);-
3328 d->checkValidDateTime();-
3329}
executed 1541 times by 12 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDir
  • tst_QItemModel
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QVariant
  • tst_Spdy
1541
3330-
3331/*!-
3332 \since 5.2-
3333-
3334 Sets the timeSpec() to Qt::OffsetFromUTC and the offset to \a offsetSeconds.-
3335 The datetime will refer to a different point in time.-
3336-
3337 The maximum and minimum offset is 14 positive or negative hours. If-
3338 \a offsetSeconds is larger or smaller than that, then the result is-
3339 undefined.-
3340-
3341 If \a offsetSeconds is 0 then the timeSpec() will be set to Qt::UTC.-
3342-
3343 \sa isValid(), offsetFromUtc()-
3344*/-
3345-
3346void QDateTime::setOffsetFromUtc(int offsetSeconds)-
3347{-
3348 QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)-
3349 d->setTimeSpec(Qt::OffsetFromUTC, offsetSeconds);-
3350 d->checkValidDateTime();-
3351}
executed 35 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QSettings
35
3352-
3353#ifndef QT_BOOTSTRAPPED-
3354/*!-
3355 \since 5.2-
3356-
3357 Sets the time zone used in this datetime to \a toZone.-
3358 The datetime will refer to a different point in time.-
3359-
3360 If \a toZone is invalid then the datetime will be invalid.-
3361-
3362 \sa timeZone(), Qt::TimeSpec-
3363*/-
3364-
3365void QDateTime::setTimeZone(const QTimeZone &toZone)-
3366{-
3367 QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)-
3368 d->m_spec = Qt::TimeZone;-
3369 d->m_offsetFromUtc = 0;-
3370 d->m_timeZone = toZone;-
3371 d->refreshDateTime();-
3372}
executed 483 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QTimeZone
483
3373#endif // QT_BOOTSTRAPPED-
3374-
3375/*!-
3376 \since 4.7-
3377-
3378 Returns the datetime as the number of milliseconds that have passed-
3379 since 1970-01-01T00:00:00.000, Coordinated Universal Time (Qt::UTC).-
3380-
3381 On systems that do not support time zones, this function will-
3382 behave as if local time were Qt::UTC.-
3383-
3384 The behavior for this function is undefined if the datetime stored in-
3385 this object is not valid. However, for all valid dates, this function-
3386 returns a unique value.-
3387-
3388 \sa toTime_t(), setMSecsSinceEpoch()-
3389*/-
3390qint64 QDateTime::toMSecsSinceEpoch() const-
3391{-
3392 return d->toMSecsSinceEpoch();
executed 134960 times by 21 tests: return d->toMSecsSinceEpoch();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QStyleSheetStyle
  • tst_QTimeZone
  • tst_selftests - unknown status
134960
3393}-
3394-
3395/*!-
3396 Returns the datetime as the number of seconds that have passed-
3397 since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC).-
3398-
3399 On systems that do not support time zones, this function will-
3400 behave as if local time were Qt::UTC.-
3401-
3402 \note This function returns a 32-bit unsigned integer, so it does not-
3403 support dates before 1970, but it does support dates after-
3404 2038-01-19T03:14:06, which may not be valid time_t values. Be careful-
3405 when passing those time_t values to system functions, which could-
3406 interpret them as negative dates.-
3407-
3408 If the date is outside the range 1970-01-01T00:00:00 to-
3409 2106-02-07T06:28:14, this function returns -1 cast to an unsigned integer-
3410 (i.e., 0xFFFFFFFF).-
3411-
3412 To get an extended range, use toMSecsSinceEpoch().-
3413-
3414 \sa toMSecsSinceEpoch(), setTime_t()-
3415*/-
3416-
3417uint QDateTime::toTime_t() const-
3418{-
3419 if (!isValid())
!isValid()Description
TRUEevaluated 964 times by 28 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QButtonGroup
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontDialog
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QGroupBox
  • tst_QIcon
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMdiSubWindow
  • tst_QMessageBox
  • tst_QPixmap
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTextBrowser
  • ...
FALSEevaluated 181 times by 14 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAuthenticator
  • tst_QComboBox
  • tst_QDBusAbstractAdaptor
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFrame
  • tst_QIcon
  • tst_QLabel
  • tst_QNetworkDiskCache
  • tst_QPixmap
  • tst_QPixmapFilter
  • tst_QStyle
181-964
3420 return uint(-1);
executed 964 times by 28 tests: return uint(-1);
Executed by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QButtonGroup
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontDialog
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QGroupBox
  • tst_QIcon
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMdiSubWindow
  • tst_QMessageBox
  • tst_QPixmap
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTextBrowser
  • ...
964
3421 qint64 retval = d->toMSecsSinceEpoch() / 1000;-
3422 if (quint64(retval) >= Q_UINT64_C(0xFFFFFFFF))
quint64(retval...0xFFFFFFFFULL)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 178 times by 14 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAuthenticator
  • tst_QComboBox
  • tst_QDBusAbstractAdaptor
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFrame
  • tst_QIcon
  • tst_QLabel
  • tst_QNetworkDiskCache
  • tst_QPixmap
  • tst_QPixmapFilter
  • tst_QStyle
3-178
3423 return uint(-1);
executed 3 times by 1 test: return uint(-1);
Executed by:
  • tst_QDateTime
3
3424 return uint(retval);
executed 178 times by 14 tests: return uint(retval);
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAuthenticator
  • tst_QComboBox
  • tst_QDBusAbstractAdaptor
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFrame
  • tst_QIcon
  • tst_QLabel
  • tst_QNetworkDiskCache
  • tst_QPixmap
  • tst_QPixmapFilter
  • tst_QStyle
178
3425}-
3426-
3427/*!-
3428 \since 4.7-
3429-
3430 Sets the date and time given the number of milliseconds \a msecs that have-
3431 passed since 1970-01-01T00:00:00.000, Coordinated Universal Time-
3432 (Qt::UTC). On systems that do not support time zones this function-
3433 will behave as if local time were Qt::UTC.-
3434-
3435 Note that passing the minimum of \c qint64-
3436 (\c{std::numeric_limits<qint64>::min()}) to \a msecs will result in-
3437 undefined behavior.-
3438-
3439 \sa toMSecsSinceEpoch(), setTime_t()-
3440*/-
3441void QDateTime::setMSecsSinceEpoch(qint64 msecs)-
3442{-
3443 QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)-
3444-
3445 d->m_status = 0;-
3446 switch (d->m_spec) {-
3447 case Qt::UTC:
executed 11649 times by 20 tests: case Qt::UTC:
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_QPrinter
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
  • tst_QXmlInputSource
  • tst_Spdy
11649
3448 d->m_msecs = msecs;-
3449 d->m_status = d->m_status-
3450 | QDateTimePrivate::ValidDate-
3451 | QDateTimePrivate::ValidTime-
3452 | QDateTimePrivate::ValidDateTime;-
3453 break;
executed 11649 times by 20 tests: break;
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_QPrinter
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
  • tst_QXmlInputSource
  • tst_Spdy
11649
3454 case Qt::OffsetFromUTC:
executed 17 times by 2 tests: case Qt::OffsetFromUTC:
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
17
3455 d->m_msecs = msecs + (d->m_offsetFromUtc * 1000);-
3456 d->m_status = d->m_status-
3457 | QDateTimePrivate::ValidDate-
3458 | QDateTimePrivate::ValidTime-
3459 | QDateTimePrivate::ValidDateTime;-
3460 break;
executed 17 times by 2 tests: break;
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
17
3461 case Qt::TimeZone:
executed 20 times by 1 test: case Qt::TimeZone:
Executed by:
  • tst_QDateTime
20
3462#ifndef QT_BOOTSTRAPPED-
3463 // Docs state any LocalTime before 1970-01-01 will *not* have any DST applied-
3464 // but all affected times afterwards will have DST applied.-
3465 if (msecs >= 0)
msecs >= 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QDateTime
4-16
3466 d->m_offsetFromUtc = d->m_timeZone.d->offsetFromUtc(msecs);
executed 16 times by 1 test: d->m_offsetFromUtc = d->m_timeZone.d->offsetFromUtc(msecs);
Executed by:
  • tst_QDateTime
16
3467 else-
3468 d->m_offsetFromUtc = d->m_timeZone.d->standardTimeOffset(msecs);
executed 4 times by 1 test: d->m_offsetFromUtc = d->m_timeZone.d->standardTimeOffset(msecs);
Executed by:
  • tst_QDateTime
4
3469 d->m_msecs = msecs + (d->m_offsetFromUtc * 1000);-
3470 d->m_status = d->m_status-
3471 | QDateTimePrivate::ValidDate-
3472 | QDateTimePrivate::ValidTime-
3473 | QDateTimePrivate::ValidDateTime;-
3474 d->refreshDateTime();-
3475#endif // QT_BOOTSTRAPPED-
3476 break;
executed 20 times by 1 test: break;
Executed by:
  • tst_QDateTime
20
3477 case Qt::LocalTime: {
executed 6953229 times by 95 tests: case Qt::LocalTime:
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
6953229
3478 QDate dt;-
3479 QTime tm;-
3480 QDateTimePrivate::DaylightStatus status;-
3481 epochMSecsToLocalTime(msecs, &dt, &tm, &status);-
3482 d->setDateTime(dt, tm);-
3483 d->setDaylightStatus(status);-
3484 d->refreshDateTime();-
3485 break;
executed 6953229 times by 95 tests: break;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • 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
  • tst_QFileIconProvider
  • ...
6953229
3486 }-
3487 }-
3488}
executed 6964915 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
  • ...
6964915
3489-
3490/*!-
3491 \fn void QDateTime::setTime_t(uint seconds)-
3492-
3493 Sets the date and time given the number of \a seconds that have-
3494 passed since 1970-01-01T00:00:00, Coordinated Universal Time-
3495 (Qt::UTC). On systems that do not support time zones this function-
3496 will behave as if local time were Qt::UTC.-
3497-
3498 \sa toTime_t()-
3499*/-
3500-
3501void QDateTime::setTime_t(uint secsSince1Jan1970UTC)-
3502{-
3503 setMSecsSinceEpoch((qint64)secsSince1Jan1970UTC * 1000);-
3504}
executed 16 times by 1 test: end of block
Executed by:
  • tst_QDateTime
16
3505-
3506#ifndef QT_NO_DATESTRING-
3507/*!-
3508 \fn QString QDateTime::toString(Qt::DateFormat format) const-
3509-
3510 \overload-
3511-
3512 Returns the datetime as a string in the \a format given.-
3513-
3514 If the \a format is Qt::TextDate, the string is formatted in-
3515 the default way. QDate::shortDayName(), QDate::shortMonthName(),-
3516 and QTime::toString() are used to generate the string, so the-
3517 day and month names will be localized names using the system locale,-
3518 i.e. QLocale::system(). An example of this formatting is-
3519 "Wed May 20 03:40:13 1998".-
3520-
3521 If the \a format is Qt::ISODate, the string format corresponds-
3522 to the ISO 8601 extended specification for representations of-
3523 dates and times, taking the form YYYY-MM-DDTHH:mm:ss[Z|[+|-]HH:mm],-
3524 depending on the timeSpec() of the QDateTime. If the timeSpec()-
3525 is Qt::UTC, Z will be appended to the string; if the timeSpec() is-
3526 Qt::OffsetFromUTC, the offset in hours and minutes from UTC will-
3527 be appended to the string.-
3528-
3529 If the \a format is Qt::SystemLocaleShortDate or-
3530 Qt::SystemLocaleLongDate, the string format depends on the locale-
3531 settings of the system. Identical to calling-
3532 QLocale::system().toString(datetime, QLocale::ShortFormat) or-
3533 QLocale::system().toString(datetime, QLocale::LongFormat).-
3534-
3535 If the \a format is Qt::DefaultLocaleShortDate or-
3536 Qt::DefaultLocaleLongDate, the string format depends on the-
3537 default application locale. This is the locale set with-
3538 QLocale::setDefault(), or the system locale if no default locale-
3539 has been set. Identical to calling QLocale().toString(datetime,-
3540 QLocale::ShortFormat) or QLocale().toString(datetime,-
3541 QLocale::LongFormat).-
3542-
3543 If the \a format is Qt::RFC2822Date, the string is formatted-
3544 following \l{RFC 2822}.-
3545-
3546 If the datetime is invalid, an empty string will be returned.-
3547-
3548 \warning The Qt::ISODate format is only valid for years in the-
3549 range 0 to 9999. This restriction may apply to locale-aware-
3550 formats as well, depending on the locale settings.-
3551-
3552 \sa fromString(), QDate::toString(), QTime::toString(),-
3553 QLocale::toString()-
3554*/-
3555-
3556QString QDateTime::toString(Qt::DateFormat format) const-
3557{-
3558 QString buf;-
3559 if (!isValid())
!isValid()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 3156 times by 13 tests
Evaluated by:
  • tst_QCompleter
  • tst_QDate
  • tst_QDateTime
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QVariant
  • tst_languageChange
  • tst_qmakelib
2-3156
3560 return buf;
executed 2 times by 1 test: return buf;
Executed by:
  • tst_QDateTime
2
3561-
3562 switch (format) {-
3563 case Qt::SystemLocaleDate:
executed 2721 times by 8 tests: case Qt::SystemLocaleDate:
Executed by:
  • tst_QCompleter
  • tst_QDateTime
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_languageChange
2721
3564 case Qt::SystemLocaleShortDate:
executed 1 time by 1 test: case Qt::SystemLocaleShortDate:
Executed by:
  • tst_QDateTime
1
3565 return QLocale::system().toString(*this, QLocale::ShortFormat);
executed 2722 times by 8 tests: return QLocale::system().toString(*this, QLocale::ShortFormat);
Executed by:
  • tst_QCompleter
  • tst_QDateTime
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QItemModel
  • tst_languageChange
2722
3566 case Qt::SystemLocaleLongDate:
executed 1 time by 1 test: case Qt::SystemLocaleLongDate:
Executed by:
  • tst_QDateTime
1
3567 return QLocale::system().toString(*this, QLocale::LongFormat);
executed 1 time by 1 test: return QLocale::system().toString(*this, QLocale::LongFormat);
Executed by:
  • tst_QDateTime
1
3568 case Qt::LocaleDate:
executed 1 time by 1 test: case Qt::LocaleDate:
Executed by:
  • tst_QDateTime
1
3569 case Qt::DefaultLocaleShortDate:
executed 1 time by 1 test: case Qt::DefaultLocaleShortDate:
Executed by:
  • tst_QDateTime
1
3570 return QLocale().toString(*this, QLocale::ShortFormat);
executed 2 times by 1 test: return QLocale().toString(*this, QLocale::ShortFormat);
Executed by:
  • tst_QDateTime
2
3571 case Qt::DefaultLocaleLongDate:
executed 1 time by 1 test: case Qt::DefaultLocaleLongDate:
Executed by:
  • tst_QDateTime
1
3572 return QLocale().toString(*this, QLocale::LongFormat);
executed 1 time by 1 test: return QLocale().toString(*this, QLocale::LongFormat);
Executed by:
  • tst_QDateTime
1
3573 case Qt::RFC2822Date: {
executed 5 times by 1 test: case Qt::RFC2822Date:
Executed by:
  • tst_QDateTime
5
3574 buf = QLocale::c().toString(*this, QStringLiteral("dd MMM yyyy hh:mm:ss "));
executed 5 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QDateTime
5
3575 buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);-
3576 return buf;
executed 5 times by 1 test: return buf;
Executed by:
  • tst_QDateTime
5
3577 }-
3578 default:
never executed: default:
0
3579#ifndef QT_NO_TEXTDATE-
3580 case Qt::TextDate: {
executed 399 times by 3 tests: case Qt::TextDate:
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_qmakelib
399
3581 const QPair<QDate, QTime> p = d->getDateTime();-
3582 const QDate &dt = p.first;-
3583 const QTime &tm = p.second;-
3584 //We cant use date.toString(Qt::TextDate) as we need to insert the time before the year-
3585 buf = QString::fromLatin1("%1 %2 %3 %4 %5").arg(dt.shortDayName(dt.dayOfWeek()))-
3586 .arg(dt.shortMonthName(dt.month()))-
3587 .arg(dt.day())-
3588 .arg(tm.toString(Qt::TextDate))-
3589 .arg(dt.year());-
3590 if (timeSpec() != Qt::LocalTime) {
timeSpec() != Qt::LocalTimeDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 396 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_qmakelib
3-396
3591 buf += QLatin1String(" GMT");-
3592 if (d->m_spec == Qt::OffsetFromUTC)
d->m_spec == Qt::OffsetFromUTCDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
1-2
3593 buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);
executed 2 times by 1 test: buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);
Executed by:
  • tst_QDateTime
2
3594 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QDateTime
3
3595 return buf;
executed 399 times by 3 tests: return buf;
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_qmakelib
399
3596 }-
3597#endif-
3598 case Qt::ISODate: {
executed 26 times by 4 tests: case Qt::ISODate:
Executed by:
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QVariant
26
3599 const QPair<QDate, QTime> p = d->getDateTime();-
3600 const QDate &dt = p.first;-
3601 const QTime &tm = p.second;-
3602 buf = dt.toString(Qt::ISODate);-
3603 if (buf.isEmpty())
buf.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 25 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QVariant
1-25
3604 return QString(); // failed to convert
executed 1 time by 1 test: return QString();
Executed by:
  • tst_QDateTime
1
3605 buf += QLatin1Char('T');-
3606 buf += tm.toString(Qt::ISODate);-
3607 switch (d->m_spec) {-
3608 case Qt::UTC:
executed 9 times by 2 tests: case Qt::UTC:
Executed by:
  • tst_QDateTime
  • tst_QNetworkRequest
9
3609 buf += QLatin1Char('Z');-
3610 break;
executed 9 times by 2 tests: break;
Executed by:
  • tst_QDateTime
  • tst_QNetworkRequest
9
3611 case Qt::OffsetFromUTC:
executed 3 times by 1 test: case Qt::OffsetFromUTC:
Executed by:
  • tst_QDateTime
3
3612 buf += toOffsetString(Qt::ISODate, d->m_offsetFromUtc);-
3613 break;
executed 3 times by 1 test: break;
Executed by:
  • tst_QDateTime
3
3614 default:
executed 13 times by 3 tests: default:
Executed by:
  • tst_QDateTime
  • tst_QSqlTableModel
  • tst_QVariant
13
3615 break;
executed 13 times by 3 tests: break;
Executed by:
  • tst_QDateTime
  • tst_QSqlTableModel
  • tst_QVariant
13
3616 }-
3617 return buf;
executed 25 times by 4 tests: return buf;
Executed by:
  • tst_QDateTime
  • tst_QNetworkRequest
  • tst_QSqlTableModel
  • tst_QVariant
25
3618 }-
3619 }-
3620}-
3621-
3622/*!-
3623 Returns the datetime as a string. The \a format parameter-
3624 determines the format of the result string.-
3625-
3626 These expressions may be used for the date:-
3627-
3628 \table-
3629 \header \li Expression \li Output-
3630 \row \li d \li the day as number without a leading zero (1 to 31)-
3631 \row \li dd \li the day as number with a leading zero (01 to 31)-
3632 \row \li ddd-
3633 \li the abbreviated localized day name (e.g. 'Mon' to 'Sun').-
3634 Uses the system locale to localize the name, i.e. QLocale::system().-
3635 \row \li dddd-
3636 \li the long localized day name (e.g. 'Monday' to 'Sunday').-
3637 Uses the system locale to localize the name, i.e. QLocale::system().-
3638 \row \li M \li the month as number without a leading zero (1-12)-
3639 \row \li MM \li the month as number with a leading zero (01-12)-
3640 \row \li MMM-
3641 \li the abbreviated localized month name (e.g. 'Jan' to 'Dec').-
3642 Uses the system locale to localize the name, i.e. QLocale::system().-
3643 \row \li MMMM-
3644 \li the long localized month name (e.g. 'January' to 'December').-
3645 Uses the system locale to localize the name, i.e. QLocale::system().-
3646 \row \li yy \li the year as two digit number (00-99)-
3647 \row \li yyyy \li the year as four digit number-
3648 \endtable-
3649-
3650 These expressions may be used for the time:-
3651-
3652 \table-
3653 \header \li Expression \li Output-
3654 \row \li h-
3655 \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)-
3656 \row \li hh-
3657 \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)-
3658 \row \li H-
3659 \li the hour without a leading zero (0 to 23, even with AM/PM display)-
3660 \row \li HH-
3661 \li the hour with a leading zero (00 to 23, even with AM/PM display)-
3662 \row \li m \li the minute without a leading zero (0 to 59)-
3663 \row \li mm \li the minute with a leading zero (00 to 59)-
3664 \row \li s \li the second without a leading zero (0 to 59)-
3665 \row \li ss \li the second with a leading zero (00 to 59)-
3666 \row \li z \li the milliseconds without leading zeroes (0 to 999)-
3667 \row \li zzz \li the milliseconds with leading zeroes (000 to 999)-
3668 \row \li AP or A-
3669 \li use AM/PM display. \e A/AP will be replaced by either "AM" or "PM".-
3670 \row \li ap or a-
3671 \li use am/pm display. \e a/ap will be replaced by either "am" or "pm".-
3672 \row \li t \li the timezone (for example "CEST")-
3673 \endtable-
3674-
3675 All other input characters will be ignored. Any sequence of characters that-
3676 are enclosed in single quotes will be treated as text and not be used as an-
3677 expression. Two consecutive single quotes ("''") are replaced by a singlequote-
3678 in the output. Formats without separators (e.g. "HHmm") are currently not supported.-
3679-
3680 Example format strings (assumed that the QDateTime is 21 May 2001-
3681 14:13:09):-
3682-
3683 \table-
3684 \header \li Format \li Result-
3685 \row \li dd.MM.yyyy \li 21.05.2001-
3686 \row \li ddd MMMM d yy \li Tue May 21 01-
3687 \row \li hh:mm:ss.zzz \li 14:13:09.042-
3688 \row \li h:m:s ap \li 2:13:9 pm-
3689 \endtable-
3690-
3691 If the datetime is invalid, an empty string will be returned.-
3692-
3693 \sa fromString(), QDate::toString(), QTime::toString(), QLocale::toString()-
3694*/-
3695QString QDateTime::toString(const QString& format) const-
3696{-
3697 return QLocale::system().toString(*this, format);
executed 2377 times by 18 tests: return QLocale::system().toString(*this, format);
Executed by:
  • tst_QAsn1Element
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileInfo
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkReply
  • tst_QNoDebug
  • tst_QSignalSpy
  • tst_QSqlQuery
  • tst_QSslCertificate
  • tst_QVariant
  • tst_qlogging - unknown status
  • tst_qmessagehandler
  • tst_selftests - unknown status
2377
3698}-
3699#endif //QT_NO_DATESTRING-
3700-
3701static void massageAdjustedDateTime(Qt::TimeSpec spec,-
3702#ifndef QT_BOOTSTRAPPED-
3703 const QTimeZone &zone,-
3704#endif // QT_BOOTSTRAPPED-
3705 QDate *date,-
3706 QTime *time)-
3707{-
3708 /*-
3709 If we have just adjusted to a day with a DST transition, our given time-
3710 may lie in the transition hour (either missing or duplicated). For any-
3711 other time, telling mktime (deep in the bowels of localMSecsToEpochMSecs)-
3712 we don't know its DST-ness will produce no adjustment (just a decision as-
3713 to its DST-ness); but for a time in spring's missing hour it'll adjust the-
3714 time while picking a DST-ness. (Handling of autumn is trickier, as either-
3715 DST-ness is valid, without adjusting the time. We might want to propagate-
3716 d->daylightStatus() in that case, but it's hard to do so without breaking-
3717 (far more common) other cases; and it makes little difference, as the two-
3718 answers do then differ only in DST-ness.)-
3719 */-
3720 if (spec == Qt::LocalTime) {
spec == Qt::LocalTimeDescription
TRUEevaluated 6374 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
FALSEevaluated 124 times by 1 test
Evaluated by:
  • tst_QDateTime
124-6374
3721 QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime;-
3722 localMSecsToEpochMSecs(timeToMSecs(*date, *time), &status, date, time);-
3723#ifndef QT_BOOTSTRAPPED-
3724 } else if (spec == Qt::TimeZone) {
executed 6374 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
spec == Qt::TimeZoneDescription
TRUEnever evaluated
FALSEevaluated 124 times by 1 test
Evaluated by:
  • tst_QDateTime
0-6374
3725 QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), zone, date, time);-
3726#endif // QT_BOOTSTRAPPED-
3727 }
never executed: end of block
0
3728}
executed 6498 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
6498
3729#ifdef QT_BOOTSTRAPPED // Avoid duplicate #if-ery in uses.-
3730#define MASSAGEADJUSTEDDATETIME(s, z, d, t) massageAdjustedDateTime(s, d, t)-
3731#else-
3732#define MASSAGEADJUSTEDDATETIME(s, z, d, t) massageAdjustedDateTime(s, z, d, t)-
3733#endif // QT_BOOTSTRAPPED-
3734-
3735/*!-
3736 Returns a QDateTime object containing a datetime \a ndays days-
3737 later than the datetime of this object (or earlier if \a ndays is-
3738 negative).-
3739-
3740 If the timeSpec() is Qt::LocalTime and the resulting-
3741 date and time fall in the Standard Time to Daylight-Saving Time transition-
3742 hour then the result will be adjusted accordingly, i.e. if the transition-
3743 is at 2am and the clock goes forward to 3am and the result falls between-
3744 2am and 3am then the result will be adjusted to fall after 3am.-
3745-
3746 \sa daysTo(), addMonths(), addYears(), addSecs()-
3747*/-
3748-
3749QDateTime QDateTime::addDays(qint64 ndays) const-
3750{-
3751 QDateTime dt(*this);-
3752 QPair<QDate, QTime> p = d->getDateTime();-
3753 QDate &date = p.first;-
3754 QTime &time = p.second;-
3755 date = date.addDays(ndays);-
3756 MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);-
3757 dt.d->setDateTime(date, time);-
3758 return dt;
executed 6288 times by 2 tests: return dt;
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
6288
3759}-
3760-
3761/*!-
3762 Returns a QDateTime object containing a datetime \a nmonths months-
3763 later than the datetime of this object (or earlier if \a nmonths-
3764 is negative).-
3765-
3766 If the timeSpec() is Qt::LocalTime and the resulting-
3767 date and time fall in the Standard Time to Daylight-Saving Time transition-
3768 hour then the result will be adjusted accordingly, i.e. if the transition-
3769 is at 2am and the clock goes forward to 3am and the result falls between-
3770 2am and 3am then the result will be adjusted to fall after 3am.-
3771-
3772 \sa daysTo(), addDays(), addYears(), addSecs()-
3773*/-
3774-
3775QDateTime QDateTime::addMonths(int nmonths) const-
3776{-
3777 QDateTime dt(*this);-
3778 QPair<QDate, QTime> p = d->getDateTime();-
3779 QDate &date = p.first;-
3780 QTime &time = p.second;-
3781 date = date.addMonths(nmonths);-
3782 MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);-
3783 dt.d->setDateTime(date, time);-
3784 return dt;
executed 119 times by 2 tests: return dt;
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
119
3785}-
3786-
3787/*!-
3788 Returns a QDateTime object containing a datetime \a nyears years-
3789 later than the datetime of this object (or earlier if \a nyears is-
3790 negative).-
3791-
3792 If the timeSpec() is Qt::LocalTime and the resulting-
3793 date and time fall in the Standard Time to Daylight-Saving Time transition-
3794 hour then the result will be adjusted accordingly, i.e. if the transition-
3795 is at 2am and the clock goes forward to 3am and the result falls between-
3796 2am and 3am then the result will be adjusted to fall after 3am.-
3797-
3798 \sa daysTo(), addDays(), addMonths(), addSecs()-
3799*/-
3800-
3801QDateTime QDateTime::addYears(int nyears) const-
3802{-
3803 QDateTime dt(*this);-
3804 QPair<QDate, QTime> p = d->getDateTime();-
3805 QDate &date = p.first;-
3806 QTime &time = p.second;-
3807 date = date.addYears(nyears);-
3808 MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);-
3809 dt.d->setDateTime(date, time);-
3810 return dt;
executed 91 times by 1 test: return dt;
Executed by:
  • tst_QDateTime
91
3811}-
3812#undef MASSAGEADJUSTEDDATETIME-
3813-
3814/*!-
3815 Returns a QDateTime object containing a datetime \a s seconds-
3816 later than the datetime of this object (or earlier if \a s is-
3817 negative).-
3818-
3819 If this datetime is invalid, an invalid datetime will be returned.-
3820-
3821 \sa addMSecs(), secsTo(), addDays(), addMonths(), addYears()-
3822*/-
3823-
3824QDateTime QDateTime::addSecs(qint64 s) const-
3825{-
3826 return addMSecs(s * 1000);
executed 41141 times by 17 tests: return addMSecs(s * 1000);
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QSqlTableModel
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QXmlInputSource
  • tst_Spdy
41141
3827}-
3828-
3829/*!-
3830 Returns a QDateTime object containing a datetime \a msecs miliseconds-
3831 later than the datetime of this object (or earlier if \a msecs is-
3832 negative).-
3833-
3834 If this datetime is invalid, an invalid datetime will be returned.-
3835-
3836 \sa addSecs(), msecsTo(), addDays(), addMonths(), addYears()-
3837*/-
3838QDateTime QDateTime::addMSecs(qint64 msecs) const-
3839{-
3840 if (!isValid())
!isValid()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 41229 times by 17 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QSqlTableModel
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QXmlInputSource
  • tst_Spdy
5-41229
3841 return QDateTime();
executed 5 times by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
5
3842-
3843 QDateTime dt(*this);-
3844 if (d->m_spec == Qt::LocalTime || d->m_spec == Qt::TimeZone)
d->m_spec == Qt::LocalTimeDescription
TRUEevaluated 81 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QSqlTableModel
FALSEevaluated 41148 times by 16 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QXmlInputSource
  • tst_Spdy
d->m_spec == Qt::TimeZoneDescription
TRUEnever evaluated
FALSEevaluated 41148 times by 16 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QXmlInputSource
  • tst_Spdy
0-41148
3845 // Convert to real UTC first in case crosses DST transition-
3846 dt.setMSecsSinceEpoch(d->toMSecsSinceEpoch() + msecs);
executed 81 times by 2 tests: dt.setMSecsSinceEpoch(d->toMSecsSinceEpoch() + msecs);
Executed by:
  • tst_QDateTime
  • tst_QSqlTableModel
81
3847 else-
3848 // No need to convert, just add on-
3849 dt.d->m_msecs = dt.d->m_msecs + msecs;
executed 41148 times by 16 tests: dt.d->m_msecs = dt.d->m_msecs + msecs;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QXmlInputSource
  • tst_Spdy
41148
3850 return dt;
executed 41229 times by 17 tests: return dt;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QSqlTableModel
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QXmlInputSource
  • tst_Spdy
41229
3851}-
3852-
3853/*!-
3854 Returns the number of days from this datetime to the \a other-
3855 datetime. The number of days is counted as the number of times-
3856 midnight is reached between this datetime to the \a other-
3857 datetime. This means that a 10 minute difference from 23:55 to-
3858 0:05 the next day counts as one day.-
3859-
3860 If the \a other datetime is earlier than this datetime,-
3861 the value returned is negative.-
3862-
3863 Example:-
3864 \snippet code/src_corelib_tools_qdatetime.cpp 15-
3865-
3866 \sa addDays(), secsTo(), msecsTo()-
3867*/-
3868-
3869qint64 QDateTime::daysTo(const QDateTime &other) const-
3870{-
3871 return date().daysTo(other.date());
executed 114 times by 3 tests: return date().daysTo(other.date());
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QDateTimeEdit
114
3872}-
3873-
3874/*!-
3875 Returns the number of seconds from this datetime to the \a other-
3876 datetime. If the \a other datetime is earlier than this datetime,-
3877 the value returned is negative.-
3878-
3879 Before performing the comparison, the two datetimes are converted-
3880 to Qt::UTC to ensure that the result is correct if daylight-saving-
3881 (DST) applies to one of the two datetimes but not the other.-
3882-
3883 Returns 0 if either datetime is invalid.-
3884-
3885 Example:-
3886 \snippet code/src_corelib_tools_qdatetime.cpp 11-
3887-
3888 \sa addSecs(), daysTo(), QTime::secsTo()-
3889*/-
3890-
3891qint64 QDateTime::secsTo(const QDateTime &other) const-
3892{-
3893 return (msecsTo(other) / 1000);
executed 813 times by 11 tests: return (msecsTo(other) / 1000);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QFtp
  • tst_QHttpNetworkConnection
  • tst_QMimeDatabase
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
813
3894}-
3895-
3896/*!-
3897 Returns the number of milliseconds from this datetime to the \a other-
3898 datetime. If the \a other datetime is earlier than this datetime,-
3899 the value returned is negative.-
3900-
3901 Before performing the comparison, the two datetimes are converted-
3902 to Qt::UTC to ensure that the result is correct if daylight-saving-
3903 (DST) applies to one of the two datetimes and but not the other.-
3904-
3905 Returns 0 if either datetime is invalid.-
3906-
3907 \sa addMSecs(), daysTo(), QTime::msecsTo()-
3908*/-
3909-
3910qint64 QDateTime::msecsTo(const QDateTime &other) const-
3911{-
3912 if (!isValid() || !other.isValid())
!isValid()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 1180 times by 15 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QDir
  • tst_QFtp
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QLockFile
  • tst_QMimeDatabase
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QXmlInputSource
  • tst_Spdy
!other.isValid()Description
TRUEnever evaluated
FALSEevaluated 1180 times by 15 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QDir
  • tst_QFtp
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QLockFile
  • tst_QMimeDatabase
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QXmlInputSource
  • tst_Spdy
0-1180
3913 return 0;
executed 4 times by 1 test: return 0;
Executed by:
  • tst_QDateTime
4
3914-
3915 return other.d->toMSecsSinceEpoch() - d->toMSecsSinceEpoch();
executed 1180 times by 15 tests: return other.d->toMSecsSinceEpoch() - d->toMSecsSinceEpoch();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QDir
  • tst_QFtp
  • tst_QHttpNetworkConnection
  • tst_QItemModel
  • tst_QLockFile
  • tst_QMimeDatabase
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QXmlInputSource
  • tst_Spdy
1180
3916}-
3917-
3918/*!-
3919 \fn QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const-
3920-
3921 Returns a copy of this datetime converted to the given time-
3922 \a spec.-
3923-
3924 If \a spec is Qt::OffsetFromUTC then it is set to Qt::UTC. To set to a-
3925 spec of Qt::OffsetFromUTC use toOffsetFromUtc().-
3926-
3927 If \a spec is Qt::TimeZone then it is set to Qt::LocalTime,-
3928 i.e. the local Time Zone.-
3929-
3930 Example:-
3931 \snippet code/src_corelib_tools_qdatetime.cpp 16-
3932-
3933 \sa timeSpec(), toTimeZone(), toUTC(), toLocalTime()-
3934*/-
3935-
3936QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const-
3937{-
3938 if (d->m_spec == spec && (spec == Qt::UTC || spec == Qt::LocalTime))
d->m_spec == specDescription
TRUEevaluated 18124 times by 13 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSslCertificate
  • tst_QStyleSheetStyle
  • tst_QTime
FALSEevaluated 1176 times by 7 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QVariant
spec == Qt::UTCDescription
TRUEevaluated 1252 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCookie
  • tst_QSslCertificate
FALSEevaluated 16872 times by 11 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
spec == Qt::LocalTimeDescription
TRUEevaluated 16872 times by 11 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QStyleSheetStyle
  • tst_QTime
FALSEnever evaluated
0-18124
3939 return *this;
executed 18124 times by 13 tests: return *this;
Executed by:
  • tst_QAccessibility
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QItemDelegate
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSslCertificate
  • tst_QStyleSheetStyle
  • tst_QTime
18124
3940-
3941 if (!isValid()) {
!isValid()Description
TRUEevaluated 505 times by 6 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QVariant
FALSEevaluated 671 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkReply
505-671
3942 QDateTime ret = *this;-
3943 ret.setTimeSpec(spec);-
3944 return ret;
executed 505 times by 6 tests: return ret;
Executed by:
  • tst_QDateTime
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QVariant
505
3945 }-
3946-
3947 return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), spec, 0);
executed 671 times by 3 tests: return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), spec, 0);
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkReply
671
3948}-
3949-
3950/*!-
3951 \since 5.2-
3952-
3953 \fn QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const-
3954-
3955 Returns a copy of this datetime converted to a spec of Qt::OffsetFromUTC-
3956 with the given \a offsetSeconds.-
3957-
3958 If the \a offsetSeconds equals 0 then a UTC datetime will be returned-
3959-
3960 \sa setOffsetFromUtc(), offsetFromUtc(), toTimeSpec()-
3961*/-
3962-
3963QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const-
3964{-
3965 if (d->m_spec == Qt::OffsetFromUTC && d->m_offsetFromUtc == offsetSeconds)
d->m_spec == Qt::OffsetFromUTCDescription
TRUEnever evaluated
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
d->m_offsetFro... offsetSecondsDescription
TRUEnever evaluated
FALSEnever evaluated
0-6
3966 return *this;
never executed: return *this;
0
3967-
3968 if (!isValid()) {
!isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
1-5
3969 QDateTime ret = *this;-
3970 ret.setOffsetFromUtc(offsetSeconds);-
3971 return ret;
executed 1 time by 1 test: return ret;
Executed by:
  • tst_QDateTime
1
3972 }-
3973-
3974 return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), Qt::OffsetFromUTC, offsetSeconds);
executed 5 times by 2 tests: return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), Qt::OffsetFromUTC, offsetSeconds);
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
5
3975}-
3976-
3977#ifndef QT_BOOTSTRAPPED-
3978/*!-
3979 \since 5.2-
3980-
3981 Returns a copy of this datetime converted to the given \a timeZone-
3982-
3983 \sa timeZone(), toTimeSpec()-
3984*/-
3985-
3986QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const-
3987{-
3988 if (d->m_spec == Qt::TimeZone && d->m_timeZone == timeZone)
d->m_spec == Qt::TimeZoneDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
d->m_timeZone == timeZoneDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
0-1
3989 return *this;
never executed: return *this;
0
3990-
3991 if (!isValid()) {
!isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
1
3992 QDateTime ret = *this;-
3993 ret.setTimeZone(timeZone);-
3994 return ret;
executed 1 time by 1 test: return ret;
Executed by:
  • tst_QDateTime
1
3995 }-
3996-
3997 return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), timeZone);
executed 1 time by 1 test: return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), timeZone);
Executed by:
  • tst_QDateTime
1
3998}-
3999#endif // QT_BOOTSTRAPPED-
4000-
4001/*!-
4002 Returns \c true if this datetime is equal to the \a other datetime;-
4003 otherwise returns \c false.-
4004-
4005 \sa operator!=()-
4006*/-
4007-
4008bool QDateTime::operator==(const QDateTime &other) const-
4009{-
4010 if (d->m_spec == Qt::LocalTime
d->m_spec == Qt::LocalTimeDescription
TRUEevaluated 62344 times by 28 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QColorDialog
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QSignalSpy
  • tst_QSslCertificate
  • tst_QStyleSheetStyle
  • ...
FALSEevaluated 1272 times by 12 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAsn1Element
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSslCertificate
  • tst_selftests - unknown status
1272-62344
4011 && other.d->m_spec == Qt::LocalTime
other.d->m_spe... Qt::LocalTimeDescription
TRUEevaluated 62311 times by 28 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QColorDialog
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QSignalSpy
  • tst_QSslCertificate
  • tst_QStyleSheetStyle
  • ...
FALSEevaluated 33 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
33-62311
4012 && d->m_status == other.d->m_status) {
d->m_status ==...er.d->m_statusDescription
TRUEevaluated 61608 times by 28 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QColorDialog
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QSignalSpy
  • tst_QSslCertificate
  • tst_QStyleSheetStyle
  • ...
FALSEevaluated 703 times by 8 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDBusAbstractAdaptor
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QStyleSheetStyle
703-61608
4013 return (d->m_msecs == other.d->m_msecs);
executed 61608 times by 28 tests: return (d->m_msecs == other.d->m_msecs);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QColorDialog
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QSignalSpy
  • tst_QSslCertificate
  • tst_QStyleSheetStyle
  • ...
61608
4014 }-
4015 // Convert to UTC and compare-
4016 return (toMSecsSinceEpoch() == other.toMSecsSinceEpoch());
executed 2008 times by 18 tests: return (toMSecsSinceEpoch() == other.toMSecsSinceEpoch());
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAsn1Element
  • tst_QDBusAbstractAdaptor
  • tst_QDBusMarshall
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCacheMetaData
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSettings
  • tst_QSslCertificate
  • tst_QStyleSheetStyle
  • tst_selftests - unknown status
2008
4017}-
4018-
4019/*!-
4020 \fn bool QDateTime::operator!=(const QDateTime &other) const-
4021-
4022 Returns \c true if this datetime is different from the \a other-
4023 datetime; otherwise returns \c false.-
4024-
4025 Two datetimes are different if either the date, the time, or the-
4026 time zone components are different.-
4027-
4028 \sa operator==()-
4029*/-
4030-
4031/*!-
4032 Returns \c true if this datetime is earlier than the \a other-
4033 datetime; otherwise returns \c false.-
4034*/-
4035-
4036bool QDateTime::operator<(const QDateTime &other) const-
4037{-
4038 if (d->m_spec == Qt::LocalTime
d->m_spec == Qt::LocalTimeDescription
TRUEevaluated 44463 times by 35 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QMimeDatabase
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QPlainTextEdit
  • tst_QPrinter
  • ...
FALSEevaluated 59466 times by 8 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QTimeZone
44463-59466
4039 && other.d->m_spec == Qt::LocalTime
other.d->m_spe... Qt::LocalTimeDescription
TRUEevaluated 44454 times by 34 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • ...
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkCookieJar
9-44454
4040 && d->m_status == other.d->m_status) {
d->m_status ==...er.d->m_statusDescription
TRUEevaluated 43980 times by 34 tests
Evaluated by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • ...
FALSEevaluated 474 times by 4 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QStyleSheetStyle
474-43980
4041 return (d->m_msecs < other.d->m_msecs);
executed 43980 times by 34 tests: return (d->m_msecs < other.d->m_msecs);
Executed by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QIcon
  • tst_QItemDelegate
  • tst_QLabel
  • tst_QLineEdit
  • tst_QMessageBox
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QPlainTextEdit
  • tst_QPrinter
  • tst_QSidebar
  • ...
43980
4042 }-
4043 // Convert to UTC and compare-
4044 return (toMSecsSinceEpoch() < other.toMSecsSinceEpoch());
executed 59949 times by 11 tests: return (toMSecsSinceEpoch() < other.toMSecsSinceEpoch());
Executed by:
  • tst_QAccessibility
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QItemDelegate
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QStyleSheetStyle
  • tst_QTimeZone
59949
4045}-
4046-
4047/*!-
4048 \fn bool QDateTime::operator<=(const QDateTime &other) const-
4049-
4050 Returns \c true if this datetime is earlier than or equal to the-
4051 \a other datetime; otherwise returns \c false.-
4052*/-
4053-
4054/*!-
4055 \fn bool QDateTime::operator>(const QDateTime &other) const-
4056-
4057 Returns \c true if this datetime is later than the \a other datetime;-
4058 otherwise returns \c false.-
4059*/-
4060-
4061/*!-
4062 \fn bool QDateTime::operator>=(const QDateTime &other) const-
4063-
4064 Returns \c true if this datetime is later than or equal to the-
4065 \a other datetime; otherwise returns \c false.-
4066*/-
4067-
4068/*!-
4069 \fn QDateTime QDateTime::currentDateTime()-
4070 Returns the current datetime, as reported by the system clock, in-
4071 the local time zone.-
4072-
4073 \sa currentDateTimeUtc(), QDate::currentDate(), QTime::currentTime(), toTimeSpec()-
4074*/-
4075-
4076/*!-
4077 \fn QDateTime QDateTime::currentDateTimeUtc()-
4078 \since 4.7-
4079 Returns the current datetime, as reported by the system clock, in-
4080 UTC.-
4081-
4082 \sa currentDateTime(), QDate::currentDate(), QTime::currentTime(), toTimeSpec()-
4083*/-
4084-
4085/*!-
4086 \fn qint64 QDateTime::currentMSecsSinceEpoch()-
4087 \since 4.7-
4088-
4089 Returns the number of milliseconds since 1970-01-01T00:00:00 Universal-
4090 Coordinated Time. This number is like the POSIX time_t variable, but-
4091 expressed in milliseconds instead.-
4092-
4093 \sa currentDateTime(), currentDateTimeUtc(), toTime_t(), toTimeSpec()-
4094*/-
4095-
4096#if defined(Q_OS_WIN)-
4097static inline uint msecsFromDecomposed(int hour, int minute, int sec, int msec = 0)-
4098{-
4099 return MSECS_PER_HOUR * hour + MSECS_PER_MIN * minute + 1000 * sec + msec;-
4100}-
4101-
4102QDate QDate::currentDate()-
4103{-
4104 QDate d;-
4105 SYSTEMTIME st;-
4106 memset(&st, 0, sizeof(SYSTEMTIME));-
4107 GetLocalTime(&st);-
4108 d.jd = julianDayFromDate(st.wYear, st.wMonth, st.wDay);-
4109 return d;-
4110}-
4111-
4112QTime QTime::currentTime()-
4113{-
4114 QTime ct;-
4115 SYSTEMTIME st;-
4116 memset(&st, 0, sizeof(SYSTEMTIME));-
4117 GetLocalTime(&st);-
4118 ct.setHMS(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);-
4119#if defined(Q_OS_WINCE)-
4120 ct.startTick = GetTickCount() % MSECS_PER_DAY;-
4121#endif-
4122 return ct;-
4123}-
4124-
4125QDateTime QDateTime::currentDateTime()-
4126{-
4127 QDate d;-
4128 QTime t;-
4129 SYSTEMTIME st;-
4130 memset(&st, 0, sizeof(SYSTEMTIME));-
4131 GetLocalTime(&st);-
4132 d.jd = julianDayFromDate(st.wYear, st.wMonth, st.wDay);-
4133 t.mds = msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);-
4134 return QDateTime(d, t);-
4135}-
4136-
4137QDateTime QDateTime::currentDateTimeUtc()-
4138{-
4139 QDate d;-
4140 QTime t;-
4141 SYSTEMTIME st;-
4142 memset(&st, 0, sizeof(SYSTEMTIME));-
4143 GetSystemTime(&st);-
4144 d.jd = julianDayFromDate(st.wYear, st.wMonth, st.wDay);-
4145 t.mds = msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);-
4146 return QDateTime(d, t, Qt::UTC);-
4147}-
4148-
4149qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW-
4150{-
4151 SYSTEMTIME st;-
4152 memset(&st, 0, sizeof(SYSTEMTIME));-
4153 GetSystemTime(&st);-
4154-
4155 return msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds) +-
4156 qint64(julianDayFromDate(st.wYear, st.wMonth, st.wDay)-
4157 - julianDayFromDate(1970, 1, 1)) * Q_INT64_C(86400000);-
4158}-
4159-
4160#elif defined(Q_OS_UNIX)-
4161QDate QDate::currentDate()-
4162{-
4163 return QDateTime::currentDateTime().date();
executed 202 times by 8 tests: return QDateTime::currentDateTime().date();
Executed by:
  • tst_QAccessibility
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QDate
  • tst_QDateTimeEdit
  • tst_QFtp
  • tst_QMetaType
  • tst_QSettings
202
4164}-
4165-
4166QTime QTime::currentTime()-
4167{-
4168 return QDateTime::currentDateTime().time();
executed 6944229 times by 39 tests: return QDateTime::currentDateTime().time();
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractSlider
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCoreApplication
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QFile
  • tst_QFtp
  • tst_QFutureWatcher
  • tst_QGuiApplication
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QLabel
  • tst_QLocalSocket
  • tst_QMetaType
  • tst_QMovie
  • tst_QMutex
  • tst_QNetworkReply
  • tst_QObjectPerformance
  • tst_QProcess
  • tst_QProgressBar
  • tst_QReadWriteLock
  • tst_QSettings
  • ...
6944229
4169}-
4170-
4171QDateTime QDateTime::currentDateTime()-
4172{-
4173 return fromMSecsSinceEpoch(currentMSecsSinceEpoch(), Qt::LocalTime);
executed 6945101 times by 60 tests: return fromMSecsSinceEpoch(currentMSecsSinceEpoch(), Qt::LocalTime);
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QFile
  • tst_QFileInfo
  • tst_QFtp
  • tst_QFutureWatcher
  • tst_QGuiApplication
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QItemDelegate
  • tst_QLabel
  • tst_QLocalSocket
  • tst_QLockFile
  • ...
6945101
4174}-
4175-
4176QDateTime QDateTime::currentDateTimeUtc()-
4177{-
4178 return fromMSecsSinceEpoch(currentMSecsSinceEpoch(), Qt::UTC);
executed 3651 times by 18 tests: return fromMSecsSinceEpoch(currentMSecsSinceEpoch(), Qt::UTC);
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QDateTime
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkCookie
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QPrinter
  • tst_QSslCertificate
  • tst_QSslSocket
  • tst_QSslSocket_onDemandCertificates_member
  • tst_QSslSocket_onDemandCertificates_static
  • tst_QXmlInputSource
  • tst_Spdy
3651
4179}-
4180-
4181qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW-
4182{-
4183 // posix compliant system-
4184 // we have milliseconds-
4185 struct timeval tv;-
4186 gettimeofday(&tv, 0);-
4187 return qint64(tv.tv_sec) * Q_INT64_C(1000) + tv.tv_usec / 1000;
executed 6948773 times by 70 tests: return qint64(tv.tv_sec) * static_cast<long long>(1000LL) + tv.tv_usec / 1000;
Executed by:
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractNetworkCache
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QAtomicInt
  • tst_QAuthenticator
  • tst_QCalendarWidget
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDate
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QFile
  • tst_QFileInfo
  • tst_QFtp
  • tst_QFutureWatcher
  • tst_QGuiApplication
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QItemDelegate
  • tst_QLabel
  • tst_QLocalSocket
  • ...
6948773
4188}-
4189-
4190#else-
4191#error "What system is this?"-
4192#endif-
4193-
4194/*! \fn QDateTime QDateTime::fromCFDate(CFDateRef date)-
4195 \since 5.5-
4196-
4197 Constructs a new QDateTime containing a copy of the CFDate \a date.-
4198-
4199 \sa toCFDate()-
4200*/-
4201-
4202/*! \fn CFDateRef QDateTime::toCFDate() const-
4203 \since 5.5-
4204-
4205 Creates a CFDate from a QDateTime. The caller owns the CFDate object-
4206 and is responsible for releasing it.-
4207-
4208 \sa fromCFDate()-
4209*/-
4210-
4211/*! \fn QDateTime QDateTime::fromNSDate(const NSDate *date)-
4212 \since 5.5-
4213-
4214 Constructs a new QDateTime containing a copy of the NSDate \a date.-
4215-
4216 \sa toNSDate()-
4217*/-
4218-
4219/*! \fn NSDate QDateTime::toNSDate() const-
4220 \since 5.5-
4221-
4222 Creates an NSDate from a QDateTime. The NSDate object is autoreleased.-
4223-
4224 \sa fromNSDate()-
4225*/-
4226-
4227/*!-
4228 \since 4.2-
4229-
4230 Returns a datetime whose date and time are the number of \a seconds-
4231 that have passed since 1970-01-01T00:00:00, Coordinated Universal-
4232 Time (Qt::UTC) and converted to Qt::LocalTime. On systems that do not-
4233 support time zones, the time will be set as if local time were Qt::UTC.-
4234-
4235 \sa toTime_t(), setTime_t()-
4236*/-
4237QDateTime QDateTime::fromTime_t(uint seconds)-
4238{-
4239 return fromMSecsSinceEpoch((qint64)seconds * 1000, Qt::LocalTime);
executed 7782 times by 49 tests: return fromMSecsSinceEpoch((qint64)seconds * 1000, Qt::LocalTime);
Executed by:
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDir
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QFrame
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • ...
7782
4240}-
4241-
4242/*!-
4243 \since 5.2-
4244-
4245 Returns a datetime whose date and time are the number of \a seconds-
4246 that have passed since 1970-01-01T00:00:00, Coordinated Universal-
4247 Time (Qt::UTC) and converted to the given \a spec.-
4248-
4249 If the \a spec is not Qt::OffsetFromUTC then the \a offsetSeconds will be-
4250 ignored. If the \a spec is Qt::OffsetFromUTC and the \a offsetSeconds is 0-
4251 then the spec will be set to Qt::UTC, i.e. an offset of 0 seconds.-
4252-
4253 \sa toTime_t(), setTime_t()-
4254*/-
4255QDateTime QDateTime::fromTime_t(uint seconds, Qt::TimeSpec spec, int offsetSeconds)-
4256{-
4257 return fromMSecsSinceEpoch((qint64)seconds * 1000, spec, offsetSeconds);
never executed: return fromMSecsSinceEpoch((qint64)seconds * 1000, spec, offsetSeconds);
0
4258}-
4259-
4260#ifndef QT_BOOTSTRAPPED-
4261/*!-
4262 \since 5.2-
4263-
4264 Returns a datetime whose date and time are the number of \a seconds-
4265 that have passed since 1970-01-01T00:00:00, Coordinated Universal-
4266 Time (Qt::UTC) and with the given \a timeZone.-
4267-
4268 \sa toTime_t(), setTime_t()-
4269*/-
4270QDateTime QDateTime::fromTime_t(uint seconds, const QTimeZone &timeZone)-
4271{-
4272 return fromMSecsSinceEpoch((qint64)seconds * 1000, timeZone);
executed 1 time by 1 test: return fromMSecsSinceEpoch((qint64)seconds * 1000, timeZone);
Executed by:
  • tst_QDateTime
1
4273}-
4274#endif-
4275-
4276/*!-
4277 \since 4.7-
4278-
4279 Returns a datetime whose date and time are the number of milliseconds, \a msecs,-
4280 that have passed since 1970-01-01T00:00:00.000, Coordinated Universal-
4281 Time (Qt::UTC), and converted to Qt::LocalTime. On systems that do not-
4282 support time zones, the time will be set as if local time were Qt::UTC.-
4283-
4284 Note that there are possible values for \a msecs that lie outside the valid-
4285 range of QDateTime, both negative and positive. The behavior of this-
4286 function is undefined for those values.-
4287-
4288 \sa toTime_t(), setTime_t()-
4289*/-
4290QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs)-
4291{-
4292 return fromMSecsSinceEpoch(msecs, Qt::LocalTime);
never executed: return fromMSecsSinceEpoch(msecs, Qt::LocalTime);
0
4293}-
4294-
4295/*!-
4296 \since 5.2-
4297-
4298 Returns a datetime whose date and time are the number of milliseconds \a msecs-
4299 that have passed since 1970-01-01T00:00:00.000, Coordinated Universal-
4300 Time (Qt::UTC) and converted to the given \a spec.-
4301-
4302 Note that there are possible values for \a msecs that lie outside the valid-
4303 range of QDateTime, both negative and positive. The behavior of this-
4304 function is undefined for those values.-
4305-
4306 If the \a spec is not Qt::OffsetFromUTC then the \a offsetSeconds will be-
4307 ignored. If the \a spec is Qt::OffsetFromUTC and the \a offsetSeconds is 0-
4308 then the spec will be set to Qt::UTC, i.e. an offset of 0 seconds.-
4309-
4310 If \a spec is Qt::TimeZone then the spec will be set to Qt::LocalTime,-
4311 i.e. the current system time zone.-
4312-
4313 \sa fromTime_t()-
4314*/-
4315QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetSeconds)-
4316{-
4317 QDateTime dt;-
4318 dt.d->setTimeSpec(spec, offsetSeconds);-
4319 dt.setMSecsSinceEpoch(msecs);-
4320 return dt;
executed 6963970 times by 103 tests: return dt;
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
  • ...
6963970
4321}-
4322-
4323#ifndef QT_BOOTSTRAPPED-
4324/*!-
4325 \since 5.2-
4326-
4327 Returns a datetime whose date and time are the number of milliseconds \a msecs-
4328 that have passed since 1970-01-01T00:00:00.000, Coordinated Universal-
4329 Time (Qt::UTC) and with the given \a timeZone.-
4330-
4331 \sa fromTime_t()-
4332*/-
4333QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)-
4334{-
4335 QDateTime dt;-
4336 dt.setTimeZone(timeZone);-
4337 dt.setMSecsSinceEpoch(msecs);-
4338 return dt;
executed 10 times by 1 test: return dt;
Executed by:
  • tst_QDateTime
10
4339}-
4340#endif-
4341-
4342#if QT_DEPRECATED_SINCE(5, 2)-
4343/*!-
4344 \since 4.4-
4345 \internal-
4346 \obsolete-
4347-
4348 This method was added in 4.4 but never documented as public. It was replaced-
4349 in 5.2 with public method setOffsetFromUtc() for consistency with QTimeZone.-
4350-
4351 This method should never be made public.-
4352-
4353 \sa setOffsetFromUtc()-
4354 */-
4355void QDateTime::setUtcOffset(int seconds)-
4356{-
4357 setOffsetFromUtc(seconds);-
4358}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QDateTime
4
4359-
4360/*!-
4361 \since 4.4-
4362 \internal-
4363 \obsolete-
4364-
4365 This method was added in 4.4 but never documented as public. It was replaced-
4366 in 5.1 with public method offsetFromUTC() for consistency with QTimeZone.-
4367-
4368 This method should never be made public.-
4369-
4370 \sa offsetFromUTC()-
4371*/-
4372int QDateTime::utcOffset() const-
4373{-
4374 return offsetFromUtc();
executed 20 times by 1 test: return offsetFromUtc();
Executed by:
  • tst_QDateTime
20
4375}-
4376#endif // QT_DEPRECATED_SINCE-
4377-
4378#ifndef QT_NO_DATESTRING-
4379-
4380/*!-
4381 \fn QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)-
4382-
4383 Returns the QDateTime represented by the \a string, using the-
4384 \a format given, or an invalid datetime if this is not possible.-
4385-
4386 Note for Qt::TextDate: It is recommended that you use the-
4387 English short month names (e.g. "Jan"). Although localized month-
4388 names can also be used, they depend on the user's locale settings.-
4389-
4390 \sa toString(), QLocale::toDateTime()-
4391*/-
4392QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format)-
4393{-
4394 if (string.isEmpty())
string.isEmpty()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 144 times by 6 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QNetworkRequest
  • tst_QSqlQuery
  • tst_QVariant
5-144
4395 return QDateTime();
executed 5 times by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
5
4396-
4397 switch (format) {-
4398 case Qt::SystemLocaleDate:
executed 1 time by 1 test: case Qt::SystemLocaleDate:
Executed by:
  • tst_QDateTime
1
4399 case Qt::SystemLocaleShortDate:
executed 1 time by 1 test: case Qt::SystemLocaleShortDate:
Executed by:
  • tst_QDateTime
1
4400 return QLocale::system().toDateTime(string, QLocale::ShortFormat);
executed 2 times by 1 test: return QLocale::system().toDateTime(string, QLocale::ShortFormat);
Executed by:
  • tst_QDateTime
2
4401 case Qt::SystemLocaleLongDate:
executed 1 time by 1 test: case Qt::SystemLocaleLongDate:
Executed by:
  • tst_QDateTime
1
4402 return QLocale::system().toDateTime(string, QLocale::LongFormat);
executed 1 time by 1 test: return QLocale::system().toDateTime(string, QLocale::LongFormat);
Executed by:
  • tst_QDateTime
1
4403 case Qt::LocaleDate:
executed 1 time by 1 test: case Qt::LocaleDate:
Executed by:
  • tst_QDateTime
1
4404 case Qt::DefaultLocaleShortDate:
executed 1 time by 1 test: case Qt::DefaultLocaleShortDate:
Executed by:
  • tst_QDateTime
1
4405 return QLocale().toDateTime(string, QLocale::ShortFormat);
executed 2 times by 1 test: return QLocale().toDateTime(string, QLocale::ShortFormat);
Executed by:
  • tst_QDateTime
2
4406 case Qt::DefaultLocaleLongDate:
executed 1 time by 1 test: case Qt::DefaultLocaleLongDate:
Executed by:
  • tst_QDateTime
1
4407 return QLocale().toDateTime(string, QLocale::LongFormat);
executed 1 time by 1 test: return QLocale().toDateTime(string, QLocale::LongFormat);
Executed by:
  • tst_QDateTime
1
4408 case Qt::RFC2822Date: {
executed 30 times by 1 test: case Qt::RFC2822Date:
Executed by:
  • tst_QDateTime
30
4409 const ParsedRfcDateTime rfc = rfcDateImpl(string);-
4410-
4411 if (!rfc.date.isValid() || !rfc.time.isValid())
!rfc.date.isValid()Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 19 times by 1 test
Evaluated by:
  • tst_QDateTime
!rfc.time.isValid()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QDateTime
3-19
4412 return QDateTime();
executed 14 times by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
14
4413-
4414 QDateTime dateTime(rfc.date, rfc.time, Qt::UTC);-
4415 dateTime.setOffsetFromUtc(rfc.utcOffset);-
4416 return dateTime;
executed 16 times by 1 test: return dateTime;
Executed by:
  • tst_QDateTime
16
4417 }-
4418 case Qt::ISODate: {
executed 66 times by 4 tests: case Qt::ISODate:
Executed by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
66
4419 const int size = string.size();-
4420 if (size < 10)
size < 10Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QVariant
FALSEevaluated 62 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
4-62
4421 return QDateTime();
executed 4 times by 1 test: return QDateTime();
Executed by:
  • tst_QVariant
4
4422-
4423 QStringRef isoString(&string);-
4424 Qt::TimeSpec spec = Qt::LocalTime;-
4425-
4426 QDate date = QDate::fromString(string.left(10), Qt::ISODate);-
4427 if (!date.isValid())
!date.isValid()Description
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QVariant
FALSEevaluated 55 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
7-55
4428 return QDateTime();
executed 7 times by 2 tests: return QDateTime();
Executed by:
  • tst_QDateTime
  • tst_QVariant
7
4429 if (size == 10)
size == 10Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 54 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
1-54
4430 return QDateTime(date);
executed 1 time by 1 test: return QDateTime(date);
Executed by:
  • tst_QDateTime
1
4431-
4432 isoString = isoString.right(isoString.length() - 11);-
4433 int offset = 0;-
4434 // Check end of string for Time Zone definition, either Z for UTC or [+-]HH:mm for Offset-
4435 if (isoString.endsWith(QLatin1Char('Z'))) {
isoString.ends...tin1Char('Z'))Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 48 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
6-48
4436 spec = Qt::UTC;-
4437 isoString = isoString.left(isoString.size() - 1);-
4438 } else {
executed 6 times by 1 test: end of block
Executed by:
  • tst_QDateTime
6
4439 // the loop below is faster but functionally equal to:-
4440 // const int signIndex = isoString.indexOf(QRegExp(QStringLiteral("[+-]")));-
4441 int signIndex = isoString.size() - 1;-
4442 bool found = false;-
4443 {-
4444 const QChar plus = QLatin1Char('+');-
4445 const QChar minus = QLatin1Char('-');-
4446 do {-
4447 QChar character(isoString.at(signIndex));-
4448 found = character == plus || character == minus;
character == plusDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 397 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
character == minusDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 389 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
5-397
4449 } while (--signIndex >= 0 && !found);
executed 402 times by 4 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
--signIndex >= 0Description
TRUEevaluated 367 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
FALSEevaluated 35 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
!foundDescription
TRUEevaluated 354 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_QDateTime
13-402
4450 ++signIndex;-
4451 }-
4452-
4453 if (found) {
foundDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 35 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
13-35
4454 bool ok;-
4455 offset = fromOffsetString(isoString.mid(signIndex), &ok);-
4456 if (!ok)
!okDescription
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_QDateTime
0-13
4457 return QDateTime();
never executed: return QDateTime();
0
4458 isoString = isoString.left(signIndex);-
4459 spec = Qt::OffsetFromUTC;-
4460 }
executed 13 times by 1 test: end of block
Executed by:
  • tst_QDateTime
13
4461 }
executed 48 times by 4 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
48
4462-
4463 // Might be end of day (24:00, including variants), which QTime considers invalid.-
4464 // ISO 8601 (section 4.2.3) says that 24:00 is equivalent to 00:00 the next day.-
4465 bool isMidnight24 = false;-
4466 QTime time = fromIsoTimeString(isoString, Qt::ISODate, &isMidnight24);-
4467 if (!time.isValid())
!time.isValid()Description
TRUEnever evaluated
FALSEevaluated 54 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
0-54
4468 return QDateTime();
never executed: return QDateTime();
0
4469 if (isMidnight24)
isMidnight24Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 49 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
5-49
4470 date = date.addDays(1);
executed 5 times by 1 test: date = date.addDays(1);
Executed by:
  • tst_QDateTime
5
4471 return QDateTime(date, time, spec, offset);
executed 54 times by 4 tests: return QDateTime(date, time, spec, offset);
Executed by:
  • tst_QDateTime
  • tst_QNetworkReply
  • tst_QSqlQuery
  • tst_QVariant
54
4472 }-
4473#if !defined(QT_NO_TEXTDATE)-
4474 case Qt::TextDate: {
executed 42 times by 3 tests: case Qt::TextDate:
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
42
4475 QVector<QStringRef> parts = string.splitRef(QLatin1Char(' '), QString::SkipEmptyParts);-
4476-
4477 if ((parts.count() < 5) || (parts.count() > 6))
(parts.count() < 5)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 41 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
(parts.count() > 6)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
1-41
4478 return QDateTime();
executed 2 times by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
2
4479-
4480 // Accept "Sun Dec 1 13:02:00 1974" and "Sun 1. Dec 13:02:00 1974"-
4481 int month = 0;-
4482 int day = 0;-
4483 bool ok = false;-
4484-
4485 // First try month then day-
4486 month = fromShortMonthName(parts.at(1));-
4487 if (month)
monthDescription
TRUEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
FALSEnever evaluated
0-40
4488 day = parts.at(2).toInt();
executed 40 times by 3 tests: day = parts.at(2).toInt();
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
40
4489-
4490 // If failed try day then month-
4491 if (!month || !day) {
!monthDescription
TRUEnever evaluated
FALSEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
!dayDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 26 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
0-40
4492 month = fromShortMonthName(parts.at(2));-
4493 if (month) {
monthDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEnever evaluated
0-14
4494 QStringRef dayStr = parts.at(1);-
4495 if (dayStr.endsWith(QLatin1Char('.'))) {
dayStr.endsWit...tin1Char('.'))Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDateTime
2-12
4496 dayStr = dayStr.left(dayStr.size() - 1);-
4497 day = dayStr.toInt();-
4498 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_QDateTime
12
4499 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_QDateTime
14
4500 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_QDateTime
14
4501-
4502 // If both failed, give up-
4503 if (!month || !day)
!monthDescription
TRUEnever evaluated
FALSEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
!dayDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 37 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
0-40
4504 return QDateTime();
executed 3 times by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
3
4505-
4506 // Year can be before or after time, "Sun Dec 1 1974 13:02:00" or "Sun Dec 1 13:02:00 1974"-
4507 // Guess which by looking for ':' in the time-
4508 int year = 0;-
4509 int yearPart = 0;-
4510 int timePart = 0;-
4511 if (parts.at(3).contains(QLatin1Char(':'))) {
parts.at(3).co...tin1Char(':'))Description
TRUEevaluated 23 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_QDateTime
14-23
4512 yearPart = 4;-
4513 timePart = 3;-
4514 } else if (parts.at(4).contains(QLatin1Char(':'))) {
executed 23 times by 3 tests: end of block
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
parts.at(4).co...tin1Char(':'))Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
1-23
4515 yearPart = 3;-
4516 timePart = 4;-
4517 } else {
executed 13 times by 1 test: end of block
Executed by:
  • tst_QDateTime
13
4518 return QDateTime();
executed 1 time by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
1
4519 }-
4520-
4521 year = parts.at(yearPart).toInt(&ok);-
4522 if (!ok)
!okDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 34 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
2-34
4523 return QDateTime();
executed 2 times by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
2
4524-
4525 QDate date(year, month, day);-
4526 if (!date.isValid())
!date.isValid()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 32 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
2-32
4527 return QDateTime();
executed 2 times by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
2
4528-
4529 QVector<QStringRef> timeParts = parts.at(timePart).split(QLatin1Char(':'));-
4530 if (timeParts.count() < 2 || timeParts.count() > 3)
timeParts.count() < 2Description
TRUEnever evaluated
FALSEevaluated 32 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
timeParts.count() > 3Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 31 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
0-32
4531 return QDateTime();
executed 1 time by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
1
4532-
4533 int hour = timeParts.at(0).toInt(&ok);-
4534 if (!ok)
!okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 30 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
1-30
4535 return QDateTime();
executed 1 time by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
1
4536-
4537 int minute = timeParts.at(1).toInt(&ok);-
4538 if (!ok)
!okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 29 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
1-29
4539 return QDateTime();
executed 1 time by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
1
4540-
4541 int second = 0;-
4542 int millisecond = 0;-
4543 if (timeParts.count() > 2) {
timeParts.count() > 2Description
TRUEevaluated 28 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
1-28
4544 const QVector<QStringRef> secondParts = timeParts.at(2).split(QLatin1Char('.'));-
4545 if (secondParts.size() > 2) {
secondParts.size() > 2Description
TRUEnever evaluated
FALSEevaluated 28 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
0-28
4546 return QDateTime();
never executed: return QDateTime();
0
4547 }-
4548-
4549 second = secondParts.first().toInt(&ok);-
4550 if (!ok) {
!okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 27 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
1-27
4551 return QDateTime();
executed 1 time by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
1
4552 }-
4553-
4554 if (secondParts.size() > 1) {
secondParts.size() > 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 26 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
1-26
4555 millisecond = secondParts.last().toInt(&ok);-
4556 if (!ok) {
!okDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
0-1
4557 return QDateTime();
never executed: return QDateTime();
0
4558 }-
4559 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QDateTime
1
4560 }
executed 27 times by 3 tests: end of block
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
27
4561-
4562 QTime time(hour, minute, second, millisecond);-
4563 if (!time.isValid())
!time.isValid()Description
TRUEnever evaluated
FALSEevaluated 28 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
0-28
4564 return QDateTime();
never executed: return QDateTime();
0
4565-
4566 if (parts.count() == 5)
parts.count() == 5Description
TRUEevaluated 15 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_QDateTime
13-15
4567 return QDateTime(date, time, Qt::LocalTime);
executed 15 times by 3 tests: return QDateTime(date, time, Qt::LocalTime);
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QNetworkRequest
15
4568-
4569 QStringRef tz = parts.at(5);-
4570 if (!tz.startsWith(QLatin1String("GMT"), Qt::CaseInsensitive))
!tz.startsWith...seInsensitive)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QDateTime
1-12
4571 return QDateTime();
executed 1 time by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
1
4572 tz = tz.mid(3);-
4573 if (!tz.isEmpty()) {
!tz.isEmpty()Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QDateTime
3-9
4574 int offset = fromOffsetString(tz, &ok);-
4575 if (!ok)
!okDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QDateTime
4-5
4576 return QDateTime();
executed 4 times by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
4
4577 return QDateTime(date, time, Qt::OffsetFromUTC, offset);
executed 5 times by 1 test: return QDateTime(date, time, Qt::OffsetFromUTC, offset);
Executed by:
  • tst_QDateTime
5
4578 } else {-
4579 return QDateTime(date, time, Qt::UTC);
executed 3 times by 1 test: return QDateTime(date, time, Qt::UTC);
Executed by:
  • tst_QDateTime
3
4580 }-
4581 }-
4582#endif //QT_NO_TEXTDATE-
4583 }-
4584-
4585 return QDateTime();
never executed: return QDateTime();
0
4586}-
4587-
4588/*!-
4589 \fn QDateTime::fromString(const QString &string, const QString &format)-
4590-
4591 Returns the QDateTime represented by the \a string, using the \a-
4592 format given, or an invalid datetime if the string cannot be parsed.-
4593-
4594 These expressions may be used for the date part of the format string:-
4595-
4596 \table-
4597 \header \li Expression \li Output-
4598 \row \li d \li the day as number without a leading zero (1 to 31)-
4599 \row \li dd \li the day as number with a leading zero (01 to 31)-
4600 \row \li ddd-
4601 \li the abbreviated localized day name (e.g. 'Mon' to 'Sun').-
4602 Uses QDate::shortDayName().-
4603 \row \li dddd-
4604 \li the long localized day name (e.g. 'Monday' to 'Sunday').-
4605 Uses QDate::longDayName().-
4606 \row \li M \li the month as number without a leading zero (1-12)-
4607 \row \li MM \li the month as number with a leading zero (01-12)-
4608 \row \li MMM-
4609 \li the abbreviated localized month name (e.g. 'Jan' to 'Dec').-
4610 Uses QDate::shortMonthName().-
4611 \row \li MMMM-
4612 \li the long localized month name (e.g. 'January' to 'December').-
4613 Uses QDate::longMonthName().-
4614 \row \li yy \li the year as two digit number (00-99)-
4615 \row \li yyyy \li the year as four digit number-
4616 \endtable-
4617-
4618 \note Unlike the other version of this function, day and month names must-
4619 be given in the user's local language. It is only possible to use the English-
4620 names if the user's language is English.-
4621-
4622 These expressions may be used for the time part of the format string:-
4623-
4624 \table-
4625 \header \li Expression \li Output-
4626 \row \li h-
4627 \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)-
4628 \row \li hh-
4629 \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)-
4630 \row \li H-
4631 \li the hour without a leading zero (0 to 23, even with AM/PM display)-
4632 \row \li HH-
4633 \li the hour with a leading zero (00 to 23, even with AM/PM display)-
4634 \row \li m \li the minute without a leading zero (0 to 59)-
4635 \row \li mm \li the minute with a leading zero (00 to 59)-
4636 \row \li s \li the second without a leading zero (0 to 59)-
4637 \row \li ss \li the second with a leading zero (00 to 59)-
4638 \row \li z \li the milliseconds without leading zeroes (0 to 999)-
4639 \row \li zzz \li the milliseconds with leading zeroes (000 to 999)-
4640 \row \li AP or A-
4641 \li interpret as an AM/PM time. \e AP must be either "AM" or "PM".-
4642 \row \li ap or a-
4643 \li Interpret as an AM/PM time. \e ap must be either "am" or "pm".-
4644 \endtable-
4645-
4646 All other input characters will be treated as text. Any sequence-
4647 of characters that are enclosed in single quotes will also be-
4648 treated as text and not be used as an expression.-
4649-
4650 \snippet code/src_corelib_tools_qdatetime.cpp 12-
4651-
4652 If the format is not satisfied, an invalid QDateTime is returned.-
4653 The expressions that don't have leading zeroes (d, M, h, m, s, z) will be-
4654 greedy. This means that they will use two digits even if this will-
4655 put them outside the range and/or leave too few digits for other-
4656 sections.-
4657-
4658 \snippet code/src_corelib_tools_qdatetime.cpp 13-
4659-
4660 This could have meant 1 January 00:30.00 but the M will grab-
4661 two digits.-
4662-
4663 Incorrectly specified fields of the \a string will cause an invalid-
4664 QDateTime to be returned. For example, consider the following code,-
4665 where the two digit year 12 is read as 1912 (see the table below for all-
4666 field defaults); the resulting datetime is invalid because 23 April 1912-
4667 was a Tuesday, not a Monday:-
4668-
4669 \snippet code/src_corelib_tools_qdatetime.cpp 20-
4670-
4671 The correct code is:-
4672-
4673 \snippet code/src_corelib_tools_qdatetime.cpp 21-
4674-
4675 For any field that is not represented in the format, the following-
4676 defaults are used:-
4677-
4678 \table-
4679 \header \li Field \li Default value-
4680 \row \li Year \li 1900-
4681 \row \li Month \li 1 (January)-
4682 \row \li Day \li 1-
4683 \row \li Hour \li 0-
4684 \row \li Minute \li 0-
4685 \row \li Second \li 0-
4686 \endtable-
4687-
4688 For example:-
4689-
4690 \snippet code/src_corelib_tools_qdatetime.cpp 14-
4691-
4692 \sa toString(), QDate::fromString(), QTime::fromString(),-
4693 QLocale::toDateTime()-
4694*/-
4695-
4696QDateTime QDateTime::fromString(const QString &string, const QString &format)-
4697{-
4698#ifndef QT_BOOTSTRAPPED-
4699 QTime time;-
4700 QDate date;-
4701-
4702 QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString);-
4703 if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
dt.parseFormat(format)Description
TRUEevaluated 49 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
FALSEnever evaluated
dt.fromString(... &date, &time)Description
TRUEevaluated 41 times by 4 tests
Evaluated by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QDateTime
0-49
4704 return QDateTime(date, time);
executed 41 times by 4 tests: return QDateTime(date, time);
Executed by:
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QNetworkCookieJar
  • tst_QNetworkReply
41
4705#else-
4706 Q_UNUSED(string);-
4707 Q_UNUSED(format);-
4708#endif-
4709 return QDateTime();
executed 8 times by 1 test: return QDateTime();
Executed by:
  • tst_QDateTime
8
4710}-
4711-
4712#endif // QT_NO_DATESTRING-
4713/*!-
4714 \fn QDateTime QDateTime::toLocalTime() const-
4715-
4716 Returns a datetime containing the date and time information in-
4717 this datetime, but specified using the Qt::LocalTime definition.-
4718-
4719 Example:-
4720-
4721 \snippet code/src_corelib_tools_qdatetime.cpp 17-
4722-
4723 \sa toTimeSpec()-
4724*/-
4725-
4726/*!-
4727 \fn QDateTime QDateTime::toUTC() const-
4728-
4729 Returns a datetime containing the date and time information in-
4730 this datetime, but specified using the Qt::UTC definition.-
4731-
4732 Example:-
4733-
4734 \snippet code/src_corelib_tools_qdatetime.cpp 18-
4735-
4736 \sa toTimeSpec()-
4737*/-
4738-
4739/*****************************************************************************-
4740 Date/time stream functions-
4741 *****************************************************************************/-
4742-
4743#ifndef QT_NO_DATASTREAM-
4744/*!-
4745 \relates QDate-
4746-
4747 Writes the \a date to stream \a out.-
4748-
4749 \sa {Serializing Qt Data Types}-
4750*/-
4751-
4752QDataStream &operator<<(QDataStream &out, const QDate &date)-
4753{-
4754 if (out.version() < QDataStream::Qt_5_0)
out.version() ...Stream::Qt_5_0Description
TRUEevaluated 248 times by 4 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QSettings
  • tst_QVariant
FALSEevaluated 495 times by 10 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
248-495
4755 return out << quint32(date.jd);
executed 248 times by 4 tests: return out << quint32(date.jd);
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QSettings
  • tst_QVariant
248
4756 else-
4757 return out << qint64(date.jd);
executed 495 times by 10 tests: return out << qint64(date.jd);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
495
4758}-
4759-
4760/*!-
4761 \relates QDate-
4762-
4763 Reads a date from stream \a in into the \a date.-
4764-
4765 \sa {Serializing Qt Data Types}-
4766*/-
4767-
4768QDataStream &operator>>(QDataStream &in, QDate &date)-
4769{-
4770 if (in.version() < QDataStream::Qt_5_0) {
in.version() <...Stream::Qt_5_0Description
TRUEevaluated 250 times by 4 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QSettings
  • tst_QVariant
FALSEevaluated 491 times by 10 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
250-491
4771 quint32 jd;-
4772 in >> jd;-
4773 // Older versions consider 0 an invalid jd.-
4774 date.jd = (jd != 0 ? jd : QDate::nullJd());
jd != 0Description
TRUEevaluated 234 times by 3 tests
Evaluated by:
  • tst_QDate
  • tst_QDateTime
  • tst_QSettings
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QDate
  • tst_QVariant
16-234
4775 } else {
executed 250 times by 4 tests: end of block
Executed by:
  • tst_QDate
  • tst_QDateTime
  • tst_QSettings
  • tst_QVariant
250
4776 qint64 jd;-
4777 in >> jd;-
4778 date.jd = jd;-
4779 }
executed 491 times by 10 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
491
4780-
4781 return in;
executed 741 times by 10 tests: return in;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDate
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
741
4782}-
4783-
4784/*!-
4785 \relates QTime-
4786-
4787 Writes \a time to stream \a out.-
4788-
4789 \sa {Serializing Qt Data Types}-
4790*/-
4791-
4792QDataStream &operator<<(QDataStream &out, const QTime &time)-
4793{-
4794 if (out.version() >= QDataStream::Qt_4_0) {
out.version() ...Stream::Qt_4_0Description
TRUEevaluated 872 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
FALSEevaluated 73 times by 2 tests
Evaluated by:
  • tst_QDataStream
  • tst_QDateTime
73-872
4795 return out << quint32(time.mds);
executed 872 times by 9 tests: return out << quint32(time.mds);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
872
4796 } else {-
4797 // Qt3 had no support for reading -1, QTime() was valid and serialized as 0-
4798 return out << quint32(time.isNull() ? 0 : time.mds);
executed 73 times by 2 tests: return out << quint32(time.isNull() ? 0 : time.mds);
Executed by:
  • tst_QDataStream
  • tst_QDateTime
73
4799 }-
4800}-
4801-
4802/*!-
4803 \relates QTime-
4804-
4805 Reads a time from stream \a in into the given \a time.-
4806-
4807 \sa {Serializing Qt Data Types}-
4808*/-
4809-
4810QDataStream &operator>>(QDataStream &in, QTime &time)-
4811{-
4812 quint32 ds;-
4813 in >> ds;-
4814 if (in.version() >= QDataStream::Qt_4_0) {
in.version() >...Stream::Qt_4_0Description
TRUEevaluated 870 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
FALSEevaluated 73 times by 2 tests
Evaluated by:
  • tst_QDataStream
  • tst_QDateTime
73-870
4815 time.mds = int(ds);-
4816 } else {
executed 870 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
870
4817 // Qt3 would write 0 for a null time-
4818 time.mds = (ds == 0) ? QTime::NullTime : int(ds);
(ds == 0)Description
TRUEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QDataStream
  • tst_QDateTime
FALSEevaluated 48 times by 1 test
Evaluated by:
  • tst_QDateTime
25-48
4819 }
executed 73 times by 2 tests: end of block
Executed by:
  • tst_QDataStream
  • tst_QDateTime
73
4820 return in;
executed 943 times by 9 tests: return in;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
943
4821}-
4822-
4823/*!-
4824 \relates QDateTime-
4825-
4826 Writes \a dateTime to the \a out stream.-
4827-
4828 \sa {Serializing Qt Data Types}-
4829*/-
4830QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)-
4831{-
4832 QPair<QDate, QTime> dateAndTime;-
4833-
4834 if (out.version() >= QDataStream::Qt_5_2) {
out.version() ...Stream::Qt_5_2Description
TRUEevaluated 325 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
FALSEevaluated 168 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
168-325
4835-
4836 // In 5.2 we switched to using Qt::TimeSpec and added offset support-
4837 dateAndTime = dateTime.d->getDateTime();-
4838 out << dateAndTime << qint8(dateTime.timeSpec());-
4839 if (dateTime.timeSpec() == Qt::OffsetFromUTC)
dateTime.timeS...:OffsetFromUTCDescription
TRUEevaluated 11 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QSettings
FALSEevaluated 314 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
11-314
4840 out << qint32(dateTime.offsetFromUtc());
executed 11 times by 3 tests: out << qint32(dateTime.offsetFromUtc());
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QSettings
11
4841#ifndef QT_BOOTSTRAPPED-
4842 else if (dateTime.timeSpec() == Qt::TimeZone)
dateTime.timeS...= Qt::TimeZoneDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 313 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
1-313
4843 out << dateTime.timeZone();
executed 1 time by 1 test: out << dateTime.timeZone();
Executed by:
  • tst_QDateTime
1
4844#endif // QT_BOOTSTRAPPED-
4845-
4846 } else if (out.version() == QDataStream::Qt_5_0) {
executed 325 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
out.version() ...Stream::Qt_5_0Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QVariant
FALSEevaluated 159 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
9-325
4847-
4848 // In Qt 5.0 we incorrectly serialised all datetimes as UTC.-
4849 // This approach is wrong and should not be used again; it breaks-
4850 // the guarantee that a deserialised local datetime is the same time-
4851 // of day, regardless of which timezone it was serialised in.-
4852 dateAndTime = (dateTime.isValid() ? dateTime.toUTC() : dateTime).d->getDateTime();
dateTime.isValid()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QVariant
1-8
4853 out << dateAndTime << qint8(dateTime.timeSpec());-
4854-
4855 } else if (out.version() >= QDataStream::Qt_4_0) {
executed 9 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QVariant
out.version() ...Stream::Qt_4_0Description
TRUEevaluated 87 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
FALSEevaluated 72 times by 1 test
Evaluated by:
  • tst_QDateTime
9-87
4856-
4857 // From 4.0 to 5.1 (except 5.0) we used QDateTimePrivate::Spec-
4858 dateAndTime = dateTime.d->getDateTime();-
4859 out << dateAndTime;-
4860 switch (dateTime.timeSpec()) {-
4861 case Qt::UTC:
executed 56 times by 1 test: case Qt::UTC:
Executed by:
  • tst_QDateTime
56
4862 out << (qint8)QDateTimePrivate::UTC;-
4863 break;
executed 56 times by 1 test: break;
Executed by:
  • tst_QDateTime
56
4864 case Qt::OffsetFromUTC:
executed 1 time by 1 test: case Qt::OffsetFromUTC:
Executed by:
  • tst_QNetworkDiskCache
1
4865 out << (qint8)QDateTimePrivate::OffsetFromUTC;-
4866 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QNetworkDiskCache
1
4867 case Qt::TimeZone:
never executed: case Qt::TimeZone:
0
4868 out << (qint8)QDateTimePrivate::TimeZone;-
4869 break;
never executed: break;
0
4870 case Qt::LocalTime:
executed 30 times by 3 tests: case Qt::LocalTime:
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
30
4871 out << (qint8)QDateTimePrivate::LocalUnknown;-
4872 break;
executed 30 times by 3 tests: break;
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
30
4873 }-
4874-
4875 } else { // version < QDataStream::Qt_4_0
executed 87 times by 3 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
87
4876-
4877 // Before 4.0 there was no TimeSpec, only Qt::LocalTime was supported-
4878 dateAndTime = dateTime.d->getDateTime();-
4879 out << dateAndTime;-
4880-
4881 }
executed 72 times by 1 test: end of block
Executed by:
  • tst_QDateTime
72
4882-
4883 return out;
executed 493 times by 9 tests: return out;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
493
4884}-
4885-
4886/*!-
4887 \relates QDateTime-
4888-
4889 Reads a datetime from the stream \a in into \a dateTime.-
4890-
4891 \sa {Serializing Qt Data Types}-
4892*/-
4893-
4894QDataStream &operator>>(QDataStream &in, QDateTime &dateTime)-
4895{-
4896 QDate dt;-
4897 QTime tm;-
4898 qint8 ts = 0;-
4899 Qt::TimeSpec spec = Qt::LocalTime;-
4900 qint32 offset = 0;-
4901#ifndef QT_BOOTSTRAPPED-
4902 QTimeZone tz;-
4903#endif // QT_BOOTSTRAPPED-
4904-
4905 if (in.version() >= QDataStream::Qt_5_2) {
in.version() >...Stream::Qt_5_2Description
TRUEevaluated 303 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
116-303
4906-
4907 // In 5.2 we switched to using Qt::TimeSpec and added offset support-
4908 in >> dt >> tm >> ts;-
4909 spec = static_cast<Qt::TimeSpec>(ts);-
4910 if (spec == Qt::OffsetFromUTC) {
spec == Qt::OffsetFromUTCDescription
TRUEevaluated 11 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QSettings
FALSEevaluated 292 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
11-292
4911 in >> offset;-
4912 dateTime = QDateTime(dt, tm, spec, offset);-
4913#ifndef QT_BOOTSTRAPPED-
4914 } else if (spec == Qt::TimeZone) {
executed 11 times by 3 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QSettings
spec == Qt::TimeZoneDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QDateTime
FALSEevaluated 291 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
1-291
4915 in >> tz;-
4916 dateTime = QDateTime(dt, tm, tz);-
4917#endif // QT_BOOTSTRAPPED-
4918 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_QDateTime
1
4919 dateTime = QDateTime(dt, tm, spec);-
4920 }
executed 291 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QVariant
291
4921-
4922 } else if (in.version() == QDataStream::Qt_5_0) {
in.version() =...Stream::Qt_5_0Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDateTime
  • tst_QVariant
FALSEevaluated 110 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
6-110
4923-
4924 // In Qt 5.0 we incorrectly serialised all datetimes as UTC-
4925 in >> dt >> tm >> ts;-
4926 spec = static_cast<Qt::TimeSpec>(ts);-
4927 dateTime = QDateTime(dt, tm, Qt::UTC);-
4928 dateTime = dateTime.toTimeSpec(spec);-
4929-
4930 } else if (in.version() >= QDataStream::Qt_4_0) {
executed 6 times by 2 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QVariant
in.version() >...Stream::Qt_4_0Description
TRUEevaluated 62 times by 3 tests
Evaluated by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
FALSEevaluated 48 times by 1 test
Evaluated by:
  • tst_QDateTime
6-62
4931-
4932 // From 4.0 to 5.1 (except 5.0) we used QDateTimePrivate::Spec-
4933 in >> dt >> tm >> ts;-
4934 switch ((QDateTimePrivate::Spec)ts) {-
4935 case QDateTimePrivate::UTC:
executed 28 times by 1 test: case QDateTimePrivate::UTC:
Executed by:
  • tst_QDateTime
28
4936 spec = Qt::UTC;-
4937 break;
executed 28 times by 1 test: break;
Executed by:
  • tst_QDateTime
28
4938 case QDateTimePrivate::OffsetFromUTC:
executed 2 times by 1 test: case QDateTimePrivate::OffsetFromUTC:
Executed by:
  • tst_QNetworkDiskCache
2
4939 spec = Qt::OffsetFromUTC;-
4940 break;
executed 2 times by 1 test: break;
Executed by:
  • tst_QNetworkDiskCache
2
4941 case QDateTimePrivate::TimeZone:
never executed: case QDateTimePrivate::TimeZone:
0
4942 spec = Qt::TimeZone;-
4943#ifndef QT_BOOTSTRAPPED-
4944 // FIXME: need to use a different constructor !-
4945#endif-
4946 break;
never executed: break;
0
4947 case QDateTimePrivate::LocalUnknown:
executed 32 times by 3 tests: case QDateTimePrivate::LocalUnknown:
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
32
4948 case QDateTimePrivate::LocalStandard:
never executed: case QDateTimePrivate::LocalStandard:
0
4949 case QDateTimePrivate::LocalDST:
never executed: case QDateTimePrivate::LocalDST:
0
4950 spec = Qt::LocalTime;-
4951 break;
executed 32 times by 3 tests: break;
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
32
4952 }-
4953 dateTime = QDateTime(dt, tm, spec, offset);-
4954-
4955 } else { // version < QDataStream::Qt_4_0
executed 62 times by 3 tests: end of block
Executed by:
  • tst_QDateTime
  • tst_QNetworkDiskCache
  • tst_QVariant
62
4956-
4957 // Before 4.0 there was no TimeSpec, only Qt::LocalTime was supported-
4958 in >> dt >> tm;-
4959 dateTime = QDateTime(dt, tm, spec, offset);-
4960-
4961 }
executed 48 times by 1 test: end of block
Executed by:
  • tst_QDateTime
48
4962-
4963 return in;
executed 419 times by 9 tests: return in;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QDateTime
  • tst_QMetaType
  • tst_QNetworkCacheMetaData
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
  • tst_QVariant
419
4964}-
4965#endif // QT_NO_DATASTREAM-
4966-
4967/*****************************************************************************-
4968 Date / Time Debug Streams-
4969*****************************************************************************/-
4970-
4971#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING)-
4972QDebug operator<<(QDebug dbg, const QDate &date)-
4973{-
4974 QDebugStateSaver saver(dbg);-
4975 dbg.nospace() << "QDate(" << date.toString(Qt::ISODate) << ')';-
4976 return dbg;
executed 3 times by 2 tests: return dbg;
Executed by:
  • tst_QDate
  • tst_QVariant
3
4977}-
4978-
4979QDebug operator<<(QDebug dbg, const QTime &time)-
4980{-
4981 QDebugStateSaver saver(dbg);-
4982 dbg.nospace() << "QTime(" << time.toString(QStringLiteral("HH:mm:ss.zzz")) << ')';
executed 1 time by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QVariant
1
4983 return dbg;
executed 1 time by 1 test: return dbg;
Executed by:
  • tst_QVariant
1
4984}-
4985-
4986QDebug operator<<(QDebug dbg, const QDateTime &date)-
4987{-
4988 QDebugStateSaver saver(dbg);-
4989 const Qt::TimeSpec ts = date.timeSpec();-
4990 dbg.nospace() << "QDateTime(";-
4991 dbg.noquote() << date.toString(QStringLiteral("yyyy-MM-dd HH:mm:ss.zzz t"))
executed 2 times by 2 tests: return qstring_literal_temp;
Executed by:
  • tst_QNoDebug
  • tst_QVariant
2
4992 << ' ' << ts;-
4993 switch (ts) {-
4994 case Qt::UTC:
never executed: case Qt::UTC:
0
4995 break;
never executed: break;
0
4996 case Qt::OffsetFromUTC:
never executed: case Qt::OffsetFromUTC:
0
4997 dbg << ' ' << date.offsetFromUtc() << 's';-
4998 break;
never executed: break;
0
4999 case Qt::TimeZone:
never executed: case Qt::TimeZone:
0
5000#ifndef QT_BOOTSTRAPPED-
5001 dbg << ' ' << date.timeZone().id();-
5002#endif // QT_BOOTSTRAPPED-
5003 break;
never executed: break;
0
5004 case Qt::LocalTime:
executed 2 times by 2 tests: case Qt::LocalTime:
Executed by:
  • tst_QNoDebug
  • tst_QVariant
2
5005 break;
executed 2 times by 2 tests: break;
Executed by:
  • tst_QNoDebug
  • tst_QVariant
2
5006 }-
5007 return dbg << ')';
executed 2 times by 2 tests: return dbg << ')';
Executed by:
  • tst_QNoDebug
  • tst_QVariant
2
5008}-
5009#endif-
5010-
5011/*! \fn uint qHash(const QDateTime &key, uint seed = 0)-
5012 \relates QHash-
5013 \since 5.0-
5014-
5015 Returns the hash value for the \a key, using \a seed to seed the calculation.-
5016*/-
5017uint qHash(const QDateTime &key, uint seed)-
5018{-
5019 // Use to toMSecsSinceEpoch instead of individual qHash functions for-
5020 // QDate/QTime/spec/offset because QDateTime::operator== converts both arguments-
5021 // to the same timezone. If we don't, qHash would return different hashes for-
5022 // two QDateTimes that are equivalent once converted to the same timezone.-
5023 return qHash(key.toMSecsSinceEpoch(), seed);
executed 16 times by 1 test: return qHash(key.toMSecsSinceEpoch(), seed);
Executed by:
  • tst_QDateTime
16
5024}-
5025-
5026/*! \fn uint qHash(const QDate &key, uint seed = 0)-
5027 \relates QHash-
5028 \since 5.0-
5029-
5030 Returns the hash value for the \a key, using \a seed to seed the calculation.-
5031*/-
5032uint qHash(const QDate &key, uint seed) Q_DECL_NOTHROW-
5033{-
5034 return qHash(key.toJulianDay(), seed);
executed 6 times by 1 test: return qHash(key.toJulianDay(), seed);
Executed by:
  • tst_QDate
6
5035}-
5036-
5037/*! \fn uint qHash(const QTime &key, uint seed = 0)-
5038 \relates QHash-
5039 \since 5.0-
5040-
5041 Returns the hash value for the \a key, using \a seed to seed the calculation.-
5042*/-
5043uint qHash(const QTime &key, uint seed) Q_DECL_NOTHROW-
5044{-
5045 return qHash(key.msecsSinceStartOfDay(), seed);
executed 4 times by 1 test: return qHash(key.msecsSinceStartOfDay(), seed);
Executed by:
  • tst_QTime
4
5046}-
5047-
5048QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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