tools/qdatetime.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qplatformdefs.h" -
43#include "private/qdatetime_p.h" -
44 -
45#include "qdatastream.h" -
46#include "qset.h" -
47#include "qlocale.h" -
48#include "qdatetime.h" -
49#include "qregexp.h" -
50#include "qdebug.h" -
51#ifndef Q_OS_WIN -
52#include <locale.h> -
53#endif -
54 -
55#include <cmath> -
56#include <time.h> -
57#ifdef Q_OS_WIN -
58# include <qt_windows.h> -
59# ifdef Q_OS_WINCE -
60# include "qfunctions_wince.h" -
61# endif -
62#endif -
63 -
64//#define QDATETIMEPARSER_DEBUG -
65#if defined (QDATETIMEPARSER_DEBUG) && !defined(QT_NO_DEBUG_STREAM) -
66# define QDTPDEBUG qDebug() << QString("%1:%2").arg(__FILE__).arg(__LINE__) -
67# define QDTPDEBUGN qDebug -
68#else -
69# define QDTPDEBUG if (false) qDebug() -
70# define QDTPDEBUGN if (false) qDebug -
71#endif -
72 -
73#if defined(Q_OS_MAC) -
74#include <private/qcore_mac_p.h> -
75#endif -
76 -
77QT_BEGIN_NAMESPACE -
78 -
79enum { -
80 SECS_PER_DAY = 86400, -
81 MSECS_PER_DAY = 86400000, -
82 SECS_PER_HOUR = 3600, -
83 MSECS_PER_HOUR = 3600000, -
84 SECS_PER_MIN = 60, -
85 MSECS_PER_MIN = 60000, -
86 JULIAN_DAY_FOR_EPOCH = 2440588 // result of julianDayFromDate(1970, 1, 1) -
87}; -
88 -
89static inline QDate fixedDate(int y, int m, int d) -
90{ -
91 QDate result(y, m, 1);
executed (the execution status of this line is deduced): QDate result(y, m, 1);
-
92 result.setDate(y, m, qMin(d, result.daysInMonth()));
executed (the execution status of this line is deduced): result.setDate(y, m, qMin(d, result.daysInMonth()));
-
93 return result;
executed: return result;
Execution Count:202
202
94} -
95 -
96static inline qint64 floordiv(qint64 a, qint64 b) -
97{ -
98 return (a - (a < 0 ? b-1 : 0)) / b;
never executed: return (a - (a < 0 ? b-1 : 0)) / b;
0
99} -
100 -
101static inline qint64 floordiv(qint64 a, int b) -
102{ -
103 return (a - (a < 0 ? b-1 : 0)) / b;
executed: return (a - (a < 0 ? b-1 : 0)) / b;
Execution Count:5915935
5915935
104} -
105 -
106static inline int floordiv(int a, int b) -
107{ -
108 return (a - (a < 0 ? b-1 : 0)) / b;
executed: return (a - (a < 0 ? b-1 : 0)) / b;
Execution Count:12871262
12871262
109} -
110 -
111static inline qint64 julianDayFromDate(int year, int month, int day) -
112{ -
113 // Adjust for no year 0 -
114 if (year < 0)
evaluated: year < 0
TRUEFALSE
yes
Evaluation Count:239346
yes
Evaluation Count:457303
239346-457303
115 ++year;
executed: ++year;
Execution Count:239346
239346
116 -
117/* -
118 * Math from The Calendar FAQ at http://www.tondering.dk/claus/cal/julperiod.php -
119 * This formula is correct for all julian days, when using mathematical integer -
120 * division (round to negative infinity), not c++11 integer division (round to zero) -
121 */ -
122 int a = floordiv(14 - month, 12);
executed (the execution status of this line is deduced): int a = floordiv(14 - month, 12);
-
123 qint64 y = (qint64)year + 4800 - a;
executed (the execution status of this line is deduced): qint64 y = (qint64)year + 4800 - a;
-
124 int m = month + 12 * a - 3;
executed (the execution status of this line is deduced): int m = month + 12 * a - 3;
-
125 return day + floordiv(153 * m + 2, 5) + 365 * y + floordiv(y, 4) - floordiv(y, 100) + floordiv(y, 400) - 32045;
executed: return day + floordiv(153 * m + 2, 5) + 365 * y + floordiv(y, 4) - floordiv(y, 100) + floordiv(y, 400) - 32045;
Execution Count:696649
696649
126} -
127 -
128static void getDateFromJulianDay(qint64 julianDay, int *yearp, int *monthp, int *dayp) -
129{ -
130/* -
131 * Math from The Calendar FAQ at http://www.tondering.dk/claus/cal/julperiod.php -
132 * This formula is correct for all julian days, when using mathematical integer -
133 * division (round to negative infinity), not c++11 integer division (round to zero) -
134 */ -
135 qint64 a = julianDay + 32044;
executed (the execution status of this line is deduced): qint64 a = julianDay + 32044;
-
136 qint64 b = floordiv(4 * a + 3, 146097);
executed (the execution status of this line is deduced): qint64 b = floordiv(4 * a + 3, 146097);
-
137 int c = a - floordiv(146097 * b, 4);
executed (the execution status of this line is deduced): int c = a - floordiv(146097 * b, 4);
-
138 -
139 int d = floordiv(4 * c + 3, 1461);
executed (the execution status of this line is deduced): int d = floordiv(4 * c + 3, 1461);
-
140 int e = c - floordiv(1461 * d, 4);
executed (the execution status of this line is deduced): int e = c - floordiv(1461 * d, 4);
-
141 int m = floordiv(5 * e + 2, 153);
executed (the execution status of this line is deduced): int m = floordiv(5 * e + 2, 153);
-
142 -
143 int day = e - floordiv(153 * m + 2, 5) + 1;
executed (the execution status of this line is deduced): int day = e - floordiv(153 * m + 2, 5) + 1;
-
144 int month = m + 3 - 12 * floordiv(m, 10);
executed (the execution status of this line is deduced): int month = m + 3 - 12 * floordiv(m, 10);
-
145 int year = 100 * b + d - 4800 + floordiv(m, 10);
executed (the execution status of this line is deduced): int year = 100 * b + d - 4800 + floordiv(m, 10);
-
146 -
147 // Adjust for no year 0 -
148 if (year <= 0)
evaluated: year <= 0
TRUEFALSE
yes
Evaluation Count:715387
yes
Evaluation Count:1197608
715387-1197608
149 --year ;
executed: --year ;
Execution Count:715387
715387
150 -
151 if (yearp)
evaluated: yearp
TRUEFALSE
yes
Evaluation Count:642902
yes
Evaluation Count:1270093
642902-1270093
152 *yearp = year;
executed: *yearp = year;
Execution Count:642902
642902
153 if (monthp)
evaluated: monthp
TRUEFALSE
yes
Evaluation Count:624035
yes
Evaluation Count:1288960
624035-1288960
154 *monthp = month;
executed: *monthp = month;
Execution Count:624035
624035
155 if (dayp)
evaluated: dayp
TRUEFALSE
yes
Evaluation Count:659443
yes
Evaluation Count:1253552
659443-1253552
156 *dayp = day;
executed: *dayp = day;
Execution Count:659443
659443
157}
executed: }
Execution Count:1912995
1912995
158 -
159 -
160static const char monthDays[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; -
161 -
162#ifndef QT_NO_TEXTDATE -
163static const char * const qt_shortMonthNames[] = { -
164 "Jan", "Feb", "Mar", "Apr", "May", "Jun", -
165 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -
166#endif -
167#ifndef QT_NO_DATESTRING -
168static QString fmtDateTime(const QString& f, const QTime* dt = 0, const QDate* dd = 0); -
169#endif -
170 -
171/***************************************************************************** -
172 QDate member functions -
173 *****************************************************************************/ -
174 -
175/*! -
176 \since 4.5 -
177 -
178 \enum QDate::MonthNameType -
179 -
180 This enum describes the types of the string representation used -
181 for the month name. -
182 -
183 \value DateFormat This type of name can be used for date-to-string formatting. -
184 \value StandaloneFormat This type is used when you need to enumerate months or weekdays. -
185 Usually standalone names are represented in singular forms with -
186 capitalized first letter. -
187*/ -
188 -
189/*! -
190 \class QDate -
191 \inmodule QtCore -
192 \reentrant -
193 \brief The QDate class provides date functions. -
194 -
195 -
196 A QDate object contains a calendar date, i.e. year, month, and day -
197 numbers, in the Gregorian calendar. It can read the current date -
198 from the system clock. It provides functions for comparing dates, -
199 and for manipulating dates. For example, it is possible to add -
200 and subtract days, months, and years to dates. -
201 -
202 A QDate object is typically created by giving the year, -
203 month, and day numbers explicitly. Note that QDate interprets two -
204 digit years as is, i.e., years 0 - 99. A QDate can also be -
205 constructed with the static function currentDate(), which creates -
206 a QDate object containing the system clock's date. An explicit -
207 date can also be set using setDate(). The fromString() function -
208 returns a QDate given a string and a date format which is used to -
209 interpret the date within the string. -
210 -
211 The year(), month(), and day() functions provide access to the -
212 year, month, and day numbers. Also, dayOfWeek() and dayOfYear() -
213 functions are provided. The same information is provided in -
214 textual format by the toString(), shortDayName(), longDayName(), -
215 shortMonthName(), and longMonthName() functions. -
216 -
217 QDate provides a full set of operators to compare two QDate -
218 objects where smaller means earlier, and larger means later. -
219 -
220 You can increment (or decrement) a date by a given number of days -
221 using addDays(). Similarly you can use addMonths() and addYears(). -
222 The daysTo() function returns the number of days between two -
223 dates. -
224 -
225 The daysInMonth() and daysInYear() functions return how many days -
226 there are in this date's month and year, respectively. The -
227 isLeapYear() function indicates whether a date is in a leap year. -
228 -
229 \section1 -
230 -
231 \section2 No Year 0 -
232 -
233 There is no year 0. Dates in that year are considered invalid. The -
234 year -1 is the year "1 before Christ" or "1 before current era." -
235 The day before 1 January 1 CE is 31 December 1 BCE. -
236 -
237 \section2 Range of Valid Dates -
238 -
239 Dates are stored internally as a Julian Day number, an integer count of -
240 every day in a contiguous range, with 24 November 4714 BCE in the Gregorian -
241 calendar being Julian Day 0 (1 January 4713 BCE in the Julian calendar). -
242 As well as being an efficient and accurate way of storing an absolute date, -
243 it is suitable for converting a Date into other calendar systems such as -
244 Hebrew, Islamic or Chinese. The Julian Day number can be obtained using -
245 QDate::toJulianDay() and can be set using QDate::fromJulianDay(). -
246 -
247 The range of dates able to be stored by QDate as a Julian Day number is -
248 for technical reasons limited to between -784350574879 and 784354017364, -
249 which means from before 2 billion BCE to after 2 billion CE. -
250 -
251 \sa QTime, QDateTime, QDateEdit, QDateTimeEdit, QCalendarWidget -
252*/ -
253 -
254/*! -
255 \fn QDate::QDate() -
256 -
257 Constructs a null date. Null dates are invalid. -
258 -
259 \sa isNull(), isValid() -
260*/ -
261 -
262/*! -
263 Constructs a date with year \a y, month \a m and day \a d. -
264 -
265 If the specified date is invalid, the date is not set and -
266 isValid() returns false. -
267 -
268 \warning Years 1 to 99 are interpreted as is. Year 0 is invalid. -
269 -
270 \sa isValid() -
271*/ -
272 -
273QDate::QDate(int y, int m, int d) -
274{ -
275 setDate(y, m, d);
executed (the execution status of this line is deduced): setDate(y, m, d);
-
276}
executed: }
Execution Count:129452
129452
277 -
278 -
279/*! -
280 \fn bool QDate::isNull() const -
281 -
282 Returns true if the date is null; otherwise returns false. A null -
283 date is invalid. -
284 -
285 \note The behavior of this function is equivalent to isValid(). -
286 -
287 \sa isValid() -
288*/ -
289 -
290 -
291/*! -
292 \fn bool QDate::isValid() const -
293 -
294 Returns true if this date is valid; otherwise returns false. -
295 -
296 \sa isNull() -
297*/ -
298 -
299 -
300/*! -
301 Returns the year of this date. Negative numbers indicate years -
302 before 1 CE, such that year -44 is 44 BCE. -
303 -
304 Returns 0 if the date is invalid. -
305 -
306 \sa month(), day() -
307*/ -
308 -
309int QDate::year() const -
310{ -
311 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:634780
25-634780
312 return 0;
executed: return 0;
Execution Count:25
25
313 -
314 int y;
executed (the execution status of this line is deduced): int y;
-
315 getDateFromJulianDay(jd, &y, 0, 0);
executed (the execution status of this line is deduced): getDateFromJulianDay(jd, &y, 0, 0);
-
316 return y;
executed: return y;
Execution Count:634780
634780
317} -
318 -
319/*! -
320 Returns the number corresponding to the month of this date, using -
321 the following convention: -
322 -
323 \list -
324 \li 1 = "January" -
325 \li 2 = "February" -
326 \li 3 = "March" -
327 \li 4 = "April" -
328 \li 5 = "May" -
329 \li 6 = "June" -
330 \li 7 = "July" -
331 \li 8 = "August" -
332 \li 9 = "September" -
333 \li 10 = "October" -
334 \li 11 = "November" -
335 \li 12 = "December" -
336 \endlist -
337 -
338 Returns 0 if the date is invalid. -
339 -
340 \sa year(), day() -
341*/ -
342 -
343int QDate::month() const -
344{ -
345 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:615917
24-615917
346 return 0;
executed: return 0;
Execution Count:24
24
347 -
348 int m;
executed (the execution status of this line is deduced): int m;
-
349 getDateFromJulianDay(jd, 0, &m, 0);
executed (the execution status of this line is deduced): getDateFromJulianDay(jd, 0, &m, 0);
-
350 return m;
executed: return m;
Execution Count:615917
615917
351} -
352 -
353/*! -
354 Returns the day of the month (1 to 31) of this date. -
355 -
356 Returns 0 if the date is invalid. -
357 -
358 \sa year(), month(), dayOfWeek() -
359*/ -
360 -
361int QDate::day() const -
362{ -
363 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:654174
24-654174
364 return 0;
executed: return 0;
Execution Count:24
24
365 -
366 int d;
executed (the execution status of this line is deduced): int d;
-
367 getDateFromJulianDay(jd, 0, 0, &d);
executed (the execution status of this line is deduced): getDateFromJulianDay(jd, 0, 0, &d);
-
368 return d;
executed: return d;
Execution Count:654174
654174
369} -
370 -
371/*! -
372 Returns the weekday (1 = Monday to 7 = Sunday) for this date. -
373 -
374 Returns 0 if the date is invalid. -
375 -
376 \sa day(), dayOfYear(), Qt::DayOfWeek -
377*/ -
378 -
379int QDate::dayOfWeek() const -
380{ -
381 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:29688
39-29688
382 return 0;
executed: return 0;
Execution Count:39
39
383 -
384 if (jd >= 0)
evaluated: jd >= 0
TRUEFALSE
yes
Evaluation Count:29680
yes
Evaluation Count:8
8-29680
385 return (jd % 7) + 1;
executed: return (jd % 7) + 1;
Execution Count:29680
29680
386 else -
387 return ((jd + 1) % 7) + 7;
executed: return ((jd + 1) % 7) + 7;
Execution Count:8
8
388} -
389 -
390/*! -
391 Returns the day of the year (1 to 365 or 366 on leap years) for -
392 this date. -
393 -
394 Returns 0 if the date is invalid. -
395 -
396 \sa day(), dayOfWeek() -
397*/ -
398 -
399int QDate::dayOfYear() const -
400{ -
401 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:316
1-316
402 return 0;
executed: return 0;
Execution Count:1
1
403 -
404 return jd - julianDayFromDate(year(), 1, 1) + 1;
executed: return jd - julianDayFromDate(year(), 1, 1) + 1;
Execution Count:316
316
405} -
406 -
407/*! -
408 Returns the number of days in the month (28 to 31) for this date. -
409 -
410 Returns 0 if the date is invalid. -
411 -
412 \sa day(), daysInYear() -
413*/ -
414 -
415int QDate::daysInMonth() const -
416{ -
417 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:2849
41-2849
418 return 0;
executed: return 0;
Execution Count:41
41
419 -
420 int y, m;
executed (the execution status of this line is deduced): int y, m;
-
421 getDateFromJulianDay(jd, &y, &m, 0);
executed (the execution status of this line is deduced): getDateFromJulianDay(jd, &y, &m, 0);
-
422 if (m == 2 && isLeapYear(y))
evaluated: m == 2
TRUEFALSE
yes
Evaluation Count:107
yes
Evaluation Count:2742
evaluated: isLeapYear(y)
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:47
47-2742
423 return 29;
executed: return 29;
Execution Count:60
60
424 else -
425 return monthDays[m];
executed: return monthDays[m];
Execution Count:2789
2789
426} -
427 -
428/*! -
429 Returns the number of days in the year (365 or 366) for this date. -
430 -
431 Returns 0 if the date is invalid. -
432 -
433 \sa day(), daysInMonth() -
434*/ -
435 -
436int QDate::daysInYear() const -
437{ -
438 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
439 return 0;
executed: return 0;
Execution Count:1
1
440 -
441 int y;
executed (the execution status of this line is deduced): int y;
-
442 getDateFromJulianDay(jd, &y, 0, 0);
executed (the execution status of this line is deduced): getDateFromJulianDay(jd, &y, 0, 0);
-
443 return isLeapYear(y) ? 366 : 365;
executed: return isLeapYear(y) ? 366 : 365;
Execution Count:4
4
444} -
445 -
446/*! -
447 Returns the week number (1 to 53), and stores the year in -
448 *\a{yearNumber} unless \a yearNumber is null (the default). -
449 -
450 Returns 0 if the date is invalid. -
451 -
452 In accordance with ISO 8601, weeks start on Monday and the first -
453 Thursday of a year is always in week 1 of that year. Most years -
454 have 52 weeks, but some have 53. -
455 -
456 *\a{yearNumber} is not always the same as year(). For example, 1 -
457 January 2000 has week number 52 in the year 1999, and 31 December -
458 2002 has week number 1 in the year 2003. -
459 -
460 \legalese -
461 Copyright (c) 1989 The Regents of the University of California. -
462 All rights reserved. -
463 -
464 Redistribution and use in source and binary forms are permitted -
465 provided that the above copyright notice and this paragraph are -
466 duplicated in all such forms and that any documentation, -
467 advertising materials, and other materials related to such -
468 distribution and use acknowledge that the software was developed -
469 by the University of California, Berkeley. The name of the -
470 University may not be used to endorse or promote products derived -
471 from this software without specific prior written permission. -
472 THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR -
473 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -
474 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -
475 -
476 \sa isValid() -
477*/ -
478 -
479int QDate::weekNumber(int *yearNumber) const -
480{ -
481 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:303
3-303
482 return 0;
executed: return 0;
Execution Count:3
3
483 -
484 int year = QDate::year();
executed (the execution status of this line is deduced): int year = QDate::year();
-
485 int yday = dayOfYear() - 1;
executed (the execution status of this line is deduced): int yday = dayOfYear() - 1;
-
486 int wday = dayOfWeek();
executed (the execution status of this line is deduced): int wday = dayOfWeek();
-
487 if (wday == 7)
evaluated: wday == 7
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:302
1-302
488 wday = 0;
executed: wday = 0;
Execution Count:1
1
489 int w;
executed (the execution status of this line is deduced): int w;
-
490 -
491 for (;;) {
executed (the execution status of this line is deduced): for (;;) {
-
492 int len;
executed (the execution status of this line is deduced): int len;
-
493 int bot;
executed (the execution status of this line is deduced): int bot;
-
494 int top;
executed (the execution status of this line is deduced): int top;
-
495 -
496 len = isLeapYear(year) ? 366 : 365;
evaluated: isLeapYear(year)
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:267
38-267
497 /* -
498 ** What yday (-3 ... 3) does -
499 ** the ISO year begin on? -
500 */ -
501 bot = ((yday + 11 - wday) % 7) - 3;
executed (the execution status of this line is deduced): bot = ((yday + 11 - wday) % 7) - 3;
-
502 /* -
503 ** What yday does the NEXT -
504 ** ISO year begin on? -
505 */ -
506 top = bot - (len % 7);
executed (the execution status of this line is deduced): top = bot - (len % 7);
-
507 if (top < -3)
evaluated: top < -3
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:303
2-303
508 top += 7;
executed: top += 7;
Execution Count:2
2
509 top += len;
executed (the execution status of this line is deduced): top += len;
-
510 if (yday >= top) {
evaluated: yday >= top
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:303
2-303
511 ++year;
executed (the execution status of this line is deduced): ++year;
-
512 w = 1;
executed (the execution status of this line is deduced): w = 1;
-
513 break;
executed: break;
Execution Count:2
2
514 } -
515 if (yday >= bot) {
evaluated: yday >= bot
TRUEFALSE
yes
Evaluation Count:301
yes
Evaluation Count:2
2-301
516 w = 1 + ((yday - bot) / 7);
executed (the execution status of this line is deduced): w = 1 + ((yday - bot) / 7);
-
517 break;
executed: break;
Execution Count:301
301
518 } -
519 --year;
executed (the execution status of this line is deduced): --year;
-
520 yday += isLeapYear(year) ? 366 : 365;
evaluated: isLeapYear(year)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
521 }
executed: }
Execution Count:2
2
522 if (yearNumber != 0)
evaluated: yearNumber != 0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:294
9-294
523 *yearNumber = year;
executed: *yearNumber = year;
Execution Count:9
9
524 return w;
executed: return w;
Execution Count:303
303
525} -
526 -
527#ifndef QT_NO_TEXTDATE -
528/*! -
529 \since 4.5 -
530 -
531 Returns the short name of the \a month for the representation specified -
532 by \a type. -
533 -
534 The months are enumerated using the following convention: -
535 -
536 \list -
537 \li 1 = "Jan" -
538 \li 2 = "Feb" -
539 \li 3 = "Mar" -
540 \li 4 = "Apr" -
541 \li 5 = "May" -
542 \li 6 = "Jun" -
543 \li 7 = "Jul" -
544 \li 8 = "Aug" -
545 \li 9 = "Sep" -
546 \li 10 = "Oct" -
547 \li 11 = "Nov" -
548 \li 12 = "Dec" -
549 \endlist -
550 -
551 The month names will be localized according to the system's locale -
552 settings. -
553 -
554 Returns an empty string if the date is invalid. -
555 -
556 \sa toString(), longMonthName(), shortDayName(), longDayName() -
557*/ -
558 -
559QString QDate::shortMonthName(int month, QDate::MonthNameType type) -
560{ -
561 if (month < 1 || month > 12)
evaluated: month < 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:282
evaluated: month > 12
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:280
2-282
562 return QString();
executed: return QString();
Execution Count:4
4
563 -
564 switch (type) { -
565 case QDate::DateFormat: -
566 return QLocale::system().monthName(month, QLocale::ShortFormat);
executed: return QLocale::system().monthName(month, QLocale::ShortFormat);
Execution Count:268
268
567 case QDate::StandaloneFormat: -
568 return QLocale::system().standaloneMonthName(month, QLocale::ShortFormat);
executed: return QLocale::system().standaloneMonthName(month, QLocale::ShortFormat);
Execution Count:12
12
569 default: -
570 break;
never executed: break;
0
571 } -
572 return QString();
never executed: return QString();
0
573} -
574 -
575/*! -
576 \since 4.5 -
577 -
578 Returns the long name of the \a month for the representation specified -
579 by \a type. -
580 -
581 The months are enumerated using the following convention: -
582 -
583 \list -
584 \li 1 = "January" -
585 \li 2 = "February" -
586 \li 3 = "March" -
587 \li 4 = "April" -
588 \li 5 = "May" -
589 \li 6 = "June" -
590 \li 7 = "July" -
591 \li 8 = "August" -
592 \li 9 = "September" -
593 \li 10 = "October" -
594 \li 11 = "November" -
595 \li 12 = "December" -
596 \endlist -
597 -
598 The month names will be localized according to the system's locale -
599 settings. -
600 -
601 Returns an empty string if the date is invalid. -
602 -
603 \sa toString(), shortMonthName(), shortDayName(), longDayName() -
604*/ -
605 -
606QString QDate::longMonthName(int month, MonthNameType type) -
607{ -
608 if (month < 1 || month > 12)
evaluated: month < 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:39
evaluated: month > 12
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:37
2-39
609 return QString();
executed: return QString();
Execution Count:4
4
610 -
611 switch (type) { -
612 case QDate::DateFormat: -
613 return QLocale::system().monthName(month, QLocale::LongFormat);
executed: return QLocale::system().monthName(month, QLocale::LongFormat);
Execution Count:25
25
614 case QDate::StandaloneFormat: -
615 return QLocale::system().standaloneMonthName(month, QLocale::LongFormat);
executed: return QLocale::system().standaloneMonthName(month, QLocale::LongFormat);
Execution Count:12
12
616 default: -
617 break;
never executed: break;
0
618 } -
619 return QString();
never executed: return QString();
0
620} -
621 -
622/*! -
623 \since 4.5 -
624 -
625 Returns the short name of the \a weekday for the representation specified -
626 by \a type. -
627 -
628 The days are enumerated using the following convention: -
629 -
630 \list -
631 \li 1 = "Mon" -
632 \li 2 = "Tue" -
633 \li 3 = "Wed" -
634 \li 4 = "Thu" -
635 \li 5 = "Fri" -
636 \li 6 = "Sat" -
637 \li 7 = "Sun" -
638 \endlist -
639 -
640 The day names will be localized according to the system's locale -
641 settings. -
642 -
643 Returns an empty string if the date is invalid. -
644 -
645 \sa toString(), shortMonthName(), longMonthName(), longDayName() -
646*/ -
647 -
648QString QDate::shortDayName(int weekday, MonthNameType type) -
649{ -
650 if (weekday < 1 || weekday > 7)
evaluated: weekday < 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:80
evaluated: weekday > 7
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:78
2-80
651 return QString();
executed: return QString();
Execution Count:4
4
652 -
653 switch (type) { -
654 case QDate::DateFormat: -
655 return QLocale::system().dayName(weekday, QLocale::ShortFormat);
executed: return QLocale::system().dayName(weekday, QLocale::ShortFormat);
Execution Count:71
71
656 case QDate::StandaloneFormat: -
657 return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat);
executed: return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat);
Execution Count:7
7
658 default: -
659 break;
never executed: break;
0
660 } -
661 return QString();
never executed: return QString();
0
662} -
663 -
664/*! -
665 \since 4.5 -
666 -
667 Returns the long name of the \a weekday for the representation specified -
668 by \a type. -
669 -
670 The days are enumerated using the following convention: -
671 -
672 \list -
673 \li 1 = "Monday" -
674 \li 2 = "Tuesday" -
675 \li 3 = "Wednesday" -
676 \li 4 = "Thursday" -
677 \li 5 = "Friday" -
678 \li 6 = "Saturday" -
679 \li 7 = "Sunday" -
680 \endlist -
681 -
682 The day names will be localized according to the system's locale -
683 settings. -
684 -
685 Returns an empty string if the date is invalid. -
686 -
687 \sa toString(), shortDayName(), shortMonthName(), longMonthName() -
688*/ -
689 -
690QString QDate::longDayName(int weekday, MonthNameType type) -
691{ -
692 if (weekday < 1 || weekday > 7)
evaluated: weekday < 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:24
evaluated: weekday > 7
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:22
2-24
693 return QString();
executed: return QString();
Execution Count:4
4
694 -
695 switch (type) { -
696 case QDate::DateFormat: -
697 return QLocale::system().dayName(weekday, QLocale::LongFormat);
executed: return QLocale::system().dayName(weekday, QLocale::LongFormat);
Execution Count:15
15
698 case QDate::StandaloneFormat: -
699 return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat);
executed: return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat);
Execution Count:7
7
700 default: -
701 break;
never executed: break;
0
702 } -
703 return QLocale::system().dayName(weekday, QLocale::LongFormat);
never executed: return QLocale::system().dayName(weekday, QLocale::LongFormat);
0
704} -
705#endif //QT_NO_TEXTDATE -
706 -
707#ifndef QT_NO_DATESTRING -
708 -
709/*! -
710 \fn QString QDate::toString(Qt::DateFormat format) const -
711 -
712 \overload -
713 -
714 Returns the date as a string. The \a format parameter determines -
715 the format of the string. -
716 -
717 If the \a format is Qt::TextDate, the string is formatted in -
718 the default way. QDate::shortDayName() and QDate::shortMonthName() -
719 are used to generate the string, so the day and month names will -
720 be localized names. An example of this formatting is -
721 "Sat May 20 1995". -
722 -
723 If the \a format is Qt::ISODate, the string format corresponds -
724 to the ISO 8601 extended specification for representations of -
725 dates and times, taking the form YYYY-MM-DD, where YYYY is the -
726 year, MM is the month of the year (between 01 and 12), and DD is -
727 the day of the month between 01 and 31. -
728 -
729 If the \a format is Qt::SystemLocaleShortDate or -
730 Qt::SystemLocaleLongDate, the string format depends on the locale -
731 settings of the system. Identical to calling -
732 QLocale::system().toString(date, QLocale::ShortFormat) or -
733 QLocale::system().toString(date, QLocale::LongFormat). -
734 -
735 If the \a format is Qt::DefaultLocaleShortDate or -
736 Qt::DefaultLocaleLongDate, the string format depends on the -
737 default application locale. This is the locale set with -
738 QLocale::setDefault(), or the system locale if no default locale -
739 has been set. Identical to calling QLocale().toString(date, -
740 QLocale::ShortFormat) or QLocale().toString(date, -
741 QLocale::LongFormat). -
742 -
743 If the date is invalid, an empty string will be returned. -
744 -
745 \warning The Qt::ISODate format is only valid for years in the -
746 range 0 to 9999. This restriction may apply to locale-aware -
747 formats as well, depending on the locale settings. -
748 -
749 \sa shortDayName(), shortMonthName() -
750*/ -
751QString QDate::toString(Qt::DateFormat f) const -
752{ -
753 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1712
1-1712
754 return QString();
executed: return QString();
Execution Count:1
1
755 int y, m, d;
executed (the execution status of this line is deduced): int y, m, d;
-
756 getDateFromJulianDay(jd, &y, &m, &d);
executed (the execution status of this line is deduced): getDateFromJulianDay(jd, &y, &m, &d);
-
757 switch (f) { -
758 case Qt::SystemLocaleDate: -
759 case Qt::SystemLocaleShortDate: -
760 case Qt::SystemLocaleLongDate: -
761 return QLocale::system().toString(*this, f == Qt::SystemLocaleLongDate ? QLocale::LongFormat
executed: return QLocale::system().toString(*this, f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:1657
1657
762 : QLocale::ShortFormat);
executed: return QLocale::system().toString(*this, f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:1657
1657
763 case Qt::LocaleDate: -
764 case Qt::DefaultLocaleShortDate: -
765 case Qt::DefaultLocaleLongDate: -
766 return QLocale().toString(*this, f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat
executed: return QLocale().toString(*this, f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:15
15
767 : QLocale::ShortFormat);
executed: return QLocale().toString(*this, f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:15
15
768 default: -
769#ifndef QT_NO_TEXTDATE -
770 case Qt::TextDate: -
771 { -
772 return QString::fromLatin1("%0 %1 %2 %3")
executed: return QString::fromLatin1("%0 %1 %2 %3") .arg(shortDayName(dayOfWeek())) .arg(shortMonthName(m)) .arg(d) .arg(y);
Execution Count:2
2
773 .arg(shortDayName(dayOfWeek()))
executed: return QString::fromLatin1("%0 %1 %2 %3") .arg(shortDayName(dayOfWeek())) .arg(shortMonthName(m)) .arg(d) .arg(y);
Execution Count:2
2
774 .arg(shortMonthName(m))
executed: return QString::fromLatin1("%0 %1 %2 %3") .arg(shortDayName(dayOfWeek())) .arg(shortMonthName(m)) .arg(d) .arg(y);
Execution Count:2
2
775 .arg(d)
executed: return QString::fromLatin1("%0 %1 %2 %3") .arg(shortDayName(dayOfWeek())) .arg(shortMonthName(m)) .arg(d) .arg(y);
Execution Count:2
2
776 .arg(y);
executed: return QString::fromLatin1("%0 %1 %2 %3") .arg(shortDayName(dayOfWeek())) .arg(shortMonthName(m)) .arg(d) .arg(y);
Execution Count:2
2
777 } -
778#endif -
779 case Qt::ISODate: -
780 { -
781 if (year() < 0 || year() > 9999)
evaluated: year() < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:35
partially evaluated: year() > 9999
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
0-35
782 return QString();
executed: return QString();
Execution Count:3
3
783 QString year(QString::number(y).rightJustified(4, QLatin1Char('0')));
executed (the execution status of this line is deduced): QString year(QString::number(y).rightJustified(4, QLatin1Char('0')));
-
784 QString month(QString::number(m).rightJustified(2, QLatin1Char('0')));
executed (the execution status of this line is deduced): QString month(QString::number(m).rightJustified(2, QLatin1Char('0')));
-
785 QString day(QString::number(d).rightJustified(2, QLatin1Char('0')));
executed (the execution status of this line is deduced): QString day(QString::number(d).rightJustified(2, QLatin1Char('0')));
-
786 return year + QLatin1Char('-') + month + QLatin1Char('-') + day;
executed: return year + QLatin1Char('-') + month + QLatin1Char('-') + day;
Execution Count:35
35
787 } -
788 } -
789}
never executed: }
0
790 -
791/*! -
792 Returns the date as a string. The \a format parameter determines -
793 the format of the result string. -
794 -
795 These expressions may be used: -
796 -
797 \table -
798 \header \li Expression \li Output -
799 \row \li d \li the day as number without a leading zero (1 to 31) -
800 \row \li dd \li the day as number with a leading zero (01 to 31) -
801 \row \li ddd -
802 \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). -
803 Uses QDate::shortDayName(). -
804 \row \li dddd -
805 \li the long localized day name (e.g. 'Monday' to 'Sunday'). -
806 Uses QDate::longDayName(). -
807 \row \li M \li the month as number without a leading zero (1 to 12) -
808 \row \li MM \li the month as number with a leading zero (01 to 12) -
809 \row \li MMM -
810 \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). -
811 Uses QDate::shortMonthName(). -
812 \row \li MMMM -
813 \li the long localized month name (e.g. 'January' to 'December'). -
814 Uses QDate::longMonthName(). -
815 \row \li yy \li the year as two digit number (00 to 99) -
816 \row \li yyyy \li the year as four digit number. If the year is negative, -
817 a minus sign is prepended in addition. -
818 \endtable -
819 -
820 All other input characters will be ignored. Any sequence of characters that -
821 are enclosed in single quotes will be treated as text and not be used as an -
822 expression. Two consecutive single quotes ("''") are replaced by a singlequote -
823 in the output. Formats without separators (e.g. "ddMM") are currently not supported. -
824 -
825 Example format strings (assuming that the QDate is the 20 July -
826 1969): -
827 -
828 \table -
829 \header \li Format \li Result -
830 \row \li dd.MM.yyyy \li 20.07.1969 -
831 \row \li ddd MMMM d yy \li Sun July 20 69 -
832 \row \li 'The day is' dddd \li The day is Sunday -
833 \endtable -
834 -
835 If the datetime is invalid, an empty string will be returned. -
836 -
837 \warning The Qt::ISODate format is only valid for years in the -
838 range 0 to 9999. This restriction may apply to locale-aware -
839 formats as well, depending on the locale settings. -
840 -
841 \sa QDateTime::toString(), QTime::toString() -
842 -
843*/ -
844QString QDate::toString(const QString& format) const -
845{ -
846 if (year() > 9999)
evaluated: year() > 9999
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:13134
2-13134
847 return QString();
executed: return QString();
Execution Count:2
2
848 return fmtDateTime(format, 0, this);
executed: return fmtDateTime(format, 0, this);
Execution Count:13134
13134
849} -
850#endif //QT_NO_DATESTRING -
851 -
852/*! -
853 \fn bool QDate::setYMD(int y, int m, int d) -
854 -
855 \deprecated in 5.0, use setDate() instead. -
856 -
857 Sets the date's year \a y, month \a m, and day \a d. -
858 -
859 If \a y is in the range 0 to 99, it is interpreted as 1900 to -
860 1999. -
861 Returns \c false if the date is invalid. -
862 -
863 Use setDate() instead. -
864*/ -
865 -
866/*! -
867 \since 4.2 -
868 -
869 Sets the date's \a year, \a month, and \a day. Returns true if -
870 the date is valid; otherwise returns false. -
871 -
872 If the specified date is invalid, the QDate object is set to be -
873 invalid. -
874 -
875 \sa isValid() -
876*/ -
877bool QDate::setDate(int year, int month, int day) -
878{ -
879 if (isValid(year, month, day))
evaluated: isValid(year, month, day)
TRUEFALSE
yes
Evaluation Count:686490
yes
Evaluation Count:11328
11328-686490
880 jd = julianDayFromDate(year, month, day);
executed: jd = julianDayFromDate(year, month, day);
Execution Count:686490
686490
881 else -
882 jd = nullJd();
executed: jd = nullJd();
Execution Count:11328
11328
883 -
884 return isValid();
executed: return isValid();
Execution Count:697818
697818
885} -
886 -
887/*! -
888 \since 4.5 -
889 -
890 Extracts the date's year, month, and day, and assigns them to -
891 *\a year, *\a month, and *\a day. The pointers may be null. -
892 -
893 Returns 0 if the date is invalid. -
894 -
895 \sa year(), month(), day(), isValid() -
896*/ -
897void QDate::getDate(int *year, int *month, int *day) -
898{ -
899 if (isValid()) {
evaluated: isValid()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3
3-4
900 getDateFromJulianDay(jd, year, month, day);
executed (the execution status of this line is deduced): getDateFromJulianDay(jd, year, month, day);
-
901 } else {
executed: }
Execution Count:4
4
902 if (year)
evaluated: year
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
903 *year = 0;
executed: *year = 0;
Execution Count:2
2
904 if (month)
evaluated: month
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
905 *month = 0;
executed: *month = 0;
Execution Count:2
2
906 if (day)
evaluated: day
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
907 *day = 0;
executed: *day = 0;
Execution Count:2
2
908 }
executed: }
Execution Count:3
3
909} -
910 -
911/*! -
912 Returns a QDate object containing a date \a ndays later than the -
913 date of this object (or earlier if \a ndays is negative). -
914 -
915 Returns a null date if the current date is invalid or the new date is -
916 out of range. -
917 -
918 \sa addMonths(), addYears(), daysTo() -
919*/ -
920 -
921QDate QDate::addDays(qint64 ndays) const -
922{ -
923 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:618514
1-618514
924 return QDate();
executed: return QDate();
Execution Count:1
1
925 -
926 // Due to limits on minJd() and maxJd() we know that any overflow -
927 // will be invalid and caught by fromJulianDay(). -
928 return fromJulianDay(jd + ndays);
executed: return fromJulianDay(jd + ndays);
Execution Count:618514
618514
929} -
930 -
931/*! -
932 Returns a QDate object containing a date \a nmonths later than the -
933 date of this object (or earlier if \a nmonths is negative). -
934 -
935 \note If the ending day/month combination does not exist in the -
936 resulting month/year, this function will return a date that is the -
937 latest valid date. -
938 -
939 \sa addDays(), addYears() -
940*/ -
941 -
942QDate QDate::addMonths(int nmonths) const -
943{ -
944 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:123
1-123
945 return QDate();
executed: return QDate();
Execution Count:1
1
946 if (!nmonths)
evaluated: !nmonths
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:120
3-120
947 return *this;
executed: return *this;
Execution Count:3
3
948 -
949 int old_y, y, m, d;
executed (the execution status of this line is deduced): int old_y, y, m, d;
-
950 getDateFromJulianDay(jd, &y, &m, &d);
executed (the execution status of this line is deduced): getDateFromJulianDay(jd, &y, &m, &d);
-
951 old_y = y;
executed (the execution status of this line is deduced): old_y = y;
-
952 -
953 bool increasing = nmonths > 0;
executed (the execution status of this line is deduced): bool increasing = nmonths > 0;
-
954 -
955 while (nmonths != 0) {
evaluated: nmonths != 0
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:120
120-134
956 if (nmonths < 0 && nmonths + 12 <= 0) {
evaluated: nmonths < 0
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:61
evaluated: nmonths + 12 <= 0
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:62
11-73
957 y--;
executed (the execution status of this line is deduced): y--;
-
958 nmonths+=12;
executed (the execution status of this line is deduced): nmonths+=12;
-
959 } else if (nmonths < 0) {
executed: }
Execution Count:11
evaluated: nmonths < 0
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:61
11-62
960 m+= nmonths;
executed (the execution status of this line is deduced): m+= nmonths;
-
961 nmonths = 0;
executed (the execution status of this line is deduced): nmonths = 0;
-
962 if (m <= 0) {
evaluated: m <= 0
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:27
27-35
963 --y;
executed (the execution status of this line is deduced): --y;
-
964 m += 12;
executed (the execution status of this line is deduced): m += 12;
-
965 }
executed: }
Execution Count:35
35
966 } else if (nmonths - 12 >= 0) {
executed: }
Execution Count:62
evaluated: nmonths - 12 >= 0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:49
12-62
967 y++;
executed (the execution status of this line is deduced): y++;
-
968 nmonths -= 12;
executed (the execution status of this line is deduced): nmonths -= 12;
-
969 } else if (m == 12) {
executed: }
Execution Count:12
evaluated: m == 12
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:47
2-47
970 y++;
executed (the execution status of this line is deduced): y++;
-
971 m = 0;
executed (the execution status of this line is deduced): m = 0;
-
972 } else {
executed: }
Execution Count:2
2
973 m += nmonths;
executed (the execution status of this line is deduced): m += nmonths;
-
974 nmonths = 0;
executed (the execution status of this line is deduced): nmonths = 0;
-
975 if (m > 12) {
evaluated: m > 12
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:46
1-46
976 ++y;
executed (the execution status of this line is deduced): ++y;
-
977 m -= 12;
executed (the execution status of this line is deduced): m -= 12;
-
978 }
executed: }
Execution Count:1
1
979 }
executed: }
Execution Count:47
47
980 } -
981 -
982 // was there a sign change? -
983 if ((old_y > 0 && y <= 0) ||
evaluated: old_y > 0
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:3
evaluated: y <= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:115
2-117
984 (old_y < 0 && y >= 0))
evaluated: old_y < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:115
evaluated: y >= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-115
985 // yes, adjust the date by +1 or -1 years -
986 y += increasing ? +1 : -1;
executed: y += increasing ? +1 : -1;
Execution Count:4
evaluated: increasing
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2-4
987 -
988 return fixedDate(y, m, d);
executed: return fixedDate(y, m, d);
Execution Count:120
120
989} -
990 -
991/*! -
992 Returns a QDate object containing a date \a nyears later than the -
993 date of this object (or earlier if \a nyears is negative). -
994 -
995 \note If the ending day/month combination does not exist in the -
996 resulting year (i.e., if the date was Feb 29 and the final year is -
997 not a leap year), this function will return a date that is the -
998 latest valid date (that is, Feb 28). -
999 -
1000 \sa addDays(), addMonths() -
1001*/ -
1002 -
1003QDate QDate::addYears(int nyears) const -
1004{ -
1005 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:82
1-82
1006 return QDate();
executed: return QDate();
Execution Count:1
1
1007 -
1008 int y, m, d;
executed (the execution status of this line is deduced): int y, m, d;
-
1009 getDateFromJulianDay(jd, &y, &m, &d);
executed (the execution status of this line is deduced): getDateFromJulianDay(jd, &y, &m, &d);
-
1010 -
1011 int old_y = y;
executed (the execution status of this line is deduced): int old_y = y;
-
1012 y += nyears;
executed (the execution status of this line is deduced): y += nyears;
-
1013 -
1014 // was there a sign change? -
1015 if ((old_y > 0 && y <= 0) ||
evaluated: old_y > 0
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:15
evaluated: y <= 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:61
6-67
1016 (old_y < 0 && y >= 0))
evaluated: old_y < 0
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:61
evaluated: y >= 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:9
6-61
1017 // yes, adjust the date by +1 or -1 years -
1018 y += nyears > 0 ? +1 : -1;
executed: y += nyears > 0 ? +1 : -1;
Execution Count:12
evaluated: nyears > 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6-12
1019 -
1020 return fixedDate(y, m, d);
executed: return fixedDate(y, m, d);
Execution Count:82
82
1021} -
1022 -
1023/*! -
1024 Returns the number of days from this date to \a d (which is -
1025 negative if \a d is earlier than this date). -
1026 -
1027 Returns 0 if either date is invalid. -
1028 -
1029 Example: -
1030 \snippet code/src_corelib_tools_qdatetime.cpp 0 -
1031 -
1032 \sa addDays() -
1033*/ -
1034 -
1035qint64 QDate::daysTo(const QDate &d) const -
1036{ -
1037 if (isNull() || d.isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:30395
evaluated: d.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:30394
1-30395
1038 return 0;
executed: return 0;
Execution Count:2
2
1039 -
1040 // Due to limits on minJd() and maxJd() we know this will never overflow -
1041 return d.jd - jd;
executed: return d.jd - jd;
Execution Count:30394
30394
1042} -
1043 -
1044 -
1045/*! -
1046 \fn bool QDate::operator==(const QDate &d) const -
1047 -
1048 Returns true if this date is equal to \a d; otherwise returns -
1049 false. -
1050 -
1051*/ -
1052 -
1053/*! -
1054 \fn bool QDate::operator!=(const QDate &d) const -
1055 -
1056 Returns true if this date is different from \a d; otherwise -
1057 returns false. -
1058*/ -
1059 -
1060/*! -
1061 \fn bool QDate::operator<(const QDate &d) const -
1062 -
1063 Returns true if this date is earlier than \a d; otherwise returns -
1064 false. -
1065*/ -
1066 -
1067/*! -
1068 \fn bool QDate::operator<=(const QDate &d) const -
1069 -
1070 Returns true if this date is earlier than or equal to \a d; -
1071 otherwise returns false. -
1072*/ -
1073 -
1074/*! -
1075 \fn bool QDate::operator>(const QDate &d) const -
1076 -
1077 Returns true if this date is later than \a d; otherwise returns -
1078 false. -
1079*/ -
1080 -
1081/*! -
1082 \fn bool QDate::operator>=(const QDate &d) const -
1083 -
1084 Returns true if this date is later than or equal to \a d; -
1085 otherwise returns false. -
1086*/ -
1087 -
1088/*! -
1089 \fn QDate::currentDate() -
1090 Returns the current date, as reported by the system clock. -
1091 -
1092 \sa QTime::currentTime(), QDateTime::currentDateTime() -
1093*/ -
1094 -
1095#ifndef QT_NO_DATESTRING -
1096/*! -
1097 \fn QDate QDate::fromString(const QString &string, Qt::DateFormat format) -
1098 -
1099 Returns the QDate represented by the \a string, using the -
1100 \a format given, or an invalid date if the string cannot be -
1101 parsed. -
1102 -
1103 Note for Qt::TextDate: It is recommended that you use the -
1104 English short month names (e.g. "Jan"). Although localized month -
1105 names can also be used, they depend on the user's locale settings. -
1106*/ -
1107QDate QDate::fromString(const QString& s, Qt::DateFormat f) -
1108{ -
1109 if (s.isEmpty())
evaluated: s.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:76
1-76
1110 return QDate();
executed: return QDate();
Execution Count:1
1
1111 -
1112 switch (f) { -
1113 case Qt::ISODate: -
1114 { -
1115 int year(s.mid(0, 4).toInt());
executed (the execution status of this line is deduced): int year(s.mid(0, 4).toInt());
-
1116 int month(s.mid(5, 2).toInt());
executed (the execution status of this line is deduced): int month(s.mid(5, 2).toInt());
-
1117 int day(s.mid(8, 2).toInt());
executed (the execution status of this line is deduced): int day(s.mid(8, 2).toInt());
-
1118 if (year && month && day)
evaluated: year
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:12
partially evaluated: month
TRUEFALSE
yes
Evaluation Count:50
no
Evaluation Count:0
partially evaluated: day
TRUEFALSE
yes
Evaluation Count:50
no
Evaluation Count:0
0-50
1119 return QDate(year, month, day);
executed: return QDate(year, month, day);
Execution Count:50
50
1120 } -
1121 break;
executed: break;
Execution Count:12
12
1122 case Qt::SystemLocaleDate: -
1123 case Qt::SystemLocaleShortDate: -
1124 case Qt::SystemLocaleLongDate: -
1125 return fromString(s, QLocale::system().dateFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat
never executed: return fromString(s, QLocale::system().dateFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
0
1126 : QLocale::ShortFormat));
never executed: return fromString(s, QLocale::system().dateFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
0
1127 case Qt::LocaleDate: -
1128 case Qt::DefaultLocaleShortDate: -
1129 case Qt::DefaultLocaleLongDate: -
1130 return fromString(s, QLocale().dateFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat
never executed: return fromString(s, QLocale().dateFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
0
1131 : QLocale::ShortFormat));
never executed: return fromString(s, QLocale().dateFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
0
1132 default: -
1133#ifndef QT_NO_TEXTDATE -
1134 case Qt::TextDate: { -
1135 QStringList parts = s.split(QLatin1Char(' '), QString::SkipEmptyParts);
executed (the execution status of this line is deduced): QStringList parts = s.split(QLatin1Char(' '), QString::SkipEmptyParts);
-
1136 -
1137 if (parts.count() != 4) {
evaluated: parts.count() != 4
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
1138 return QDate();
executed: return QDate();
Execution Count:1
1
1139 } -
1140 -
1141 QString monthName = parts.at(1);
executed (the execution status of this line is deduced): QString monthName = parts.at(1);
-
1142 int month = -1;
executed (the execution status of this line is deduced): int month = -1;
-
1143 // Assume that English monthnames are the default -
1144 for (int i = 0; i < 12; ++i) {
evaluated: i < 12
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:1
1-72
1145 if (monthName == QLatin1String(qt_shortMonthNames[i])) {
evaluated: monthName == QLatin1String(qt_shortMonthNames[i])
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:60
12-60
1146 month = i + 1;
executed (the execution status of this line is deduced): month = i + 1;
-
1147 break;
executed: break;
Execution Count:12
12
1148 } -
1149 }
executed: }
Execution Count:60
60
1150 // If English names can't be found, search the localized ones -
1151 if (month == -1) {
evaluated: month == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12
1-12
1152 for (int i = 1; i <= 12; ++i) {
evaluated: i <= 12
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
1153 if (monthName == QDate::shortMonthName(i)) {
partially evaluated: monthName == QDate::shortMonthName(i)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1154 month = i;
never executed (the execution status of this line is deduced): month = i;
-
1155 break;
never executed: break;
0
1156 } -
1157 }
executed: }
Execution Count:12
12
1158 if (month == -1) {
partially evaluated: month == -1
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1159 // Month name matches neither English nor other localised name. -
1160 return QDate();
executed: return QDate();
Execution Count:1
1
1161 } -
1162 }
never executed: }
0
1163 -
1164 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
1165 int day = parts.at(2).toInt(&ok);
executed (the execution status of this line is deduced): int day = parts.at(2).toInt(&ok);
-
1166 if (!ok) {
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:11
1-11
1167 return QDate();
executed: return QDate();
Execution Count:1
1
1168 } -
1169 -
1170 int year = parts.at(3).toInt(&ok);
executed (the execution status of this line is deduced): int year = parts.at(3).toInt(&ok);
-
1171 if (!ok) {
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-10
1172 return QDate();
executed: return QDate();
Execution Count:1
1
1173 } -
1174 -
1175 return QDate(year, month, day);
executed: return QDate(year, month, day);
Execution Count:10
10
1176 } -
1177#else -
1178 break; -
1179#endif -
1180 } -
1181 return QDate();
executed: return QDate();
Execution Count:12
12
1182} -
1183 -
1184/*! -
1185 \fn QDate::fromString(const QString &string, const QString &format) -
1186 -
1187 Returns the QDate represented by the \a string, using the \a -
1188 format given, or an invalid date if the string cannot be parsed. -
1189 -
1190 These expressions may be used for the format: -
1191 -
1192 \table -
1193 \header \li Expression \li Output -
1194 \row \li d \li The day as a number without a leading zero (1 to 31) -
1195 \row \li dd \li The day as a number with a leading zero (01 to 31) -
1196 \row \li ddd -
1197 \li The abbreviated localized day name (e.g. 'Mon' to 'Sun'). -
1198 Uses QDate::shortDayName(). -
1199 \row \li dddd -
1200 \li The long localized day name (e.g. 'Monday' to 'Sunday'). -
1201 Uses QDate::longDayName(). -
1202 \row \li M \li The month as a number without a leading zero (1 to 12) -
1203 \row \li MM \li The month as a number with a leading zero (01 to 12) -
1204 \row \li MMM -
1205 \li The abbreviated localized month name (e.g. 'Jan' to 'Dec'). -
1206 Uses QDate::shortMonthName(). -
1207 \row \li MMMM -
1208 \li The long localized month name (e.g. 'January' to 'December'). -
1209 Uses QDate::longMonthName(). -
1210 \row \li yy \li The year as two digit number (00 to 99) -
1211 \row \li yyyy \li The year as four digit number. If the year is negative, -
1212 a minus sign is prepended in addition. -
1213 \endtable -
1214 -
1215 All other input characters will be treated as text. Any sequence -
1216 of characters that are enclosed in single quotes will also be -
1217 treated as text and will not be used as an expression. For example: -
1218 -
1219 \snippet code/src_corelib_tools_qdatetime.cpp 1 -
1220 -
1221 If the format is not satisfied, an invalid QDate is returned. The -
1222 expressions that don't expect leading zeroes (d, M) will be -
1223 greedy. This means that they will use two digits even if this -
1224 will put them outside the accepted range of values and leaves too -
1225 few digits for other sections. For example, the following format -
1226 string could have meant January 30 but the M will grab two -
1227 digits, resulting in an invalid date: -
1228 -
1229 \snippet code/src_corelib_tools_qdatetime.cpp 2 -
1230 -
1231 For any field that is not represented in the format the following -
1232 defaults are used: -
1233 -
1234 \table -
1235 \header \li Field \li Default value -
1236 \row \li Year \li 1900 -
1237 \row \li Month \li 1 -
1238 \row \li Day \li 1 -
1239 \endtable -
1240 -
1241 The following examples demonstrate the default values: -
1242 -
1243 \snippet code/src_corelib_tools_qdatetime.cpp 3 -
1244 -
1245 \sa QDateTime::fromString(), QTime::fromString(), QDate::toString(), -
1246 QDateTime::toString(), QTime::toString() -
1247*/ -
1248 -
1249QDate QDate::fromString(const QString &string, const QString &format) -
1250{ -
1251 QDate date;
executed (the execution status of this line is deduced): QDate date;
-
1252#ifndef QT_BOOTSTRAPPED -
1253 QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString);
executed (the execution status of this line is deduced): QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString);
-
1254 if (dt.parseFormat(format))
partially evaluated: dt.parseFormat(format)
TRUEFALSE
yes
Evaluation Count:44
no
Evaluation Count:0
0-44
1255 dt.fromString(string, &date, 0);
executed: dt.fromString(string, &date, 0);
Execution Count:44
44
1256#else -
1257 Q_UNUSED(string); -
1258 Q_UNUSED(format); -
1259#endif -
1260 return date;
executed: return date;
Execution Count:44
44
1261} -
1262#endif // QT_NO_DATESTRING -
1263 -
1264/*! -
1265 \overload -
1266 -
1267 Returns true if the specified date (\a year, \a month, and \a -
1268 day) is valid; otherwise returns false. -
1269 -
1270 Example: -
1271 \snippet code/src_corelib_tools_qdatetime.cpp 4 -
1272 -
1273 \sa isNull(), setDate() -
1274*/ -
1275 -
1276bool QDate::isValid(int year, int month, int day) -
1277{ -
1278 // there is no year 0 in the Gregorian calendar -
1279 if (year == 0)
evaluated: year == 0
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:703683
139-703683
1280 return false;
executed: return false;
Execution Count:139
139
1281 -
1282 return (day > 0 && month > 0 && month <= 12) &&
executed: return (day > 0 && month > 0 && month <= 12) && (day <= monthDays[month] || (day == 29 && month == 2 && isLeapYear(year)));
Execution Count:703683
703683
1283 (day <= monthDays[month] || (day == 29 && month == 2 && isLeapYear(year)));
executed: return (day > 0 && month > 0 && month <= 12) && (day <= monthDays[month] || (day == 29 && month == 2 && isLeapYear(year)));
Execution Count:703683
703683
1284} -
1285 -
1286/*! -
1287 \fn bool QDate::isLeapYear(int year) -
1288 -
1289 Returns true if the specified \a year is a leap year; otherwise -
1290 returns false. -
1291*/ -
1292 -
1293bool QDate::isLeapYear(int y) -
1294{ -
1295 // No year 0 in Gregorian calendar, so -1, -5, -9 etc are leap years -
1296 if ( y < 1)
evaluated: y < 1
TRUEFALSE
yes
Evaluation Count:9596
yes
Evaluation Count:27053
9596-27053
1297 ++y;
executed: ++y;
Execution Count:9596
9596
1298 -
1299 return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
executed: return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
Execution Count:36649
36649
1300} -
1301 -
1302/*! \fn static QDate QDate::fromJulianDay(qint64 jd) -
1303 -
1304 Converts the Julian day \a jd to a QDate. -
1305 -
1306 \sa toJulianDay() -
1307*/ -
1308 -
1309/*! \fn int QDate::toJulianDay() const -
1310 -
1311 Converts the date to a Julian day. -
1312 -
1313 \sa fromJulianDay() -
1314*/ -
1315 -
1316/***************************************************************************** -
1317 QTime member functions -
1318 *****************************************************************************/ -
1319 -
1320/*! -
1321 \class QTime -
1322 \inmodule QtCore -
1323 \reentrant -
1324 -
1325 \brief The QTime class provides clock time functions. -
1326 -
1327 -
1328 A QTime object contains a clock time, i.e. the number of hours, -
1329 minutes, seconds, and milliseconds since midnight. It can read the -
1330 current time from the system clock and measure a span of elapsed -
1331 time. It provides functions for comparing times and for -
1332 manipulating a time by adding a number of milliseconds. -
1333 -
1334 QTime uses the 24-hour clock format; it has no concept of AM/PM. -
1335 Unlike QDateTime, QTime knows nothing about time zones or -
1336 daylight savings time (DST). -
1337 -
1338 A QTime object is typically created either by giving the number -
1339 of hours, minutes, seconds, and milliseconds explicitly, or by -
1340 using the static function currentTime(), which creates a QTime -
1341 object that contains the system's local time. Note that the -
1342 accuracy depends on the accuracy of the underlying operating -
1343 system; not all systems provide 1-millisecond accuracy. -
1344 -
1345 The hour(), minute(), second(), and msec() functions provide -
1346 access to the number of hours, minutes, seconds, and milliseconds -
1347 of the time. The same information is provided in textual format by -
1348 the toString() function. -
1349 -
1350 QTime provides a full set of operators to compare two QTime -
1351 objects. QTime A is considered smaller than QTime B if A is -
1352 earlier than B. -
1353 -
1354 The addSecs() and addMSecs() functions provide the time a given -
1355 number of seconds or milliseconds later than a given time. -
1356 Correspondingly, the number of seconds or milliseconds -
1357 between two times can be found using secsTo() or msecsTo(). -
1358 -
1359 QTime can be used to measure a span of elapsed time using the -
1360 start(), restart(), and elapsed() functions. -
1361 -
1362 \sa QDate, QDateTime -
1363*/ -
1364 -
1365/*! -
1366 \fn QTime::QTime() -
1367 -
1368 Constructs a null time object. A null time can be a QTime(0, 0, 0, 0) -
1369 (i.e., midnight) object, except that isNull() returns true and isValid() -
1370 returns false. -
1371 -
1372 \sa isNull(), isValid() -
1373*/ -
1374 -
1375/*! -
1376 Constructs a time with hour \a h, minute \a m, seconds \a s and -
1377 milliseconds \a ms. -
1378 -
1379 \a h must be in the range 0 to 23, \a m and \a s must be in the -
1380 range 0 to 59, and \a ms must be in the range 0 to 999. -
1381 -
1382 \sa isValid() -
1383*/ -
1384 -
1385QTime::QTime(int h, int m, int s, int ms) -
1386{ -
1387 setHMS(h, m, s, ms);
executed (the execution status of this line is deduced): setHMS(h, m, s, ms);
-
1388}
executed: }
Execution Count:58571
58571
1389 -
1390 -
1391/*! -
1392 \fn bool QTime::isNull() const -
1393 -
1394 Returns true if the time is null (i.e., the QTime object was -
1395 constructed using the default constructor); otherwise returns -
1396 false. A null time is also an invalid time. -
1397 -
1398 \sa isValid() -
1399*/ -
1400 -
1401/*! -
1402 Returns true if the time is valid; otherwise returns false. For example, -
1403 the time 23:30:55.746 is valid, but 24:12:30 is invalid. -
1404 -
1405 \sa isNull() -
1406*/ -
1407 -
1408bool QTime::isValid() const -
1409{ -
1410 return mds > NullTime && mds < MSECS_PER_DAY;
executed: return mds > NullTime && mds < MSECS_PER_DAY;
Execution Count:28356753
28356753
1411} -
1412 -
1413 -
1414/*! -
1415 Returns the hour part (0 to 23) of the time. -
1416 -
1417 Returns -1 if the time is invalid. -
1418 -
1419 \sa minute(), second(), msec() -
1420*/ -
1421 -
1422int QTime::hour() const -
1423{ -
1424 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:44354
2-44354
1425 return -1;
executed: return -1;
Execution Count:2
2
1426 -
1427 return ds() / MSECS_PER_HOUR;
executed: return ds() / MSECS_PER_HOUR;
Execution Count:44354
44354
1428} -
1429 -
1430/*! -
1431 Returns the minute part (0 to 59) of the time. -
1432 -
1433 Returns -1 if the time is invalid. -
1434 -
1435 \sa hour(), second(), msec() -
1436*/ -
1437 -
1438int QTime::minute() const -
1439{ -
1440 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:40316
2-40316
1441 return -1;
executed: return -1;
Execution Count:2
2
1442 -
1443 return (ds() % MSECS_PER_HOUR) / MSECS_PER_MIN;
executed: return (ds() % MSECS_PER_HOUR) / MSECS_PER_MIN;
Execution Count:40316
40316
1444} -
1445 -
1446/*! -
1447 Returns the second part (0 to 59) of the time. -
1448 -
1449 Returns -1 if the time is invalid. -
1450 -
1451 \sa hour(), minute(), msec() -
1452*/ -
1453 -
1454int QTime::second() const -
1455{ -
1456 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:38565
2-38565
1457 return -1;
executed: return -1;
Execution Count:2
2
1458 -
1459 return (ds() / 1000)%SECS_PER_MIN;
executed: return (ds() / 1000)%SECS_PER_MIN;
Execution Count:38565
38565
1460} -
1461 -
1462/*! -
1463 Returns the millisecond part (0 to 999) of the time. -
1464 -
1465 Returns -1 if the time is invalid. -
1466 -
1467 \sa hour(), minute(), second() -
1468*/ -
1469 -
1470int QTime::msec() const -
1471{ -
1472 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:42215
1-42215
1473 return -1;
executed: return -1;
Execution Count:1
1
1474 -
1475 return ds() % 1000;
executed: return ds() % 1000;
Execution Count:42215
42215
1476} -
1477 -
1478#ifndef QT_NO_DATESTRING -
1479/*! -
1480 \overload -
1481 -
1482 Returns the time as a string. Milliseconds are not included. The -
1483 \a format parameter determines the format of the string. -
1484 -
1485 If \a format is Qt::TextDate, the string format is HH:MM:SS; e.g. 1 -
1486 second before midnight would be "23:59:59". -
1487 -
1488 If \a format is Qt::ISODate, the string format corresponds to the -
1489 ISO 8601 extended specification for representations of dates, -
1490 which is also HH:MM:SS. -
1491 -
1492 If the \a format is Qt::SystemLocaleShortDate or -
1493 Qt::SystemLocaleLongDate, the string format depends on the locale -
1494 settings of the system. Identical to calling -
1495 QLocale::system().toString(time, QLocale::ShortFormat) or -
1496 QLocale::system().toString(time, QLocale::LongFormat). -
1497 -
1498 If the \a format is Qt::DefaultLocaleShortDate or -
1499 Qt::DefaultLocaleLongDate, the string format depends on the -
1500 default application locale. This is the locale set with -
1501 QLocale::setDefault(), or the system locale if no default locale -
1502 has been set. Identical to calling QLocale().toString(time, -
1503 QLocale::ShortFormat) or QLocale().toString(time, -
1504 QLocale::LongFormat). -
1505 -
1506 If the time is invalid, an empty string will be returned. -
1507*/ -
1508 -
1509QString QTime::toString(Qt::DateFormat format) const -
1510{ -
1511 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1749
1-1749
1512 return QString();
executed: return QString();
Execution Count:1
1
1513 -
1514 switch (format) { -
1515 case Qt::SystemLocaleDate: -
1516 case Qt::SystemLocaleShortDate: -
1517 case Qt::SystemLocaleLongDate: -
1518 return QLocale::system().toString(*this, format == Qt::SystemLocaleLongDate ? QLocale::LongFormat
executed: return QLocale::system().toString(*this, format == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:1647
1647
1519 : QLocale::ShortFormat);
executed: return QLocale::system().toString(*this, format == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:1647
1647
1520 case Qt::LocaleDate: -
1521 case Qt::DefaultLocaleShortDate: -
1522 case Qt::DefaultLocaleLongDate: -
1523 return QLocale().toString(*this, format == Qt::DefaultLocaleLongDate ? QLocale::LongFormat
executed: return QLocale().toString(*this, format == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:5
5
1524 : QLocale::ShortFormat);
executed: return QLocale().toString(*this, format == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:5
5
1525 -
1526 default: -
1527 case Qt::ISODate: -
1528 case Qt::TextDate: -
1529 return QString::fromLatin1("%1:%2:%3")
executed: return QString::fromLatin1("%1:%2:%3") .arg(hour(), 2, 10, QLatin1Char('0')) .arg(minute(), 2, 10, QLatin1Char('0')) .arg(second(), 2, 10, QLatin1Char('0'));
Execution Count:97
97
1530 .arg(hour(), 2, 10, QLatin1Char('0'))
executed: return QString::fromLatin1("%1:%2:%3") .arg(hour(), 2, 10, QLatin1Char('0')) .arg(minute(), 2, 10, QLatin1Char('0')) .arg(second(), 2, 10, QLatin1Char('0'));
Execution Count:97
97
1531 .arg(minute(), 2, 10, QLatin1Char('0'))
executed: return QString::fromLatin1("%1:%2:%3") .arg(hour(), 2, 10, QLatin1Char('0')) .arg(minute(), 2, 10, QLatin1Char('0')) .arg(second(), 2, 10, QLatin1Char('0'));
Execution Count:97
97
1532 .arg(second(), 2, 10, QLatin1Char('0'));
executed: return QString::fromLatin1("%1:%2:%3") .arg(hour(), 2, 10, QLatin1Char('0')) .arg(minute(), 2, 10, QLatin1Char('0')) .arg(second(), 2, 10, QLatin1Char('0'));
Execution Count:97
97
1533 } -
1534}
never executed: }
0
1535 -
1536/*! -
1537 Returns the time as a string. The \a format parameter determines -
1538 the format of the result string. -
1539 -
1540 These expressions may be used: -
1541 -
1542 \table -
1543 \header \li Expression \li Output -
1544 \row \li h -
1545 \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) -
1546 \row \li hh -
1547 \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) -
1548 \row \li H -
1549 \li the hour without a leading zero (0 to 23, even with AM/PM display) -
1550 \row \li HH -
1551 \li the hour with a leading zero (00 to 23, even with AM/PM display) -
1552 \row \li m \li the minute without a leading zero (0 to 59) -
1553 \row \li mm \li the minute with a leading zero (00 to 59) -
1554 \row \li s \li the second without a leading zero (0 to 59) -
1555 \row \li ss \li the second with a leading zero (00 to 59) -
1556 \row \li z \li the milliseconds without leading zeroes (0 to 999) -
1557 \row \li zzz \li the milliseconds with leading zeroes (000 to 999) -
1558 \row \li AP or A -
1559 \li use AM/PM display. \e A/AP will be replaced by either "AM" or "PM". -
1560 \row \li ap or a -
1561 \li use am/pm display. \e a/ap will be replaced by either "am" or "pm". -
1562 \row \li t \li the timezone (for example "CEST") -
1563 \endtable -
1564 -
1565 All other input characters will be ignored. Any sequence of characters that -
1566 are enclosed in single quotes will be treated as text and not be used as an -
1567 expression. Two consecutive single quotes ("''") are replaced by a singlequote -
1568 in the output. Formats without separators (e.g. "HHmm") are currently not supported. -
1569 -
1570 Example format strings (assuming that the QTime is 14:13:09.042) -
1571 -
1572 \table -
1573 \header \li Format \li Result -
1574 \row \li hh:mm:ss.zzz \li 14:13:09.042 -
1575 \row \li h:m:s ap \li 2:13:9 pm -
1576 \row \li H:m:s a \li 14:13:9 pm -
1577 \endtable -
1578 -
1579 If the time is invalid, an empty string will be returned. -
1580 If \a format is empty, the default format "hh:mm:ss" is used. -
1581 -
1582 \sa QDate::toString(), QDateTime::toString() -
1583*/ -
1584QString QTime::toString(const QString& format) const -
1585{ -
1586 return fmtDateTime(format, this, 0);
executed: return fmtDateTime(format, this, 0);
Execution Count:13408
13408
1587} -
1588#endif //QT_NO_DATESTRING -
1589/*! -
1590 Sets the time to hour \a h, minute \a m, seconds \a s and -
1591 milliseconds \a ms. -
1592 -
1593 \a h must be in the range 0 to 23, \a m and \a s must be in the -
1594 range 0 to 59, and \a ms must be in the range 0 to 999. -
1595 Returns true if the set time is valid; otherwise returns false. -
1596 -
1597 \sa isValid() -
1598*/ -
1599 -
1600bool QTime::setHMS(int h, int m, int s, int ms) -
1601{ -
1602#if defined(Q_OS_WINCE) -
1603 startTick = NullTime; -
1604#endif -
1605 if (!isValid(h,m,s,ms)) {
evaluated: !isValid(h,m,s,ms)
TRUEFALSE
yes
Evaluation Count:90
yes
Evaluation Count:58491
90-58491
1606 mds = NullTime; // make this invalid
executed (the execution status of this line is deduced): mds = NullTime;
-
1607 return false;
executed: return false;
Execution Count:90
90
1608 } -
1609 mds = (h*SECS_PER_HOUR + m*SECS_PER_MIN + s)*1000 + ms;
executed (the execution status of this line is deduced): mds = (h*SECS_PER_HOUR + m*SECS_PER_MIN + s)*1000 + ms;
-
1610 return true;
executed: return true;
Execution Count:58491
58491
1611} -
1612 -
1613/*! -
1614 Returns a QTime object containing a time \a s seconds later -
1615 than the time of this object (or earlier if \a s is negative). -
1616 -
1617 Note that the time will wrap if it passes midnight. -
1618 -
1619 Returns a null time if this time is invalid. -
1620 -
1621 Example: -
1622 -
1623 \snippet code/src_corelib_tools_qdatetime.cpp 5 -
1624 -
1625 \sa addMSecs(), secsTo(), QDateTime::addSecs() -
1626*/ -
1627 -
1628QTime QTime::addSecs(int s) const -
1629{ -
1630 return addMSecs(s * 1000);
executed: return addMSecs(s * 1000);
Execution Count:5013
5013
1631} -
1632 -
1633/*! -
1634 Returns the number of seconds from this time to \a t. -
1635 If \a t is earlier than this time, the number of seconds returned -
1636 is negative. -
1637 -
1638 Because QTime measures time within a day and there are 86400 -
1639 seconds in a day, the result is always between -86400 and 86400. -
1640 -
1641 secsTo() does not take into account any milliseconds. -
1642 -
1643 Returns 0 if either time is invalid. -
1644 -
1645 \sa addSecs(), QDateTime::secsTo() -
1646*/ -
1647 -
1648int QTime::secsTo(const QTime &t) const -
1649{ -
1650 if (!isValid() || !t.isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5852
evaluated: !t.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5851
1-5852
1651 return 0;
executed: return 0;
Execution Count:3
3
1652 -
1653 // Truncate milliseconds as we do not want to consider them. -
1654 int ourSeconds = ds() / 1000;
executed (the execution status of this line is deduced): int ourSeconds = ds() / 1000;
-
1655 int theirSeconds = t.ds() / 1000;
executed (the execution status of this line is deduced): int theirSeconds = t.ds() / 1000;
-
1656 return theirSeconds - ourSeconds;
executed: return theirSeconds - ourSeconds;
Execution Count:5851
5851
1657} -
1658 -
1659/*! -
1660 Returns a QTime object containing a time \a ms milliseconds later -
1661 than the time of this object (or earlier if \a ms is negative). -
1662 -
1663 Note that the time will wrap if it passes midnight. See addSecs() -
1664 for an example. -
1665 -
1666 Returns a null time if this time is invalid. -
1667 -
1668 \sa addSecs(), msecsTo(), QDateTime::addMSecs() -
1669*/ -
1670 -
1671QTime QTime::addMSecs(int ms) const -
1672{ -
1673 QTime t;
executed (the execution status of this line is deduced): QTime t;
-
1674 if (isValid()) {
evaluated: isValid()
TRUEFALSE
yes
Evaluation Count:7413
yes
Evaluation Count:1
1-7413
1675 if (ms < 0) {
evaluated: ms < 0
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:7375
38-7375
1676 // % not well-defined for -ve, but / is. -
1677 int negdays = (MSECS_PER_DAY - ms) / MSECS_PER_DAY;
executed (the execution status of this line is deduced): int negdays = (MSECS_PER_DAY - ms) / MSECS_PER_DAY;
-
1678 t.mds = (ds() + ms + negdays * MSECS_PER_DAY) % MSECS_PER_DAY;
executed (the execution status of this line is deduced): t.mds = (ds() + ms + negdays * MSECS_PER_DAY) % MSECS_PER_DAY;
-
1679 } else {
executed: }
Execution Count:38
38
1680 t.mds = (ds() + ms) % MSECS_PER_DAY;
executed (the execution status of this line is deduced): t.mds = (ds() + ms) % MSECS_PER_DAY;
-
1681 }
executed: }
Execution Count:7375
7375
1682 } -
1683#if defined(Q_OS_WINCE) -
1684 if (startTick > NullTime) -
1685 t.startTick = (startTick + ms) % MSECS_PER_DAY; -
1686#endif -
1687 return t;
executed: return t;
Execution Count:7414
7414
1688} -
1689 -
1690/*! -
1691 Returns the number of milliseconds from this time to \a t. -
1692 If \a t is earlier than this time, the number of milliseconds returned -
1693 is negative. -
1694 -
1695 Because QTime measures time within a day and there are 86400 -
1696 seconds in a day, the result is always between -86400000 and -
1697 86400000 ms. -
1698 -
1699 Returns 0 if either time is invalid. -
1700 -
1701 \sa secsTo(), addMSecs(), QDateTime::msecsTo() -
1702*/ -
1703 -
1704int QTime::msecsTo(const QTime &t) const -
1705{ -
1706 if (!isValid() || !t.isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:14035969
evaluated: !t.isValid()
TRUEFALSE
yes
Evaluation Count:1666
yes
Evaluation Count:14034155
5-14035969
1707 return 0;
executed: return 0;
Execution Count:1671
1671
1708#if defined(Q_OS_WINCE) -
1709 // GetLocalTime() for Windows CE has no milliseconds resolution -
1710 if (t.startTick > NullTime && startTick > NullTime) -
1711 return t.startTick - startTick; -
1712 else -
1713#endif -
1714 return t.ds() - ds();
executed: return t.ds() - ds();
Execution Count:14034143
14034143
1715} -
1716 -
1717 -
1718/*! -
1719 \fn bool QTime::operator==(const QTime &t) const -
1720 -
1721 Returns true if this time is equal to \a t; otherwise returns false. -
1722*/ -
1723 -
1724/*! -
1725 \fn bool QTime::operator!=(const QTime &t) const -
1726 -
1727 Returns true if this time is different from \a t; otherwise returns false. -
1728*/ -
1729 -
1730/*! -
1731 \fn bool QTime::operator<(const QTime &t) const -
1732 -
1733 Returns true if this time is earlier than \a t; otherwise returns false. -
1734*/ -
1735 -
1736/*! -
1737 \fn bool QTime::operator<=(const QTime &t) const -
1738 -
1739 Returns true if this time is earlier than or equal to \a t; -
1740 otherwise returns false. -
1741*/ -
1742 -
1743/*! -
1744 \fn bool QTime::operator>(const QTime &t) const -
1745 -
1746 Returns true if this time is later than \a t; otherwise returns false. -
1747*/ -
1748 -
1749/*! -
1750 \fn bool QTime::operator>=(const QTime &t) const -
1751 -
1752 Returns true if this time is later than or equal to \a t; -
1753 otherwise returns false. -
1754*/ -
1755 -
1756/*! -
1757 \fn QTime::currentTime() -
1758 -
1759 Returns the current time as reported by the system clock. -
1760 -
1761 Note that the accuracy depends on the accuracy of the underlying -
1762 operating system; not all systems provide 1-millisecond accuracy. -
1763*/ -
1764 -
1765#ifndef QT_NO_DATESTRING -
1766 -
1767// These anonymous functions tidy up QDateTime::fromString() -
1768// and avoid confusion of responsibility between it and QTime::fromString(). -
1769namespace { -
1770inline bool isMidnight(int hour, int minute, int second, int msec) -
1771{ -
1772 return hour == 24 && minute == 0 && second == 0 && msec == 0;
executed: return hour == 24 && minute == 0 && second == 0 && msec == 0;
Execution Count:51
51
1773} -
1774 -
1775QTime fromStringImpl(const QString &s, Qt::DateFormat f, bool &isMidnight24) -
1776{ -
1777 if (s.isEmpty()) {
evaluated: s.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:76
5-76
1778 // Return a null time. -
1779 return QTime();
executed: return QTime();
Execution Count:5
5
1780 } -
1781 -
1782 switch (f) { -
1783 case Qt::SystemLocaleDate: -
1784 case Qt::SystemLocaleShortDate: -
1785 case Qt::SystemLocaleLongDate: -
1786 { -
1787 QLocale::FormatType formatType(Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
never executed (the execution status of this line is deduced): QLocale::FormatType formatType(Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
-
1788 return QTime::fromString(s, QLocale::system().timeFormat(formatType));
never executed: return QTime::fromString(s, QLocale::system().timeFormat(formatType));
0
1789 } -
1790 case Qt::LocaleDate: -
1791 case Qt::DefaultLocaleShortDate: -
1792 case Qt::DefaultLocaleLongDate: -
1793 { -
1794 QLocale::FormatType formatType(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
never executed (the execution status of this line is deduced): QLocale::FormatType formatType(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
-
1795 return QTime::fromString(s, QLocale().timeFormat(formatType));
never executed: return QTime::fromString(s, QLocale().timeFormat(formatType));
0
1796 } -
1797 case Qt::TextDate: -
1798 case Qt::ISODate: -
1799 { -
1800 bool ok = true;
executed (the execution status of this line is deduced): bool ok = true;
-
1801 const int hour(s.mid(0, 2).toInt(&ok));
executed (the execution status of this line is deduced): const int hour(s.mid(0, 2).toInt(&ok));
-
1802 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:68
8-68
1803 return QTime();
executed: return QTime();
Execution Count:8
8
1804 const int minute(s.mid(3, 2).toInt(&ok));
executed (the execution status of this line is deduced): const int minute(s.mid(3, 2).toInt(&ok));
-
1805 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:66
2-66
1806 return QTime();
executed: return QTime();
Execution Count:2
2
1807 if (f == Qt::ISODate) {
evaluated: f == Qt::ISODate
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:6
6-60
1808 if (s.size() == 5) {
evaluated: s.size() == 5
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:55
5-55
1809 // Do not need to specify seconds if using ISO format. -
1810 return QTime(hour, minute, 0, 0);
executed: return QTime(hour, minute, 0, 0);
Execution Count:5
5
1811 } else if ((s.size() > 6) && (s[5] == QLatin1Char(',') || s[5] == QLatin1Char('.'))) {
evaluated: (s.size() > 6)
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:1
evaluated: s[5] == QLatin1Char(',')
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:49
evaluated: s[5] == QLatin1Char('.')
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:46
1-54
1812 // Possibly specifying fraction of a minute. -
1813 -
1814 // We only want 5 digits worth of fraction of minute. This follows the existing -
1815 // behaviour that determines how milliseconds are read; 4 millisecond digits are -
1816 // read and then rounded to 3. If we read at most 5 digits for fraction of minute, -
1817 // the maximum amount of millisecond digits it will expand to once converted to -
1818 // seconds is 4. E.g. 12:34,99999 will expand to 12:34:59.9994. The milliseconds -
1819 // will then be rounded up AND clamped to 999. -
1820 const QString minuteFractionStr(QLatin1String("0.") + s.mid(6, 5));
executed (the execution status of this line is deduced): const QString minuteFractionStr(QLatin1String("0.") + s.mid(6, 5));
-
1821 const float minuteFraction = minuteFractionStr.toFloat(&ok);
executed (the execution status of this line is deduced): const float minuteFraction = minuteFractionStr.toFloat(&ok);
-
1822 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
1823 return QTime();
executed: return QTime();
Execution Count:1
1
1824 const float secondWithMs = minuteFraction * 60;
executed (the execution status of this line is deduced): const float secondWithMs = minuteFraction * 60;
-
1825 const float second = std::floor(secondWithMs);
executed (the execution status of this line is deduced): const float second = std::floor(secondWithMs);
-
1826 const float millisecond = 1000 * (secondWithMs - second);
executed (the execution status of this line is deduced): const float millisecond = 1000 * (secondWithMs - second);
-
1827 const int millisecondRounded = qMin(qRound(millisecond), 999);
executed (the execution status of this line is deduced): const int millisecondRounded = qMin(qRound(millisecond), 999);
-
1828 -
1829 if (isMidnight(hour, minute, second, millisecondRounded)) {
evaluated: isMidnight(hour, minute, second, millisecondRounded)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
1830 isMidnight24 = true;
executed (the execution status of this line is deduced): isMidnight24 = true;
-
1831 return QTime(0, 0, 0, 0);
executed: return QTime(0, 0, 0, 0);
Execution Count:1
1
1832 } -
1833 -
1834 return QTime(hour, minute, second, millisecondRounded);
executed: return QTime(hour, minute, second, millisecondRounded);
Execution Count:6
6
1835 } -
1836 } -
1837 -
1838 const int second(s.mid(6, 2).toInt(&ok));
executed (the execution status of this line is deduced): const int second(s.mid(6, 2).toInt(&ok));
-
1839 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:50
3-50
1840 return QTime();
executed: return QTime();
Execution Count:3
3
1841 const QString msec_s(QLatin1String("0.") + s.mid(9, 4));
executed (the execution status of this line is deduced): const QString msec_s(QLatin1String("0.") + s.mid(9, 4));
-
1842 const double msec(msec_s.toDouble(&ok));
executed (the execution status of this line is deduced): const double msec(msec_s.toDouble(&ok));
-
1843 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:48
2-48
1844 return QTime(hour, minute, second, 0);
executed: return QTime(hour, minute, second, 0);
Execution Count:2
2
1845 -
1846 if (f == Qt::ISODate) {
evaluated: f == Qt::ISODate
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:4
4-44
1847 if (isMidnight(hour, minute, second, msec)) {
evaluated: isMidnight(hour, minute, second, msec)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:39
5-39
1848 isMidnight24 = true;
executed (the execution status of this line is deduced): isMidnight24 = true;
-
1849 return QTime(0, 0, 0, 0);
executed: return QTime(0, 0, 0, 0);
Execution Count:5
5
1850 } -
1851 }
executed: }
Execution Count:39
39
1852 return QTime(hour, minute, second, qMin(qRound(msec * 1000.0), 999));
executed: return QTime(hour, minute, second, qMin(qRound(msec * 1000.0), 999));
Execution Count:43
43
1853 } -
1854 } -
1855 Q_UNREACHABLE();
never executed: }
never evaluated: 0
0
1856 return QTime();
never executed: return QTime();
0
1857} -
1858} -
1859 -
1860 -
1861/*! -
1862 \fn QTime QTime::fromString(const QString &string, Qt::DateFormat format) -
1863 -
1864 Returns the time represented in the \a string as a QTime using the -
1865 \a format given, or an invalid time if this is not possible. -
1866 -
1867 Note that fromString() uses a "C" locale encoded string to convert -
1868 milliseconds to a float value. If the default locale is not "C", -
1869 this may result in two conversion attempts (if the conversion -
1870 fails for the default locale). This should be considered an -
1871 implementation detail. -
1872*/ -
1873QTime QTime::fromString(const QString& s, Qt::DateFormat f) -
1874{ -
1875 bool unused;
executed (the execution status of this line is deduced): bool unused;
-
1876 return fromStringImpl(s, f, unused);
executed: return fromStringImpl(s, f, unused);
Execution Count:29
29
1877} -
1878 -
1879/*! -
1880 \fn QTime::fromString(const QString &string, const QString &format) -
1881 -
1882 Returns the QTime represented by the \a string, using the \a -
1883 format given, or an invalid time if the string cannot be parsed. -
1884 -
1885 These expressions may be used for the format: -
1886 -
1887 \table -
1888 \header \li Expression \li Output -
1889 \row \li h -
1890 \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) -
1891 \row \li hh -
1892 \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) -
1893 \row \li m \li the minute without a leading zero (0 to 59) -
1894 \row \li mm \li the minute with a leading zero (00 to 59) -
1895 \row \li s \li the second without a leading zero (0 to 59) -
1896 \row \li ss \li the second with a leading zero (00 to 59) -
1897 \row \li z \li the milliseconds without leading zeroes (0 to 999) -
1898 \row \li zzz \li the milliseconds with leading zeroes (000 to 999) -
1899 \row \li AP -
1900 \li interpret as an AM/PM time. \e AP must be either "AM" or "PM". -
1901 \row \li ap -
1902 \li Interpret as an AM/PM time. \e ap must be either "am" or "pm". -
1903 \endtable -
1904 -
1905 All other input characters will be treated as text. Any sequence -
1906 of characters that are enclosed in single quotes will also be -
1907 treated as text and not be used as an expression. -
1908 -
1909 \snippet code/src_corelib_tools_qdatetime.cpp 6 -
1910 -
1911 If the format is not satisfied, an invalid QTime is returned. -
1912 Expressions that do not expect leading zeroes to be given (h, m, s -
1913 and z) are greedy. This means that they will use two digits even if -
1914 this puts them outside the range of accepted values and leaves too -
1915 few digits for other sections. For example, the following string -
1916 could have meant 00:07:10, but the m will grab two digits, resulting -
1917 in an invalid time: -
1918 -
1919 \snippet code/src_corelib_tools_qdatetime.cpp 7 -
1920 -
1921 Any field that is not represented in the format will be set to zero. -
1922 For example: -
1923 -
1924 \snippet code/src_corelib_tools_qdatetime.cpp 8 -
1925 -
1926 \sa QDateTime::fromString(), QDate::fromString(), QDate::toString(), -
1927 QDateTime::toString(), QTime::toString() -
1928*/ -
1929 -
1930QTime QTime::fromString(const QString &string, const QString &format) -
1931{ -
1932 QTime time;
executed (the execution status of this line is deduced): QTime time;
-
1933#ifndef QT_BOOTSTRAPPED -
1934 QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString);
executed (the execution status of this line is deduced): QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString);
-
1935 if (dt.parseFormat(format))
partially evaluated: dt.parseFormat(format)
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
1936 dt.fromString(string, 0, &time);
executed: dt.fromString(string, 0, &time);
Execution Count:12
12
1937#else -
1938 Q_UNUSED(string); -
1939 Q_UNUSED(format); -
1940#endif -
1941 return time;
executed: return time;
Execution Count:12
12
1942} -
1943 -
1944#endif // QT_NO_DATESTRING -
1945 -
1946 -
1947/*! -
1948 \overload -
1949 -
1950 Returns true if the specified time is valid; otherwise returns -
1951 false. -
1952 -
1953 The time is valid if \a h is in the range 0 to 23, \a m and -
1954 \a s are in the range 0 to 59, and \a ms is in the range 0 to 999. -
1955 -
1956 Example: -
1957 -
1958 \snippet code/src_corelib_tools_qdatetime.cpp 9 -
1959*/ -
1960 -
1961bool QTime::isValid(int h, int m, int s, int ms) -
1962{ -
1963 return (uint)h < 24 && (uint)m < 60 && (uint)s < 60 && (uint)ms < 1000;
executed: return (uint)h < 24 && (uint)m < 60 && (uint)s < 60 && (uint)ms < 1000;
Execution Count:61199
61199
1964} -
1965 -
1966 -
1967/*! -
1968 Sets this time to the current time. This is practical for timing: -
1969 -
1970 \snippet code/src_corelib_tools_qdatetime.cpp 10 -
1971 -
1972 \sa restart(), elapsed(), currentTime() -
1973*/ -
1974 -
1975void QTime::start() -
1976{ -
1977 *this = currentTime();
executed (the execution status of this line is deduced): *this = currentTime();
-
1978}
executed: }
Execution Count:1136
1136
1979 -
1980/*! -
1981 Sets this time to the current time and returns the number of -
1982 milliseconds that have elapsed since the last time start() or -
1983 restart() was called. -
1984 -
1985 This function is guaranteed to be atomic and is thus very handy -
1986 for repeated measurements. Call start() to start the first -
1987 measurement, and restart() for each later measurement. -
1988 -
1989 Note that the counter wraps to zero 24 hours after the last call -
1990 to start() or restart(). -
1991 -
1992 \warning If the system's clock setting has been changed since the -
1993 last time start() or restart() was called, the result is -
1994 undefined. This can happen when daylight savings time is turned on -
1995 or off. -
1996 -
1997 \sa start(), elapsed(), currentTime() -
1998*/ -
1999 -
2000int QTime::restart() -
2001{ -
2002 QTime t = currentTime();
executed (the execution status of this line is deduced): QTime t = currentTime();
-
2003 int n = msecsTo(t);
executed (the execution status of this line is deduced): int n = msecsTo(t);
-
2004 if (n < 0) // passed midnight
partially evaluated: n < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:202
0-202
2005 n += 86400*1000;
never executed: n += 86400*1000;
0
2006 *this = t;
executed (the execution status of this line is deduced): *this = t;
-
2007 return n;
executed: return n;
Execution Count:202
202
2008} -
2009 -
2010/*! -
2011 Returns the number of milliseconds that have elapsed since the -
2012 last time start() or restart() was called. -
2013 -
2014 Note that the counter wraps to zero 24 hours after the last call -
2015 to start() or restart. -
2016 -
2017 Note that the accuracy depends on the accuracy of the underlying -
2018 operating system; not all systems provide 1-millisecond accuracy. -
2019 -
2020 \warning If the system's clock setting has been changed since the -
2021 last time start() or restart() was called, the result is -
2022 undefined. This can happen when daylight savings time is turned on -
2023 or off. -
2024 -
2025 \sa start(), restart() -
2026*/ -
2027 -
2028int QTime::elapsed() const -
2029{ -
2030 int n = msecsTo(currentTime());
executed (the execution status of this line is deduced): int n = msecsTo(currentTime());
-
2031 if (n < 0) // passed midnight
partially evaluated: n < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14025440
0-14025440
2032 n += 86400 * 1000;
never executed: n += 86400 * 1000;
0
2033 return n;
executed: return n;
Execution Count:14025437
14025437
2034} -
2035 -
2036 -
2037/***************************************************************************** -
2038 QDateTime member functions -
2039 *****************************************************************************/ -
2040 -
2041/*! -
2042 \class QDateTime -
2043 \inmodule QtCore -
2044 \ingroup shared -
2045 \reentrant -
2046 \brief The QDateTime class provides date and time functions. -
2047 -
2048 -
2049 A QDateTime object contains a calendar date and a clock time (a -
2050 "datetime"). It is a combination of the QDate and QTime classes. -
2051 It can read the current datetime from the system clock. It -
2052 provides functions for comparing datetimes and for manipulating a -
2053 datetime by adding a number of seconds, days, months, or years. -
2054 -
2055 A QDateTime object is typically created either by giving a date -
2056 and time explicitly in the constructor, or by using the static -
2057 function currentDateTime() that returns a QDateTime object set -
2058 to the system clock's time. The date and time can be changed with -
2059 setDate() and setTime(). A datetime can also be set using the -
2060 setTime_t() function that takes a POSIX-standard "number of -
2061 seconds since 00:00:00 on January 1, 1970" value. The fromString() -
2062 function returns a QDateTime, given a string and a date format -
2063 used to interpret the date within the string. -
2064 -
2065 The date() and time() functions provide access to the date and -
2066 time parts of the datetime. The same information is provided in -
2067 textual format by the toString() function. -
2068 -
2069 QDateTime provides a full set of operators to compare two -
2070 QDateTime objects, where smaller means earlier and larger means -
2071 later. -
2072 -
2073 You can increment (or decrement) a datetime by a given number of -
2074 milliseconds using addMSecs(), seconds using addSecs(), or days -
2075 using addDays(). Similarly, you can use addMonths() and addYears(). -
2076 The daysTo() function returns the number of days between two datetimes, -
2077 secsTo() returns the number of seconds between two datetimes, and -
2078 msecsTo() returns the number of milliseconds between two datetimes. -
2079 -
2080 QDateTime can store datetimes as \l{Qt::LocalTime}{local time} or -
2081 as \l{Qt::UTC}{UTC}. QDateTime::currentDateTime() returns a -
2082 QDateTime expressed as local time; use toUTC() to convert it to -
2083 UTC. You can also use timeSpec() to find out if a QDateTime -
2084 object stores a UTC time or a local time. Operations such as -
2085 addSecs() and secsTo() are aware of daylight saving time (DST). -
2086 -
2087 \note QDateTime does not account for leap seconds. -
2088 -
2089 \section1 -
2090 -
2091 \section2 No Year 0 -
2092 -
2093 There is no year 0. Dates in that year are considered invalid. The -
2094 year -1 is the year "1 before Christ" or "1 before current era." -
2095 The day before 1 January 1 CE is 31 December 1 BCE. -
2096 -
2097 \section2 Range of Valid Dates -
2098 -
2099 Dates are stored internally as a Julian Day number, an integer count of -
2100 every day in a contiguous range, with 24 November 4714 BCE in the Gregorian -
2101 calendar being Julian Day 0 (1 January 4713 BCE in the Julian calendar). -
2102 As well as being an efficient and accurate way of storing an absolute date, -
2103 it is suitable for converting a Date into other calendar systems such as -
2104 Hebrew, Islamic or Chinese. The Julian Day number can be obtained using -
2105 QDate::toJulianDay() and can be set using QDate::fromJulianDay(). -
2106 -
2107 The range of dates able to be stored by QDate as a Julian Day number is -
2108 for technical reasons limited to between -784350574879 and 784354017364, -
2109 which means from before 2 billion BCE to after 2 billion CE. -
2110 -
2111 \section2 -
2112 Use of System Timezone -
2113 -
2114 QDateTime uses the system's time zone information to determine the -
2115 offset of local time from UTC. If the system is not configured -
2116 correctly or not up-to-date, QDateTime will give wrong results as -
2117 well. -
2118 -
2119 \section2 Daylight Savings Time (DST) -
2120 -
2121 QDateTime takes into account the system's time zone information -
2122 when dealing with DST. On modern Unix systems, this means it -
2123 applies the correct historical DST data whenever possible. On -
2124 Windows and Windows CE, where the system doesn't support -
2125 historical DST data, historical accuracy is not maintained with -
2126 respect to DST. -
2127 -
2128 The range of valid dates taking DST into account is 1970-01-01 to -
2129 the present, and rules are in place for handling DST correctly -
2130 until 2037-12-31, but these could change. For dates falling -
2131 outside that range, QDateTime makes a \e{best guess} using the -
2132 rules for year 1970 or 2037, but we can't guarantee accuracy. This -
2133 means QDateTime doesn't take into account changes in a locale's -
2134 time zone before 1970, even if the system's time zone database -
2135 supports that information. -
2136 -
2137 \sa QDate, QTime, QDateTimeEdit -
2138*/ -
2139 -
2140/*! -
2141 Constructs a null datetime (i.e. null date and null time). A null -
2142 datetime is invalid, since the date is invalid. -
2143 -
2144 \sa isValid() -
2145*/ -
2146QDateTime::QDateTime() -
2147 : d(new QDateTimePrivate) -
2148{ -
2149}
executed: }
Execution Count:543637
543637
2150 -
2151 -
2152/*! -
2153 Constructs a datetime with the given \a date, a valid -
2154 time(00:00:00.000), and sets the timeSpec() to Qt::LocalTime. -
2155*/ -
2156 -
2157QDateTime::QDateTime(const QDate &date) -
2158 : d(new QDateTimePrivate) -
2159{ -
2160 d->date = date;
executed (the execution status of this line is deduced): d->date = date;
-
2161 d->time = QTime(0, 0, 0);
executed (the execution status of this line is deduced): d->time = QTime(0, 0, 0);
-
2162}
executed: }
Execution Count:6
6
2163 -
2164/*! -
2165 Constructs a datetime with the given \a date and \a time, using -
2166 the time specification defined by \a spec. -
2167 -
2168 If \a date is valid and \a time is not, the time will be set to midnight. -
2169*/ -
2170 -
2171QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec) -
2172 : d(new QDateTimePrivate) -
2173{ -
2174 d->date = date;
executed (the execution status of this line is deduced): d->date = date;
-
2175 d->time = date.isValid() && !time.isValid() ? QTime(0, 0, 0) : time;
evaluated: date.isValid()
TRUEFALSE
yes
Evaluation Count:21184
yes
Evaluation Count:105
evaluated: !time.isValid()
TRUEFALSE
yes
Evaluation Count:863
yes
Evaluation Count:20321
105-21184
2176 d->spec = (spec == Qt::UTC) ? QDateTimePrivate::UTC : QDateTimePrivate::LocalUnknown;
evaluated: (spec == Qt::UTC)
TRUEFALSE
yes
Evaluation Count:3974
yes
Evaluation Count:17315
3974-17315
2177}
executed: }
Execution Count:21289
21289
2178 -
2179/*! -
2180 Constructs a copy of the \a other datetime. -
2181*/ -
2182 -
2183QDateTime::QDateTime(const QDateTime &other) -
2184 : d(other.d) -
2185{ -
2186}
executed: }
Execution Count:183717
183717
2187 -
2188/*! -
2189 Destroys the datetime. -
2190*/ -
2191QDateTime::~QDateTime() -
2192{ -
2193} -
2194 -
2195/*! -
2196 Makes a copy of the \a other datetime and returns a reference to the -
2197 copy. -
2198*/ -
2199 -
2200QDateTime &QDateTime::operator=(const QDateTime &other) -
2201{ -
2202 d = other.d;
executed (the execution status of this line is deduced): d = other.d;
-
2203 return *this;
executed: return *this;
Execution Count:24547
24547
2204} -
2205/*! -
2206 \fn void QDateTime::swap(QDateTime &other) -
2207 \since 5.0 -
2208 -
2209 Swaps this datetime with \a other. This operation is very fast -
2210 and never fails. -
2211*/ -
2212 -
2213/*! -
2214 Returns true if both the date and the time are null; otherwise -
2215 returns false. A null datetime is invalid. -
2216 -
2217 \sa QDate::isNull(), QTime::isNull(), isValid() -
2218*/ -
2219 -
2220bool QDateTime::isNull() const -
2221{ -
2222 return d->date.isNull() && d->time.isNull();
executed: return d->date.isNull() && d->time.isNull();
Execution Count:3970
3970
2223} -
2224 -
2225/*! -
2226 Returns true if both the date and the time are valid; otherwise -
2227 returns false. -
2228 -
2229 \sa QDate::isValid(), QTime::isValid() -
2230*/ -
2231 -
2232bool QDateTime::isValid() const -
2233{ -
2234 return d->date.isValid() && d->time.isValid();
executed: return d->date.isValid() && d->time.isValid();
Execution Count:31518
31518
2235} -
2236 -
2237/*! -
2238 Returns the date part of the datetime. -
2239 -
2240 \sa setDate(), time(), timeSpec() -
2241*/ -
2242 -
2243QDate QDateTime::date() const -
2244{ -
2245 return d->date;
executed: return d->date;
Execution Count:54759
54759
2246} -
2247 -
2248/*! -
2249 Returns the time part of the datetime. -
2250 -
2251 \sa setTime(), date(), timeSpec() -
2252*/ -
2253 -
2254QTime QDateTime::time() const -
2255{ -
2256 return d->time;
executed: return d->time;
Execution Count:45807
45807
2257} -
2258 -
2259/*! -
2260 Returns the time specification of the datetime. -
2261 -
2262 \sa setTimeSpec(), date(), time(), Qt::TimeSpec -
2263*/ -
2264 -
2265Qt::TimeSpec QDateTime::timeSpec() const -
2266{ -
2267 switch(d->spec) -
2268 { -
2269 case QDateTimePrivate::UTC: -
2270 return Qt::UTC;
executed: return Qt::UTC;
Execution Count:2098
2098
2271 case QDateTimePrivate::OffsetFromUTC: -
2272 return Qt::OffsetFromUTC;
executed: return Qt::OffsetFromUTC;
Execution Count:7
7
2273 default: -
2274 return Qt::LocalTime;
executed: return Qt::LocalTime;
Execution Count:8092
8092
2275 } -
2276}
never executed: }
0
2277 -
2278/*! -
2279 Sets the date part of this datetime to \a date. -
2280 If no time is set, it is set to midnight. -
2281 -
2282 \sa date(), setTime(), setTimeSpec() -
2283*/ -
2284 -
2285void QDateTime::setDate(const QDate &date) -
2286{ -
2287 detach();
executed (the execution status of this line is deduced): detach();
-
2288 d->date = date;
executed (the execution status of this line is deduced): d->date = date;
-
2289 if (d->spec == QDateTimePrivate::LocalStandard
evaluated: d->spec == QDateTimePrivate::LocalStandard
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12
1-12
2290 || d->spec == QDateTimePrivate::LocalDST)
partially evaluated: d->spec == QDateTimePrivate::LocalDST
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
2291 d->spec = QDateTimePrivate::LocalUnknown;
executed: d->spec = QDateTimePrivate::LocalUnknown;
Execution Count:1
1
2292 if (date.isValid() && !d->time.isValid())
evaluated: date.isValid()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:3
evaluated: !d->time.isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:8
2-10
2293 d->time = QTime(0, 0, 0);
executed: d->time = QTime(0, 0, 0);
Execution Count:2
2
2294}
executed: }
Execution Count:13
13
2295 -
2296/*! -
2297 Sets the time part of this datetime to \a time. -
2298 -
2299 \sa time(), setDate(), setTimeSpec() -
2300*/ -
2301 -
2302void QDateTime::setTime(const QTime &time) -
2303{ -
2304 detach();
executed (the execution status of this line is deduced): detach();
-
2305 if (d->spec == QDateTimePrivate::LocalStandard
partially evaluated: d->spec == QDateTimePrivate::LocalStandard
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:134
0-134
2306 || d->spec == QDateTimePrivate::LocalDST)
evaluated: d->spec == QDateTimePrivate::LocalDST
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:133
1-133
2307 d->spec = QDateTimePrivate::LocalUnknown;
executed: d->spec = QDateTimePrivate::LocalUnknown;
Execution Count:1
1
2308 d->time = time;
executed (the execution status of this line is deduced): d->time = time;
-
2309}
executed: }
Execution Count:134
134
2310 -
2311/*! -
2312 Sets the time specification used in this datetime to \a spec. -
2313 The datetime will refer to a different point in time. -
2314 -
2315 Example: -
2316 \snippet code/src_corelib_tools_qdatetime.cpp 19 -
2317 -
2318 \sa timeSpec(), setDate(), setTime(), Qt::TimeSpec -
2319*/ -
2320 -
2321void QDateTime::setTimeSpec(Qt::TimeSpec spec) -
2322{ -
2323 detach();
executed (the execution status of this line is deduced): detach();
-
2324 -
2325 switch(spec) -
2326 { -
2327 case Qt::UTC: -
2328 d->spec = QDateTimePrivate::UTC;
executed (the execution status of this line is deduced): d->spec = QDateTimePrivate::UTC;
-
2329 break;
executed: break;
Execution Count:1627
1627
2330 case Qt::OffsetFromUTC: -
2331 d->spec = QDateTimePrivate::OffsetFromUTC;
executed (the execution status of this line is deduced): d->spec = QDateTimePrivate::OffsetFromUTC;
-
2332 break;
executed: break;
Execution Count:1
1
2333 default: -
2334 d->spec = QDateTimePrivate::LocalUnknown;
executed (the execution status of this line is deduced): d->spec = QDateTimePrivate::LocalUnknown;
-
2335 break;
executed: break;
Execution Count:10
10
2336 } -
2337}
executed: }
Execution Count:1638
1638
2338 -
2339qint64 toMSecsSinceEpoch_helper(qint64 jd, int msecs) -
2340{ -
2341 qint64 days = jd - JULIAN_DAY_FOR_EPOCH;
executed (the execution status of this line is deduced): qint64 days = jd - JULIAN_DAY_FOR_EPOCH;
-
2342 qint64 retval = (days * MSECS_PER_DAY) + msecs;
executed (the execution status of this line is deduced): qint64 retval = (days * MSECS_PER_DAY) + msecs;
-
2343 return retval;
executed: return retval;
Execution Count:7830
7830
2344} -
2345 -
2346/*! -
2347 \since 4.7 -
2348 -
2349 Returns the datetime as the number of milliseconds that have passed -
2350 since 1970-01-01T00:00:00.000, Coordinated Universal Time (Qt::UTC). -
2351 -
2352 On systems that do not support time zones, this function will -
2353 behave as if local time were Qt::UTC. -
2354 -
2355 The behavior for this function is undefined if the datetime stored in -
2356 this object is not valid. However, for all valid dates, this function -
2357 returns a unique value. -
2358 -
2359 \sa toTime_t(), setMSecsSinceEpoch() -
2360*/ -
2361qint64 QDateTime::toMSecsSinceEpoch() const -
2362{ -
2363 QDate utcDate;
executed (the execution status of this line is deduced): QDate utcDate;
-
2364 QTime utcTime;
executed (the execution status of this line is deduced): QTime utcTime;
-
2365 d->getUTC(utcDate, utcTime);
executed (the execution status of this line is deduced): d->getUTC(utcDate, utcTime);
-
2366 -
2367 return toMSecsSinceEpoch_helper(utcDate.toJulianDay(), QTime(0, 0, 0).msecsTo(utcTime));
executed: return toMSecsSinceEpoch_helper(utcDate.toJulianDay(), QTime(0, 0, 0).msecsTo(utcTime));
Execution Count:1792
1792
2368} -
2369 -
2370/*! -
2371 Returns the datetime as the number of seconds that have passed -
2372 since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC). -
2373 -
2374 On systems that do not support time zones, this function will -
2375 behave as if local time were Qt::UTC. -
2376 -
2377 \note This function returns a 32-bit unsigned integer, so it does not -
2378 support dates before 1970, but it does support dates after -
2379 2038-01-19T03:14:06, which may not be valid time_t values. Be careful -
2380 when passing those time_t values to system functions, which could -
2381 interpret them as negative dates. -
2382 -
2383 If the date is outside the range 1970-01-01T00:00:00 to -
2384 2106-02-07T06:28:14, this function returns -1 cast to an unsigned integer -
2385 (i.e., 0xFFFFFFFF). -
2386 -
2387 To get an extended range, use toMSecsSinceEpoch(). -
2388 -
2389 \sa toMSecsSinceEpoch(), setTime_t() -
2390*/ -
2391 -
2392uint QDateTime::toTime_t() const -
2393{ -
2394 qint64 retval = toMSecsSinceEpoch() / 1000;
executed (the execution status of this line is deduced): qint64 retval = toMSecsSinceEpoch() / 1000;
-
2395 if (quint64(retval) >= Q_UINT64_C(0xFFFFFFFF))
evaluated: quint64(retval) >= static_cast<unsigned long long>(0xFFFFFFFFULL)
TRUEFALSE
yes
Evaluation Count:1666
yes
Evaluation Count:92
92-1666
2396 return uint(-1);
executed: return uint(-1);
Execution Count:1666
1666
2397 return uint(retval);
executed: return uint(retval);
Execution Count:92
92
2398} -
2399 -
2400/*! -
2401 \since 4.7 -
2402 -
2403 Sets the date and time given the number of milliseconds \a msecs that have -
2404 passed since 1970-01-01T00:00:00.000, Coordinated Universal Time -
2405 (Qt::UTC). On systems that do not support time zones this function -
2406 will behave as if local time were Qt::UTC. -
2407 -
2408 Note that there are possible values for \a msecs that lie outside the -
2409 valid range of QDateTime, both negative and positive. The behavior of -
2410 this function is undefined for those values. -
2411 -
2412 \sa toMSecsSinceEpoch(), setTime_t() -
2413*/ -
2414void QDateTime::setMSecsSinceEpoch(qint64 msecs) -
2415{ -
2416 detach();
executed (the execution status of this line is deduced): detach();
-
2417 -
2418 QDateTimePrivate::Spec oldSpec = d->spec;
executed (the execution status of this line is deduced): QDateTimePrivate::Spec oldSpec = d->spec;
-
2419 -
2420 qint64 ddays = msecs / MSECS_PER_DAY;
executed (the execution status of this line is deduced): qint64 ddays = msecs / MSECS_PER_DAY;
-
2421 msecs %= MSECS_PER_DAY;
executed (the execution status of this line is deduced): msecs %= MSECS_PER_DAY;
-
2422 if (msecs < 0) {
evaluated: msecs < 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:18
6-18
2423 // negative -
2424 --ddays;
executed (the execution status of this line is deduced): --ddays;
-
2425 msecs += MSECS_PER_DAY;
executed (the execution status of this line is deduced): msecs += MSECS_PER_DAY;
-
2426 }
executed: }
Execution Count:6
6
2427 -
2428 d->date = QDate(1970, 1, 1).addDays(ddays);
executed (the execution status of this line is deduced): d->date = QDate(1970, 1, 1).addDays(ddays);
-
2429 d->time = QTime(0, 0, 0).addMSecs(msecs);
executed (the execution status of this line is deduced): d->time = QTime(0, 0, 0).addMSecs(msecs);
-
2430 d->spec = QDateTimePrivate::UTC;
executed (the execution status of this line is deduced): d->spec = QDateTimePrivate::UTC;
-
2431 -
2432 if (oldSpec != QDateTimePrivate::UTC)
evaluated: oldSpec != QDateTimePrivate::UTC
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:8
8-16
2433 d->spec = d->getLocal(d->date, d->time);
executed: d->spec = d->getLocal(d->date, d->time);
Execution Count:16
16
2434}
executed: }
Execution Count:24
24
2435 -
2436/*! -
2437 \fn void QDateTime::setTime_t(uint seconds) -
2438 -
2439 Sets the date and time given the number of \a seconds that have -
2440 passed since 1970-01-01T00:00:00, Coordinated Universal Time -
2441 (Qt::UTC). On systems that do not support time zones this function -
2442 will behave as if local time were Qt::UTC. -
2443 -
2444 \sa toTime_t() -
2445*/ -
2446 -
2447void QDateTime::setTime_t(uint secsSince1Jan1970UTC) -
2448{ -
2449 detach();
executed (the execution status of this line is deduced): detach();
-
2450 -
2451 QDateTimePrivate::Spec oldSpec = d->spec;
executed (the execution status of this line is deduced): QDateTimePrivate::Spec oldSpec = d->spec;
-
2452 -
2453 d->date = QDate(1970, 1, 1).addDays(secsSince1Jan1970UTC / SECS_PER_DAY);
executed (the execution status of this line is deduced): d->date = QDate(1970, 1, 1).addDays(secsSince1Jan1970UTC / SECS_PER_DAY);
-
2454 d->time = QTime(0, 0, 0).addSecs(secsSince1Jan1970UTC % SECS_PER_DAY);
executed (the execution status of this line is deduced): d->time = QTime(0, 0, 0).addSecs(secsSince1Jan1970UTC % SECS_PER_DAY);
-
2455 d->spec = QDateTimePrivate::UTC;
executed (the execution status of this line is deduced): d->spec = QDateTimePrivate::UTC;
-
2456 -
2457 if (oldSpec != QDateTimePrivate::UTC)
evaluated: oldSpec != QDateTimePrivate::UTC
TRUEFALSE
yes
Evaluation Count:5004
yes
Evaluation Count:5
5-5004
2458 d->spec = d->getLocal(d->date, d->time);
executed: d->spec = d->getLocal(d->date, d->time);
Execution Count:5004
5004
2459}
executed: }
Execution Count:5009
5009
2460 -
2461#ifndef QT_NO_DATESTRING -
2462/*! -
2463 \fn QString QDateTime::toString(Qt::DateFormat format) const -
2464 -
2465 \overload -
2466 -
2467 Returns the datetime as a string in the \a format given. -
2468 -
2469 If the \a format is Qt::TextDate, the string is formatted in -
2470 the default way. QDate::shortDayName(), QDate::shortMonthName(), -
2471 and QTime::toString() are used to generate the string, so the -
2472 day and month names will be localized names. An example of this -
2473 formatting is "Wed May 20 03:40:13 1998". -
2474 -
2475 If the \a format is Qt::ISODate, the string format corresponds -
2476 to the ISO 8601 extended specification for representations of -
2477 dates and times, taking the form YYYY-MM-DDTHH:MM:SS[Z|[+|-]HH:MM], -
2478 depending on the timeSpec() of the QDateTime. If the timeSpec() -
2479 is Qt::UTC, Z will be appended to the string; if the timeSpec() is -
2480 Qt::OffsetFromUTC, the offset in hours and minutes from UTC will -
2481 be appended to the string. -
2482 -
2483 If the \a format is Qt::SystemLocaleShortDate or -
2484 Qt::SystemLocaleLongDate, the string format depends on the locale -
2485 settings of the system. Identical to calling -
2486 QLocale::system().toString(datetime, QLocale::ShortFormat) or -
2487 QLocale::system().toString(datetime, QLocale::LongFormat). -
2488 -
2489 If the \a format is Qt::DefaultLocaleShortDate or -
2490 Qt::DefaultLocaleLongDate, the string format depends on the -
2491 default application locale. This is the locale set with -
2492 QLocale::setDefault(), or the system locale if no default locale -
2493 has been set. Identical to calling QLocale().toString(datetime, -
2494 QLocale::ShortFormat) or QLocale().toString(datetime, -
2495 QLocale::LongFormat). -
2496 -
2497 If the datetime is invalid, an empty string will be returned. -
2498 -
2499 \warning The Qt::ISODate format is only valid for years in the -
2500 range 0 to 9999. This restriction may apply to locale-aware -
2501 formats as well, depending on the locale settings. -
2502 -
2503 \sa QDate::toString(), QTime::toString(), Qt::DateFormat -
2504*/ -
2505 -
2506QString QDateTime::toString(Qt::DateFormat f) const -
2507{ -
2508 QString buf;
executed (the execution status of this line is deduced): QString buf;
-
2509 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1731
1-1731
2510 return buf;
executed: return buf;
Execution Count:1
1
2511 -
2512 if (f == Qt::ISODate) {
evaluated: f == Qt::ISODate
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:1705
26-1705
2513 buf = d->date.toString(Qt::ISODate);
executed (the execution status of this line is deduced): buf = d->date.toString(Qt::ISODate);
-
2514 if (buf.isEmpty())
evaluated: buf.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:25
1-25
2515 return QString(); // failed to convert
executed: return QString();
Execution Count:1
1
2516 buf += QLatin1Char('T');
executed (the execution status of this line is deduced): buf += QLatin1Char('T');
-
2517 buf += d->time.toString(Qt::ISODate);
executed (the execution status of this line is deduced): buf += d->time.toString(Qt::ISODate);
-
2518 switch (d->spec) { -
2519 case QDateTimePrivate::UTC: -
2520 buf += QLatin1Char('Z');
executed (the execution status of this line is deduced): buf += QLatin1Char('Z');
-
2521 break;
executed: break;
Execution Count:9
9
2522 case QDateTimePrivate::OffsetFromUTC: { -
2523 int sign = d->utcOffset >= 0 ? 1: -1;
evaluated: d->utcOffset >= 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
2524 buf += QString::fromLatin1("%1%2:%3").
executed (the execution status of this line is deduced): buf += QString::fromLatin1("%1%2:%3").
-
2525 arg(sign == 1 ? QLatin1Char('+') : QLatin1Char('-')).
executed (the execution status of this line is deduced): arg(sign == 1 ? QLatin1Char('+') : QLatin1Char('-')).
-
2526 arg(d->utcOffset * sign / SECS_PER_HOUR, 2, 10, QLatin1Char('0')).
executed (the execution status of this line is deduced): arg(d->utcOffset * sign / SECS_PER_HOUR, 2, 10, QLatin1Char('0')).
-
2527 arg((d->utcOffset / 60) % 60, 2, 10, QLatin1Char('0'));
executed (the execution status of this line is deduced): arg((d->utcOffset / 60) % 60, 2, 10, QLatin1Char('0'));
-
2528 break;
executed: break;
Execution Count:2
2
2529 } -
2530 default: -
2531 break;
executed: break;
Execution Count:14
14
2532 } -
2533 }
executed: }
Execution Count:25
25
2534#ifndef QT_NO_TEXTDATE -
2535 else if (f == Qt::TextDate) {
evaluated: f == Qt::TextDate
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:1648
57-1648
2536#ifndef Q_OS_WIN -
2537 buf = d->date.shortDayName(d->date.dayOfWeek());
executed (the execution status of this line is deduced): buf = d->date.shortDayName(d->date.dayOfWeek());
-
2538 buf += QLatin1Char(' ');
executed (the execution status of this line is deduced): buf += QLatin1Char(' ');
-
2539 buf += d->date.shortMonthName(d->date.month());
executed (the execution status of this line is deduced): buf += d->date.shortMonthName(d->date.month());
-
2540 buf += QLatin1Char(' ');
executed (the execution status of this line is deduced): buf += QLatin1Char(' ');
-
2541 buf += QString::number(d->date.day());
executed (the execution status of this line is deduced): buf += QString::number(d->date.day());
-
2542#else -
2543 wchar_t out[255]; -
2544 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILDATE, out, 255); -
2545 QString winstr = QString::fromWCharArray(out); -
2546 switch (winstr.toInt()) { -
2547 case 1: -
2548 buf = d->date.shortDayName(d->date.dayOfWeek()); -
2549 buf += QLatin1Char(' '); -
2550 buf += QString::number(d->date.day()); -
2551 buf += QLatin1String(". "); -
2552 buf += d->date.shortMonthName(d->date.month()); -
2553 break; -
2554 default: -
2555 buf = d->date.shortDayName(d->date.dayOfWeek()); -
2556 buf += QLatin1Char(' '); -
2557 buf += d->date.shortMonthName(d->date.month()); -
2558 buf += QLatin1Char(' '); -
2559 buf += QString::number(d->date.day()); -
2560 } -
2561#endif -
2562 buf += QLatin1Char(' ');
executed (the execution status of this line is deduced): buf += QLatin1Char(' ');
-
2563 buf += d->time.toString();
executed (the execution status of this line is deduced): buf += d->time.toString();
-
2564 buf += QLatin1Char(' ');
executed (the execution status of this line is deduced): buf += QLatin1Char(' ');
-
2565 buf += QString::number(d->date.year());
executed (the execution status of this line is deduced): buf += QString::number(d->date.year());
-
2566 }
executed: }
Execution Count:57
57
2567#endif -
2568 else { -
2569 buf = d->date.toString(f);
executed (the execution status of this line is deduced): buf = d->date.toString(f);
-
2570 if (buf.isEmpty())
partially evaluated: buf.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1648
0-1648
2571 return QString(); // failed to convert
never executed: return QString();
0
2572 buf += QLatin1Char(' ');
executed (the execution status of this line is deduced): buf += QLatin1Char(' ');
-
2573 buf += d->time.toString(f);
executed (the execution status of this line is deduced): buf += d->time.toString(f);
-
2574 }
executed: }
Execution Count:1648
1648
2575 -
2576 return buf;
executed: return buf;
Execution Count:1730
1730
2577} -
2578 -
2579/*! -
2580 Returns the datetime as a string. The \a format parameter -
2581 determines the format of the result string. -
2582 -
2583 These expressions may be used for the date: -
2584 -
2585 \table -
2586 \header \li Expression \li Output -
2587 \row \li d \li the day as number without a leading zero (1 to 31) -
2588 \row \li dd \li the day as number with a leading zero (01 to 31) -
2589 \row \li ddd -
2590 \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). -
2591 Uses QDate::shortDayName(). -
2592 \row \li dddd -
2593 \li the long localized day name (e.g. 'Monday' to 'Qt::Sunday'). -
2594 Uses QDate::longDayName(). -
2595 \row \li M \li the month as number without a leading zero (1-12) -
2596 \row \li MM \li the month as number with a leading zero (01-12) -
2597 \row \li MMM -
2598 \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). -
2599 Uses QDate::shortMonthName(). -
2600 \row \li MMMM -
2601 \li the long localized month name (e.g. 'January' to 'December'). -
2602 Uses QDate::longMonthName(). -
2603 \row \li yy \li the year as two digit number (00-99) -
2604 \row \li yyyy \li the year as four digit number -
2605 \endtable -
2606 -
2607 These expressions may be used for the time: -
2608 -
2609 \table -
2610 \header \li Expression \li Output -
2611 \row \li h -
2612 \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) -
2613 \row \li hh -
2614 \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) -
2615 \row \li m \li the minute without a leading zero (0 to 59) -
2616 \row \li mm \li the minute with a leading zero (00 to 59) -
2617 \row \li s \li the second without a leading zero (0 to 59) -
2618 \row \li ss \li the second with a leading zero (00 to 59) -
2619 \row \li z \li the milliseconds without leading zeroes (0 to 999) -
2620 \row \li zzz \li the milliseconds with leading zeroes (000 to 999) -
2621 \row \li AP -
2622 \li use AM/PM display. \e AP will be replaced by either "AM" or "PM". -
2623 \row \li ap -
2624 \li use am/pm display. \e ap will be replaced by either "am" or "pm". -
2625 \endtable -
2626 -
2627 All other input characters will be ignored. Any sequence of characters that -
2628 are enclosed in single quotes will be treated as text and not be used as an -
2629 expression. Two consecutive single quotes ("''") are replaced by a singlequote -
2630 in the output. Formats without separators (e.g. "HHmm") are currently not supported. -
2631 -
2632 Example format strings (assumed that the QDateTime is 21 May 2001 -
2633 14:13:09): -
2634 -
2635 \table -
2636 \header \li Format \li Result -
2637 \row \li dd.MM.yyyy \li 21.05.2001 -
2638 \row \li ddd MMMM d yy \li Tue May 21 01 -
2639 \row \li hh:mm:ss.zzz \li 14:13:09.042 -
2640 \row \li h:m:s ap \li 2:13:9 pm -
2641 \endtable -
2642 -
2643 If the datetime is invalid, an empty string will be returned. -
2644 -
2645 \sa QDate::toString(), QTime::toString() -
2646*/ -
2647QString QDateTime::toString(const QString& format) const -
2648{ -
2649 return fmtDateTime(format, &d->time, &d->date);
executed: return fmtDateTime(format, &d->time, &d->date);
Execution Count:1353
1353
2650} -
2651#endif //QT_NO_DATESTRING -
2652 -
2653/*! -
2654 Returns a QDateTime object containing a datetime \a ndays days -
2655 later than the datetime of this object (or earlier if \a ndays is -
2656 negative). -
2657 -
2658 \sa daysTo(), addMonths(), addYears(), addSecs() -
2659*/ -
2660 -
2661QDateTime QDateTime::addDays(qint64 ndays) const -
2662{ -
2663 return QDateTime(d->date.addDays(ndays), d->time, timeSpec());
executed: return QDateTime(d->date.addDays(ndays), d->time, timeSpec());
Execution Count:6263
6263
2664} -
2665 -
2666/*! -
2667 Returns a QDateTime object containing a datetime \a nmonths months -
2668 later than the datetime of this object (or earlier if \a nmonths -
2669 is negative). -
2670 -
2671 \sa daysTo(), addDays(), addYears(), addSecs() -
2672*/ -
2673 -
2674QDateTime QDateTime::addMonths(int nmonths) const -
2675{ -
2676 return QDateTime(d->date.addMonths(nmonths), d->time, timeSpec());
executed: return QDateTime(d->date.addMonths(nmonths), d->time, timeSpec());
Execution Count:70
70
2677} -
2678 -
2679/*! -
2680 Returns a QDateTime object containing a datetime \a nyears years -
2681 later than the datetime of this object (or earlier if \a nyears is -
2682 negative). -
2683 -
2684 \sa daysTo(), addDays(), addMonths(), addSecs() -
2685*/ -
2686 -
2687QDateTime QDateTime::addYears(int nyears) const -
2688{ -
2689 return QDateTime(d->date.addYears(nyears), d->time, timeSpec());
executed: return QDateTime(d->date.addYears(nyears), d->time, timeSpec());
Execution Count:57
57
2690} -
2691 -
2692QDateTime QDateTimePrivate::addMSecs(const QDateTime &dt, qint64 msecs) -
2693{ -
2694 if (!dt.isValid())
evaluated: !dt.isValid()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2148
5-2148
2695 return QDateTime();
executed: return QDateTime();
Execution Count:5
5
2696 -
2697 QDate utcDate;
executed (the execution status of this line is deduced): QDate utcDate;
-
2698 QTime utcTime;
executed (the execution status of this line is deduced): QTime utcTime;
-
2699 dt.d->getUTC(utcDate, utcTime);
executed (the execution status of this line is deduced): dt.d->getUTC(utcDate, utcTime);
-
2700 -
2701 addMSecs(utcDate, utcTime, msecs);
executed (the execution status of this line is deduced): addMSecs(utcDate, utcTime, msecs);
-
2702 -
2703 return QDateTime(utcDate, utcTime, Qt::UTC).toTimeSpec(dt.timeSpec());
executed: return QDateTime(utcDate, utcTime, Qt::UTC).toTimeSpec(dt.timeSpec());
Execution Count:2148
2148
2704} -
2705 -
2706/*! -
2707 Adds \a msecs to utcDate and \a utcTime as appropriate. It is assumed that -
2708 utcDate and utcTime are adjusted to UTC. -
2709 -
2710 \since 4.5 -
2711 \internal -
2712 */ -
2713void QDateTimePrivate::addMSecs(QDate &utcDate, QTime &utcTime, qint64 msecs) -
2714{ -
2715 qint64 dd = utcDate.toJulianDay();
executed (the execution status of this line is deduced): qint64 dd = utcDate.toJulianDay();
-
2716 int tt = QTime(0, 0, 0).msecsTo(utcTime);
executed (the execution status of this line is deduced): int tt = QTime(0, 0, 0).msecsTo(utcTime);
-
2717 int sign = 1;
executed (the execution status of this line is deduced): int sign = 1;
-
2718 if (msecs < 0) {
evaluated: msecs < 0
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:2095
84-2095
2719 msecs = -msecs;
executed (the execution status of this line is deduced): msecs = -msecs;
-
2720 sign = -1;
executed (the execution status of this line is deduced): sign = -1;
-
2721 }
executed: }
Execution Count:84
84
2722 if (msecs >= int(MSECS_PER_DAY)) {
evaluated: msecs >= int(MSECS_PER_DAY)
TRUEFALSE
yes
Evaluation Count:89
yes
Evaluation Count:2090
89-2090
2723 dd += sign * (msecs / MSECS_PER_DAY);
executed (the execution status of this line is deduced): dd += sign * (msecs / MSECS_PER_DAY);
-
2724 msecs %= MSECS_PER_DAY;
executed (the execution status of this line is deduced): msecs %= MSECS_PER_DAY;
-
2725 }
executed: }
Execution Count:89
89
2726 -
2727 tt += sign * msecs;
executed (the execution status of this line is deduced): tt += sign * msecs;
-
2728 if (tt < 0) {
evaluated: tt < 0
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:2164
15-2164
2729 tt = MSECS_PER_DAY - tt - 1;
executed (the execution status of this line is deduced): tt = MSECS_PER_DAY - tt - 1;
-
2730 dd -= tt / MSECS_PER_DAY;
executed (the execution status of this line is deduced): dd -= tt / MSECS_PER_DAY;
-
2731 tt = tt % MSECS_PER_DAY;
executed (the execution status of this line is deduced): tt = tt % MSECS_PER_DAY;
-
2732 tt = MSECS_PER_DAY - tt - 1;
executed (the execution status of this line is deduced): tt = MSECS_PER_DAY - tt - 1;
-
2733 } else if (tt >= int(MSECS_PER_DAY)) {
executed: }
Execution Count:15
evaluated: tt >= int(MSECS_PER_DAY)
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:2147
15-2147
2734 dd += tt / MSECS_PER_DAY;
executed (the execution status of this line is deduced): dd += tt / MSECS_PER_DAY;
-
2735 tt = tt % MSECS_PER_DAY;
executed (the execution status of this line is deduced): tt = tt % MSECS_PER_DAY;
-
2736 }
executed: }
Execution Count:17
17
2737 -
2738 utcDate = QDate::fromJulianDay(dd);
executed (the execution status of this line is deduced): utcDate = QDate::fromJulianDay(dd);
-
2739 utcTime = QTime(0, 0, 0).addMSecs(tt);
executed (the execution status of this line is deduced): utcTime = QTime(0, 0, 0).addMSecs(tt);
-
2740}
executed: }
Execution Count:2179
2179
2741 -
2742/*! -
2743 Returns a QDateTime object containing a datetime \a s seconds -
2744 later than the datetime of this object (or earlier if \a s is -
2745 negative). -
2746 -
2747 If this datetime is invalid, an invalid datetime will be returned. -
2748 -
2749 \sa addMSecs(), secsTo(), addDays(), addMonths(), addYears() -
2750*/ -
2751 -
2752QDateTime QDateTime::addSecs(qint64 s) const -
2753{ -
2754 return d->addMSecs(*this, s * 1000);
executed: return d->addMSecs(*this, s * 1000);
Execution Count:2089
2089
2755} -
2756 -
2757/*! -
2758 Returns a QDateTime object containing a datetime \a msecs miliseconds -
2759 later than the datetime of this object (or earlier if \a msecs is -
2760 negative). -
2761 -
2762 If this datetime is invalid, an invalid datetime will be returned. -
2763 -
2764 \sa addSecs(), msecsTo(), addDays(), addMonths(), addYears() -
2765*/ -
2766QDateTime QDateTime::addMSecs(qint64 msecs) const -
2767{ -
2768 return d->addMSecs(*this, msecs);
executed: return d->addMSecs(*this, msecs);
Execution Count:64
64
2769} -
2770 -
2771/*! -
2772 Returns the number of days from this datetime to the \a other -
2773 datetime. The number of days is counted as the number of times -
2774 midnight is reached between this datetime to the \a other -
2775 datetime. This means that a 10 minute difference from 23:55 to -
2776 0:05 the next day counts as one day. -
2777 -
2778 If the \a other datetime is earlier than this datetime, -
2779 the value returned is negative. -
2780 -
2781 Example: -
2782 \snippet code/src_corelib_tools_qdatetime.cpp 15 -
2783 -
2784 \sa addDays(), secsTo(), msecsTo() -
2785*/ -
2786 -
2787qint64 QDateTime::daysTo(const QDateTime &other) const -
2788{ -
2789 return d->date.daysTo(other.d->date);
executed: return d->date.daysTo(other.d->date);
Execution Count:114
114
2790} -
2791 -
2792/*! -
2793 Returns the number of seconds from this datetime to the \a other -
2794 datetime. If the \a other datetime is earlier than this datetime, -
2795 the value returned is negative. -
2796 -
2797 Before performing the comparison, the two datetimes are converted -
2798 to Qt::UTC to ensure that the result is correct if one of the two -
2799 datetimes has daylight saving time (DST) and the other doesn't. -
2800 -
2801 Returns 0 if either datetime is invalid. -
2802 -
2803 Example: -
2804 \snippet code/src_corelib_tools_qdatetime.cpp 11 -
2805 -
2806 \sa addSecs(), daysTo(), QTime::secsTo() -
2807*/ -
2808 -
2809qint64 QDateTime::secsTo(const QDateTime &other) const -
2810{ -
2811 if (!isValid() || !other.isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5847
evaluated: !other.isValid()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5843
2-5847
2812 return 0;
executed: return 0;
Execution Count:6
6
2813 -
2814 QDate date1, date2;
executed (the execution status of this line is deduced): QDate date1, date2;
-
2815 QTime time1, time2;
executed (the execution status of this line is deduced): QTime time1, time2;
-
2816 -
2817 d->getUTC(date1, time1);
executed (the execution status of this line is deduced): d->getUTC(date1, time1);
-
2818 other.d->getUTC(date2, time2);
executed (the execution status of this line is deduced): other.d->getUTC(date2, time2);
-
2819 -
2820 return (date1.daysTo(date2) * SECS_PER_DAY) + time1.secsTo(time2);
executed: return (date1.daysTo(date2) * SECS_PER_DAY) + time1.secsTo(time2);
Execution Count:5843
5843
2821} -
2822 -
2823/*! -
2824 Returns the number of milliseconds from this datetime to the \a other -
2825 datetime. If the \a other datetime is earlier than this datetime, -
2826 the value returned is negative. -
2827 -
2828 Before performing the comparison, the two datetimes are converted -
2829 to Qt::UTC to ensure that the result is correct if one of the two -
2830 datetimes has daylight saving time (DST) and the other doesn't. -
2831 -
2832 Returns 0 if either datetime is invalid. -
2833 -
2834 \sa addMSecs(), daysTo(), QTime::msecsTo() -
2835*/ -
2836 -
2837qint64 QDateTime::msecsTo(const QDateTime &other) const -
2838{ -
2839 if (!isValid() || !other.isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:45
partially evaluated: !other.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:45
0-45
2840 return 0;
executed: return 0;
Execution Count:2
2
2841 -
2842 QDate selfDate;
executed (the execution status of this line is deduced): QDate selfDate;
-
2843 QDate otherDate;
executed (the execution status of this line is deduced): QDate otherDate;
-
2844 QTime selfTime;
executed (the execution status of this line is deduced): QTime selfTime;
-
2845 QTime otherTime;
executed (the execution status of this line is deduced): QTime otherTime;
-
2846 -
2847 d->getUTC(selfDate, selfTime);
executed (the execution status of this line is deduced): d->getUTC(selfDate, selfTime);
-
2848 other.d->getUTC(otherDate, otherTime);
executed (the execution status of this line is deduced): other.d->getUTC(otherDate, otherTime);
-
2849 -
2850 return (static_cast<qint64>(selfDate.daysTo(otherDate)) * static_cast<qint64>(MSECS_PER_DAY))
executed: return (static_cast<qint64>(selfDate.daysTo(otherDate)) * static_cast<qint64>(MSECS_PER_DAY)) + static_cast<qint64>(selfTime.msecsTo(otherTime));
Execution Count:45
45
2851 + static_cast<qint64>(selfTime.msecsTo(otherTime));
executed: return (static_cast<qint64>(selfDate.daysTo(otherDate)) * static_cast<qint64>(MSECS_PER_DAY)) + static_cast<qint64>(selfTime.msecsTo(otherTime));
Execution Count:45
45
2852} -
2853 -
2854 -
2855/*! -
2856 \fn QDateTime QDateTime::toTimeSpec(Qt::TimeSpec specification) const -
2857 -
2858 Returns a copy of this datetime converted to the given time -
2859 \a specification. -
2860 -
2861 Example: -
2862 \snippet code/src_corelib_tools_qdatetime.cpp 16 -
2863 -
2864 \sa timeSpec(), toUTC(), toLocalTime() -
2865*/ -
2866 -
2867QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const -
2868{ -
2869 if ((d->spec == QDateTimePrivate::UTC) == (spec == Qt::UTC))
evaluated: (d->spec == QDateTimePrivate::UTC) == (spec == Qt::UTC)
TRUEFALSE
yes
Evaluation Count:14783
yes
Evaluation Count:2716
2716-14783
2870 return *this;
executed: return *this;
Execution Count:14783
14783
2871 -
2872 QDateTime ret;
executed (the execution status of this line is deduced): QDateTime ret;
-
2873 if (spec == Qt::UTC) {
evaluated: spec == Qt::UTC
TRUEFALSE
yes
Evaluation Count:1698
yes
Evaluation Count:1018
1018-1698
2874 d->getUTC(ret.d->date, ret.d->time);
executed (the execution status of this line is deduced): d->getUTC(ret.d->date, ret.d->time);
-
2875 ret.d->spec = QDateTimePrivate::UTC;
executed (the execution status of this line is deduced): ret.d->spec = QDateTimePrivate::UTC;
-
2876 } else {
executed: }
Execution Count:1698
1698
2877 ret.d->spec = d->getLocal(ret.d->date, ret.d->time);
executed (the execution status of this line is deduced): ret.d->spec = d->getLocal(ret.d->date, ret.d->time);
-
2878 }
executed: }
Execution Count:1018
1018
2879 return ret;
executed: return ret;
Execution Count:2716
2716
2880} -
2881 -
2882/*! -
2883 Returns true if this datetime is equal to the \a other datetime; -
2884 otherwise returns false. -
2885 -
2886 \sa operator!=() -
2887*/ -
2888 -
2889bool QDateTime::operator==(const QDateTime &other) const -
2890{ -
2891 if (d->spec == other.d->spec && d->utcOffset == other.d->utcOffset)
evaluated: d->spec == other.d->spec
TRUEFALSE
yes
Evaluation Count:46938
yes
Evaluation Count:322
evaluated: d->utcOffset == other.d->utcOffset
TRUEFALSE
yes
Evaluation Count:46934
yes
Evaluation Count:4
4-46938
2892 return d->time == other.d->time && d->date == other.d->date;
executed: return d->time == other.d->time && d->date == other.d->date;
Execution Count:46934
46934
2893 else { -
2894 QDate date1, date2;
executed (the execution status of this line is deduced): QDate date1, date2;
-
2895 QTime time1, time2;
executed (the execution status of this line is deduced): QTime time1, time2;
-
2896 -
2897 d->getUTC(date1, time1);
executed (the execution status of this line is deduced): d->getUTC(date1, time1);
-
2898 other.d->getUTC(date2, time2);
executed (the execution status of this line is deduced): other.d->getUTC(date2, time2);
-
2899 return time1 == time2 && date1 == date2;
executed: return time1 == time2 && date1 == date2;
Execution Count:326
326
2900 } -
2901} -
2902 -
2903/*! -
2904 \fn bool QDateTime::operator!=(const QDateTime &other) const -
2905 -
2906 Returns true if this datetime is different from the \a other -
2907 datetime; otherwise returns false. -
2908 -
2909 Two datetimes are different if either the date, the time, or the -
2910 time zone components are different. -
2911 -
2912 \sa operator==() -
2913*/ -
2914 -
2915/*! -
2916 Returns true if this datetime is earlier than the \a other -
2917 datetime; otherwise returns false. -
2918*/ -
2919 -
2920bool QDateTime::operator<(const QDateTime &other) const -
2921{ -
2922 if (d->spec == other.d->spec && d->spec != QDateTimePrivate::OffsetFromUTC) {
evaluated: d->spec == other.d->spec
TRUEFALSE
yes
Evaluation Count:29479
yes
Evaluation Count:2088
evaluated: d->spec != QDateTimePrivate::OffsetFromUTC
TRUEFALSE
yes
Evaluation Count:29477
yes
Evaluation Count:2
2-29479
2923 if (d->date != other.d->date)
evaluated: d->date != other.d->date
TRUEFALSE
yes
Evaluation Count:14029
yes
Evaluation Count:15448
14029-15448
2924 return d->date < other.d->date;
executed: return d->date < other.d->date;
Execution Count:14029
14029
2925 return d->time < other.d->time;
executed: return d->time < other.d->time;
Execution Count:15448
15448
2926 } else { -
2927 QDate date1, date2;
executed (the execution status of this line is deduced): QDate date1, date2;
-
2928 QTime time1, time2;
executed (the execution status of this line is deduced): QTime time1, time2;
-
2929 d->getUTC(date1, time1);
executed (the execution status of this line is deduced): d->getUTC(date1, time1);
-
2930 other.d->getUTC(date2, time2);
executed (the execution status of this line is deduced): other.d->getUTC(date2, time2);
-
2931 if (date1 != date2)
evaluated: date1 != date2
TRUEFALSE
yes
Evaluation Count:2065
yes
Evaluation Count:25
25-2065
2932 return date1 < date2;
executed: return date1 < date2;
Execution Count:2065
2065
2933 return time1 < time2;
executed: return time1 < time2;
Execution Count:25
25
2934 } -
2935} -
2936 -
2937/*! -
2938 \fn bool QDateTime::operator<=(const QDateTime &other) const -
2939 -
2940 Returns true if this datetime is earlier than or equal to the -
2941 \a other datetime; otherwise returns false. -
2942*/ -
2943 -
2944/*! -
2945 \fn bool QDateTime::operator>(const QDateTime &other) const -
2946 -
2947 Returns true if this datetime is later than the \a other datetime; -
2948 otherwise returns false. -
2949*/ -
2950 -
2951/*! -
2952 \fn bool QDateTime::operator>=(const QDateTime &other) const -
2953 -
2954 Returns true if this datetime is later than or equal to the -
2955 \a other datetime; otherwise returns false. -
2956*/ -
2957 -
2958/*! -
2959 \fn QDateTime QDateTime::currentDateTime() -
2960 Returns the current datetime, as reported by the system clock, in -
2961 the local time zone. -
2962 -
2963 \sa currentDateTimeUtc(), QDate::currentDate(), QTime::currentTime(), toTimeSpec() -
2964*/ -
2965 -
2966/*! -
2967 \fn QDateTime QDateTime::currentDateTimeUtc() -
2968 \since 4.7 -
2969 Returns the current datetime, as reported by the system clock, in -
2970 UTC. -
2971 -
2972 \sa currentDateTime(), QDate::currentDate(), QTime::currentTime(), toTimeSpec() -
2973*/ -
2974 -
2975/*! -
2976 \fn qint64 QDateTime::currentMSecsSinceEpoch() -
2977 \since 4.7 -
2978 -
2979 Returns the number of milliseconds since 1970-01-01T00:00:00 Universal -
2980 Coordinated Time. This number is like the POSIX time_t variable, but -
2981 expressed in milliseconds instead. -
2982 -
2983 \sa currentDateTime(), currentDateTimeUtc(), toTime_t(), toTimeSpec() -
2984*/ -
2985 -
2986static inline uint msecsFromDecomposed(int hour, int minute, int sec, int msec = 0) -
2987{ -
2988 return MSECS_PER_HOUR * hour + MSECS_PER_MIN * minute + 1000 * sec + msec;
executed: return MSECS_PER_HOUR * hour + MSECS_PER_MIN * minute + 1000 * sec + msec;
Execution Count:14036866
14036866
2989} -
2990 -
2991#if defined(Q_OS_WIN) -
2992QDate QDate::currentDate() -
2993{ -
2994 QDate d; -
2995 SYSTEMTIME st; -
2996 memset(&st, 0, sizeof(SYSTEMTIME)); -
2997 GetLocalTime(&st); -
2998 d.jd = julianDayFromDate(st.wYear, st.wMonth, st.wDay); -
2999 return d; -
3000} -
3001 -
3002QTime QTime::currentTime() -
3003{ -
3004 QTime ct; -
3005 SYSTEMTIME st; -
3006 memset(&st, 0, sizeof(SYSTEMTIME)); -
3007 GetLocalTime(&st); -
3008 ct.setHMS(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); -
3009#if defined(Q_OS_WINCE) -
3010 ct.startTick = GetTickCount() % MSECS_PER_DAY; -
3011#endif -
3012 return ct; -
3013} -
3014 -
3015QDateTime QDateTime::currentDateTime() -
3016{ -
3017 QDate d; -
3018 QTime t; -
3019 SYSTEMTIME st; -
3020 memset(&st, 0, sizeof(SYSTEMTIME)); -
3021 GetLocalTime(&st); -
3022 d.jd = julianDayFromDate(st.wYear, st.wMonth, st.wDay); -
3023 t.mds = msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); -
3024 return QDateTime(d, t); -
3025} -
3026 -
3027QDateTime QDateTime::currentDateTimeUtc() -
3028{ -
3029 QDate d; -
3030 QTime t; -
3031 SYSTEMTIME st; -
3032 memset(&st, 0, sizeof(SYSTEMTIME)); -
3033 GetSystemTime(&st); -
3034 d.jd = julianDayFromDate(st.wYear, st.wMonth, st.wDay); -
3035 t.mds = msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); -
3036 return QDateTime(d, t, Qt::UTC); -
3037} -
3038 -
3039qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW -
3040{ -
3041 QDate d; -
3042 QTime t; -
3043 SYSTEMTIME st; -
3044 memset(&st, 0, sizeof(SYSTEMTIME)); -
3045 GetSystemTime(&st); -
3046 -
3047 return msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds) + -
3048 qint64(julianDayFromDate(st.wYear, st.wMonth, st.wDay) -
3049 - julianDayFromDate(1970, 1, 1)) * Q_INT64_C(86400000); -
3050} -
3051 -
3052#elif defined(Q_OS_UNIX) -
3053QDate QDate::currentDate() -
3054{ -
3055 QDate d;
executed (the execution status of this line is deduced): QDate d;
-
3056 // posix compliant system -
3057 time_t ltime;
executed (the execution status of this line is deduced): time_t ltime;
-
3058 time(&ltime);
executed (the execution status of this line is deduced): time(&ltime);
-
3059 struct tm *t = 0;
executed (the execution status of this line is deduced): struct tm *t = 0;
-
3060 -
3061#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) -
3062 // use the reentrant version of localtime() where available -
3063 tzset();
executed (the execution status of this line is deduced): tzset();
-
3064 struct tm res;
executed (the execution status of this line is deduced): struct tm res;
-
3065 t = localtime_r(&ltime, &res);
executed (the execution status of this line is deduced): t = localtime_r(&ltime, &res);
-
3066#else -
3067 t = localtime(&ltime); -
3068#endif // !QT_NO_THREAD && _POSIX_THREAD_SAFE_FUNCTIONS -
3069 -
3070 d.jd = julianDayFromDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday);
executed (the execution status of this line is deduced): d.jd = julianDayFromDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday);
-
3071 return d;
executed: return d;
Execution Count:74
74
3072} -
3073 -
3074QTime QTime::currentTime() -
3075{ -
3076 QTime ct;
executed (the execution status of this line is deduced): QTime ct;
-
3077 // posix compliant system -
3078 struct timeval tv;
executed (the execution status of this line is deduced): struct timeval tv;
-
3079 gettimeofday(&tv, 0);
executed (the execution status of this line is deduced): gettimeofday(&tv, 0);
-
3080 time_t ltime = tv.tv_sec;
executed (the execution status of this line is deduced): time_t ltime = tv.tv_sec;
-
3081 struct tm *t = 0;
executed (the execution status of this line is deduced): struct tm *t = 0;
-
3082 -
3083#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) -
3084 // use the reentrant version of localtime() where available -
3085 tzset();
executed (the execution status of this line is deduced): tzset();
-
3086 struct tm res;
executed (the execution status of this line is deduced): struct tm res;
-
3087 t = localtime_r(&ltime, &res);
executed (the execution status of this line is deduced): t = localtime_r(&ltime, &res);
-
3088#else -
3089 t = localtime(&ltime); -
3090#endif -
3091 Q_CHECK_PTR(t);
never executed: qBadAlloc();
executed: }
Execution Count:14027095
partially evaluated: !(t)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14027065
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14027133
0-14027133
3092 -
3093 ct.mds = msecsFromDecomposed(t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec / 1000);
executed (the execution status of this line is deduced): ct.mds = msecsFromDecomposed(t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec / 1000);
-
3094 return ct;
executed: return ct;
Execution Count:14027143
14027143
3095} -
3096 -
3097QDateTime QDateTime::currentDateTime() -
3098{ -
3099 // posix compliant system -
3100 // we have milliseconds -
3101 struct timeval tv;
executed (the execution status of this line is deduced): struct timeval tv;
-
3102 gettimeofday(&tv, 0);
executed (the execution status of this line is deduced): gettimeofday(&tv, 0);
-
3103 time_t ltime = tv.tv_sec;
executed (the execution status of this line is deduced): time_t ltime = tv.tv_sec;
-
3104 struct tm *t = 0;
executed (the execution status of this line is deduced): struct tm *t = 0;
-
3105 -
3106#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) -
3107 // use the reentrant version of localtime() where available -
3108 tzset();
executed (the execution status of this line is deduced): tzset();
-
3109 struct tm res;
executed (the execution status of this line is deduced): struct tm res;
-
3110 t = localtime_r(&ltime, &res);
executed (the execution status of this line is deduced): t = localtime_r(&ltime, &res);
-
3111#else -
3112 t = localtime(&ltime); -
3113#endif -
3114 -
3115 QDateTime dt;
executed (the execution status of this line is deduced): QDateTime dt;
-
3116 dt.d->time.mds = msecsFromDecomposed(t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec / 1000);
executed (the execution status of this line is deduced): dt.d->time.mds = msecsFromDecomposed(t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec / 1000);
-
3117 -
3118 dt.d->date.jd = julianDayFromDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday);
executed (the execution status of this line is deduced): dt.d->date.jd = julianDayFromDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday);
-
3119 dt.d->spec = t->tm_isdst > 0 ? QDateTimePrivate::LocalDST :
evaluated: t->tm_isdst > 0
TRUEFALSE
yes
Evaluation Count:9756
yes
Evaluation Count:9
9-9756
3120 t->tm_isdst == 0 ? QDateTimePrivate::LocalStandard :
executed (the execution status of this line is deduced): t->tm_isdst == 0 ? QDateTimePrivate::LocalStandard :
-
3121 QDateTimePrivate::LocalUnknown;
executed (the execution status of this line is deduced): QDateTimePrivate::LocalUnknown;
-
3122 return dt;
executed: return dt;
Execution Count:9765
9765
3123} -
3124 -
3125QDateTime QDateTime::currentDateTimeUtc() -
3126{ -
3127 // posix compliant system -
3128 // we have milliseconds -
3129 struct timeval tv;
executed (the execution status of this line is deduced): struct timeval tv;
-
3130 gettimeofday(&tv, 0);
executed (the execution status of this line is deduced): gettimeofday(&tv, 0);
-
3131 time_t ltime = tv.tv_sec;
executed (the execution status of this line is deduced): time_t ltime = tv.tv_sec;
-
3132 struct tm *t = 0;
executed (the execution status of this line is deduced): struct tm *t = 0;
-
3133 -
3134#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) -
3135 // use the reentrant version of localtime() where available -
3136 struct tm res;
executed (the execution status of this line is deduced): struct tm res;
-
3137 t = gmtime_r(&ltime, &res);
executed (the execution status of this line is deduced): t = gmtime_r(&ltime, &res);
-
3138#else -
3139 t = gmtime(&ltime); -
3140#endif -
3141 -
3142 QDateTime dt;
executed (the execution status of this line is deduced): QDateTime dt;
-
3143 dt.d->time.mds = msecsFromDecomposed(t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec / 1000);
executed (the execution status of this line is deduced): dt.d->time.mds = msecsFromDecomposed(t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec / 1000);
-
3144 -
3145 dt.d->date.jd = julianDayFromDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday);
executed (the execution status of this line is deduced): dt.d->date.jd = julianDayFromDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday);
-
3146 dt.d->spec = QDateTimePrivate::UTC;
executed (the execution status of this line is deduced): dt.d->spec = QDateTimePrivate::UTC;
-
3147 return dt;
executed: return dt;
Execution Count:4
4
3148} -
3149 -
3150qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW -
3151{ -
3152 // posix compliant system -
3153 // we have milliseconds -
3154 struct timeval tv;
executed (the execution status of this line is deduced): struct timeval tv;
-
3155 gettimeofday(&tv, 0);
executed (the execution status of this line is deduced): gettimeofday(&tv, 0);
-
3156 return qint64(tv.tv_sec) * Q_INT64_C(1000) + tv.tv_usec / 1000;
executed: return qint64(tv.tv_sec) * static_cast<long long>(1000LL) + tv.tv_usec / 1000;
Execution Count:1
1
3157} -
3158 -
3159#else -
3160#error "What system is this?" -
3161#endif -
3162 -
3163/*! -
3164 \since 4.2 -
3165 -
3166 Returns a datetime whose date and time are the number of \a seconds -
3167 that have passed since 1970-01-01T00:00:00, Coordinated Universal -
3168 Time (Qt::UTC). On systems that do not support time zones, the time -
3169 will be set as if local time were Qt::UTC. -
3170 -
3171 \sa toTime_t(), setTime_t() -
3172*/ -
3173QDateTime QDateTime::fromTime_t(uint seconds) -
3174{ -
3175 QDateTime d;
executed (the execution status of this line is deduced): QDateTime d;
-
3176 d.setTime_t(seconds);
executed (the execution status of this line is deduced): d.setTime_t(seconds);
-
3177 return d;
executed: return d;
Execution Count:4991
4991
3178} -
3179 -
3180/*! -
3181 \since 4.7 -
3182 -
3183 Returns a datetime whose date and time are the number of milliseconds, \a msecs, -
3184 that have passed since 1970-01-01T00:00:00.000, Coordinated Universal -
3185 Time (Qt::UTC). On systems that do not support time zones, the time -
3186 will be set as if local time were Qt::UTC. -
3187 -
3188 Note that there are possible values for \a msecs that lie outside the valid -
3189 range of QDateTime, both negative and positive. The behavior of this -
3190 function is undefined for those values. -
3191 -
3192 \sa toTime_t(), setTime_t() -
3193*/ -
3194QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs) -
3195{ -
3196 QDateTime d;
executed (the execution status of this line is deduced): QDateTime d;
-
3197 d.setMSecsSinceEpoch(msecs);
executed (the execution status of this line is deduced): d.setMSecsSinceEpoch(msecs);
-
3198 return d;
executed: return d;
Execution Count:8
8
3199} -
3200 -
3201/*! -
3202 \since 4.4 -
3203 \internal -
3204 -
3205 Sets the offset from UTC to \a seconds, and also sets timeSpec() to -
3206 Qt::OffsetFromUTC. -
3207 -
3208 The maximum and minimum offset is 14 positive or negative hours. If -
3209 \a seconds is larger or smaller than that, the result is undefined. -
3210 -
3211 0 as offset is identical to UTC. Therefore, if \a seconds is 0, the -
3212 timeSpec() will be set to Qt::UTC. Hence the UTC offset always -
3213 relates to UTC, and can never relate to local time. -
3214 -
3215 \sa isValid(), utcOffset() -
3216 */ -
3217void QDateTime::setUtcOffset(int seconds) -
3218{ -
3219 detach();
executed (the execution status of this line is deduced): detach();
-
3220 -
3221 /* The motivation to also setting d->spec is to ensure that the QDateTime -
3222 * instance stays in well-defined states all the time; instead of that, -
3223 * we instruct the user to ensure it. */ -
3224 if(seconds == 0)
evaluated: seconds == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:15
1-15
3225 d->spec = QDateTimePrivate::UTC;
executed: d->spec = QDateTimePrivate::UTC;
Execution Count:1
1
3226 else -
3227 d->spec = QDateTimePrivate::OffsetFromUTC;
executed: d->spec = QDateTimePrivate::OffsetFromUTC;
Execution Count:15
15
3228 -
3229 /* Even if seconds is 0 we assign it to utcOffset. */ -
3230 d->utcOffset = seconds;
executed (the execution status of this line is deduced): d->utcOffset = seconds;
-
3231}
executed: }
Execution Count:16
16
3232 -
3233/*! -
3234 \since 4.4 -
3235 \internal -
3236 -
3237 Returns the UTC offset in seconds. If the timeSpec() isn't -
3238 Qt::OffsetFromUTC, 0 is returned. However, since 0 is a valid UTC -
3239 offset, the return value of this function cannot be used to determine -
3240 whether a utcOffset() is used or is valid; in that case, timeSpec() must be -
3241 checked. -
3242 -
3243 Likewise, if this QDateTime() is invalid or if timeSpec() isn't -
3244 Qt::OffsetFromUTC, 0 is returned. -
3245 -
3246 The UTC offset only applies if the timeSpec() is Qt::OffsetFromUTC. -
3247 -
3248 \sa isValid(), setUtcOffset() -
3249 */ -
3250int QDateTime::utcOffset() const -
3251{ -
3252 if(isValid() && d->spec == QDateTimePrivate::OffsetFromUTC)
evaluated: isValid()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:1
evaluated: d->spec == QDateTimePrivate::OffsetFromUTC
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
1-7
3253 return d->utcOffset;
executed: return d->utcOffset;
Execution Count:5
5
3254 else -
3255 return 0;
executed: return 0;
Execution Count:3
3
3256} -
3257 -
3258#ifndef QT_NO_DATESTRING -
3259 -
3260static int fromShortMonthName(const QString &monthName) -
3261{ -
3262 // Assume that English monthnames are the default -
3263 for (int i = 0; i < 12; ++i) {
evaluated: i < 12
TRUEFALSE
yes
Evaluation Count:254
yes
Evaluation Count:15
15-254
3264 if (monthName == QLatin1String(qt_shortMonthNames[i]))
evaluated: monthName == QLatin1String(qt_shortMonthNames[i])
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:220
34-220
3265 return i + 1;
executed: return i + 1;
Execution Count:34
34
3266 }
executed: }
Execution Count:220
220
3267 // If English names can't be found, search the localized ones -
3268 for (int i = 1; i <= 12; ++i) {
evaluated: i <= 12
TRUEFALSE
yes
Evaluation Count:180
yes
Evaluation Count:15
15-180
3269 if (monthName == QDate::shortMonthName(i))
partially evaluated: monthName == QDate::shortMonthName(i)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:180
0-180
3270 return i;
never executed: return i;
0
3271 }
executed: }
Execution Count:180
180
3272 return -1;
executed: return -1;
Execution Count:15
15
3273} -
3274 -
3275/*! -
3276 \fn QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) -
3277 -
3278 Returns the QDateTime represented by the \a string, using the -
3279 \a format given, or an invalid datetime if this is not possible. -
3280 -
3281 Note for Qt::TextDate: It is recommended that you use the -
3282 English short month names (e.g. "Jan"). Although localized month -
3283 names can also be used, they depend on the user's locale settings. -
3284*/ -
3285QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) -
3286{ -
3287 if (s.isEmpty()) {
evaluated: s.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:98
2-98
3288 return QDateTime();
executed: return QDateTime();
Execution Count:2
2
3289 } -
3290 -
3291 switch (f) { -
3292 case Qt::ISODate: { -
3293 QString tmp = s;
executed (the execution status of this line is deduced): QString tmp = s;
-
3294 Qt::TimeSpec ts = Qt::LocalTime;
executed (the execution status of this line is deduced): Qt::TimeSpec ts = Qt::LocalTime;
-
3295 QDate date = QDate::fromString(tmp.left(10), Qt::ISODate);
executed (the execution status of this line is deduced): QDate date = QDate::fromString(tmp.left(10), Qt::ISODate);
-
3296 if (tmp.size() == 10)
evaluated: tmp.size() == 10
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:54
1-54
3297 return QDateTime(date);
executed: return QDateTime(date);
Execution Count:1
1
3298 -
3299 tmp = tmp.mid(11);
executed (the execution status of this line is deduced): tmp = tmp.mid(11);
-
3300 -
3301 // Recognize UTC specifications -
3302 if (tmp.endsWith(QLatin1Char('Z'))) {
evaluated: tmp.endsWith(QLatin1Char('Z'))
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:49
5-49
3303 ts = Qt::UTC;
executed (the execution status of this line is deduced): ts = Qt::UTC;
-
3304 tmp.chop(1);
executed (the execution status of this line is deduced): tmp.chop(1);
-
3305 }
executed: }
Execution Count:5
5
3306 -
3307 // Recognize timezone specifications -
3308 QRegExp rx(QLatin1String("[+-]"));
executed (the execution status of this line is deduced): QRegExp rx(QLatin1String("[+-]"));
-
3309 if (tmp.contains(rx)) {
evaluated: tmp.contains(rx)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:50
4-50
3310 int idx = tmp.indexOf(rx);
executed (the execution status of this line is deduced): int idx = tmp.indexOf(rx);
-
3311 QString tmp2 = tmp.mid(idx);
executed (the execution status of this line is deduced): QString tmp2 = tmp.mid(idx);
-
3312 tmp = tmp.left(idx);
executed (the execution status of this line is deduced): tmp = tmp.left(idx);
-
3313 bool ok = true;
executed (the execution status of this line is deduced): bool ok = true;
-
3314 int ntzhour = 1;
executed (the execution status of this line is deduced): int ntzhour = 1;
-
3315 int ntzminute = 3;
executed (the execution status of this line is deduced): int ntzminute = 3;
-
3316 if ( tmp2.indexOf(QLatin1Char(':')) == 3 )
evaluated: tmp2.indexOf(QLatin1Char(':')) == 3
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
3317 ntzminute = 4;
executed: ntzminute = 4;
Execution Count:3
3
3318 const int tzhour(tmp2.mid(ntzhour, 2).toInt(&ok));
executed (the execution status of this line is deduced): const int tzhour(tmp2.mid(ntzhour, 2).toInt(&ok));
-
3319 const int tzminute(tmp2.mid(ntzminute, 2).toInt(&ok));
executed (the execution status of this line is deduced): const int tzminute(tmp2.mid(ntzminute, 2).toInt(&ok));
-
3320 QTime tzt(tzhour, tzminute);
executed (the execution status of this line is deduced): QTime tzt(tzhour, tzminute);
-
3321 int utcOffset = (tzt.hour() * 60 + tzt.minute()) * 60;
executed (the execution status of this line is deduced): int utcOffset = (tzt.hour() * 60 + tzt.minute()) * 60;
-
3322 if ( utcOffset != 0 ) {
evaluated: utcOffset != 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
3323 ts = Qt::OffsetFromUTC;
executed (the execution status of this line is deduced): ts = Qt::OffsetFromUTC;
-
3324 QDateTime dt(date, QTime::fromString(tmp, Qt::ISODate), ts);
executed (the execution status of this line is deduced): QDateTime dt(date, QTime::fromString(tmp, Qt::ISODate), ts);
-
3325 dt.setUtcOffset( utcOffset * (tmp2.startsWith(QLatin1Char('-')) ? -1 : 1) );
executed (the execution status of this line is deduced): dt.setUtcOffset( utcOffset * (tmp2.startsWith(QLatin1Char('-')) ? -1 : 1) );
-
3326 return dt;
executed: return dt;
Execution Count:2
2
3327 } -
3328 }
executed: }
Execution Count:2
2
3329 -
3330 bool isMidnight24 = false;
executed (the execution status of this line is deduced): bool isMidnight24 = false;
-
3331 // Might be end of day (24:00, including variants), which QTime considers invalid. -
3332 QTime time(fromStringImpl(tmp, Qt::ISODate, isMidnight24));
executed (the execution status of this line is deduced): QTime time(fromStringImpl(tmp, Qt::ISODate, isMidnight24));
-
3333 if (isMidnight24) {
evaluated: isMidnight24
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:47
5-47
3334 // ISO 8601 (section 4.2.3) says that 24:00 is equivalent to 00:00 the next day. -
3335 date = date.addDays(1);
executed (the execution status of this line is deduced): date = date.addDays(1);
-
3336 }
executed: }
Execution Count:5
5
3337 -
3338 return QDateTime(date, time, ts);
executed: return QDateTime(date, time, ts);
Execution Count:52
52
3339 } -
3340 case Qt::SystemLocaleDate: -
3341 case Qt::SystemLocaleShortDate: -
3342 case Qt::SystemLocaleLongDate: -
3343 return fromString(s, QLocale::system().dateTimeFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat
executed: return fromString(s, QLocale::system().dateTimeFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
Execution Count:3
3
3344 : QLocale::ShortFormat));
executed: return fromString(s, QLocale::system().dateTimeFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
Execution Count:3
3
3345 case Qt::LocaleDate: -
3346 case Qt::DefaultLocaleShortDate: -
3347 case Qt::DefaultLocaleLongDate: -
3348 return fromString(s, QLocale().dateTimeFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat
executed: return fromString(s, QLocale().dateTimeFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
Execution Count:3
3
3349 : QLocale::ShortFormat));
executed: return fromString(s, QLocale().dateTimeFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
Execution Count:3
3
3350#if !defined(QT_NO_TEXTDATE) -
3351 case Qt::TextDate: { -
3352 QStringList parts = s.split(QLatin1Char(' '), QString::SkipEmptyParts);
executed (the execution status of this line is deduced): QStringList parts = s.split(QLatin1Char(' '), QString::SkipEmptyParts);
-
3353 -
3354 if ((parts.count() < 5) || (parts.count() > 6)) {
evaluated: (parts.count() < 5)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:36
evaluated: (parts.count() > 6)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:35
1-36
3355 return QDateTime();
executed: return QDateTime();
Execution Count:2
2
3356 } -
3357 -
3358 // Accept "Sun Dec 1 13:02:00 1974" and "Sun 1. Dec 13:02:00 1974" -
3359 int month = -1, day = -1;
executed (the execution status of this line is deduced): int month = -1, day = -1;
-
3360 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
3361 -
3362 month = fromShortMonthName(parts.at(1));
executed (the execution status of this line is deduced): month = fromShortMonthName(parts.at(1));
-
3363 if (month != -1) {
evaluated: month != -1
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:13
13-22
3364 day = parts.at(2).toInt(&ok);
executed (the execution status of this line is deduced): day = parts.at(2).toInt(&ok);
-
3365 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:21
1-21
3366 day = -1;
executed: day = -1;
Execution Count:1
1
3367 }
executed: }
Execution Count:22
22
3368 -
3369 if (month == -1 || day == -1) {
evaluated: month == -1
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:22
evaluated: day == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:21
1-22
3370 // first variant failed, lets try the other -
3371 month = fromShortMonthName(parts.at(2));
executed (the execution status of this line is deduced): month = fromShortMonthName(parts.at(2));
-
3372 if (month != -1) {
evaluated: month != -1
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:2
2-12
3373 QString dayStr = parts.at(1);
executed (the execution status of this line is deduced): QString dayStr = parts.at(1);
-
3374 if (dayStr.endsWith(QLatin1Char('.'))) {
evaluated: dayStr.endsWith(QLatin1Char('.'))
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1
1-11
3375 dayStr.chop(1);
executed (the execution status of this line is deduced): dayStr.chop(1);
-
3376 day = dayStr.toInt(&ok);
executed (the execution status of this line is deduced): day = dayStr.toInt(&ok);
-
3377 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-10
3378 day = -1;
executed: day = -1;
Execution Count:1
1
3379 } else {
executed: }
Execution Count:11
11
3380 day = -1;
executed (the execution status of this line is deduced): day = -1;
-
3381 }
executed: }
Execution Count:1
1
3382 } -
3383 }
executed: }
Execution Count:14
14
3384 -
3385 if (month == -1 || day == -1) {
evaluated: month == -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:33
evaluated: day == -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:31
2-33
3386 // both variants failed, give up -
3387 return QDateTime();
executed: return QDateTime();
Execution Count:4
4
3388 } -
3389 -
3390 int year;
executed (the execution status of this line is deduced): int year;
-
3391 QStringList timeParts = parts.at(3).split(QLatin1Char(':'));
executed (the execution status of this line is deduced): QStringList timeParts = parts.at(3).split(QLatin1Char(':'));
-
3392 if ((timeParts.count() == 3) || (timeParts.count() == 2)) {
evaluated: (timeParts.count() == 3)
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:14
evaluated: (timeParts.count() == 2)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-17
3393 // Year is after time, e.g. "Sun Dec 1 13:02:00 1974" -
3394 year = parts.at(4).toInt(&ok);
executed (the execution status of this line is deduced): year = parts.at(4).toInt(&ok);
-
3395 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:17
1-17
3396 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
3397 } else { // Year is before time, e.g. "Sun Dec 1 1974 13:02:00"
executed: }
Execution Count:17
17
3398 timeParts = parts.at(4).split(QLatin1Char(':'));
executed (the execution status of this line is deduced): timeParts = parts.at(4).split(QLatin1Char(':'));
-
3399 if ((timeParts.count() != 3) && (timeParts.count() != 2))
evaluated: (timeParts.count() != 3)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:11
partially evaluated: (timeParts.count() != 2)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-11
3400 return QDateTime();
executed: return QDateTime();
Execution Count:2
2
3401 year = parts.at(3).toInt(&ok);
executed (the execution status of this line is deduced): year = parts.at(3).toInt(&ok);
-
3402 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-10
3403 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
3404 }
executed: }
Execution Count:10
10
3405 -
3406 int hour = timeParts.at(0).toInt(&ok);
executed (the execution status of this line is deduced): int hour = timeParts.at(0).toInt(&ok);
-
3407 if (!ok) {
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:26
1-26
3408 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
3409 } -
3410 -
3411 int minute = timeParts.at(1).toInt(&ok);
executed (the execution status of this line is deduced): int minute = timeParts.at(1).toInt(&ok);
-
3412 if (!ok) {
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:25
1-25
3413 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
3414 } -
3415 -
3416 int second = (timeParts.count() > 2) ? timeParts.at(2).toInt(&ok) : 0;
evaluated: (timeParts.count() > 2)
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:1
1-24
3417 if (!ok) {
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:24
1-24
3418 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
3419 } -
3420 -
3421 QDate date(year, month, day);
executed (the execution status of this line is deduced): QDate date(year, month, day);
-
3422 QTime time(hour, minute, second);
executed (the execution status of this line is deduced): QTime time(hour, minute, second);
-
3423 -
3424 if (parts.count() == 5)
evaluated: parts.count() == 5
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:10
10-14
3425 return QDateTime(date, time, Qt::LocalTime);
executed: return QDateTime(date, time, Qt::LocalTime);
Execution Count:14
14
3426 -
3427 QString tz = parts.at(5);
executed (the execution status of this line is deduced): QString tz = parts.at(5);
-
3428 if (!tz.startsWith(QLatin1String("GMT"), Qt::CaseInsensitive))
evaluated: !tz.startsWith(QLatin1String("GMT"), Qt::CaseInsensitive)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:9
1-9
3429 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
3430 QDateTime dt(date, time, Qt::UTC);
executed (the execution status of this line is deduced): QDateTime dt(date, time, Qt::UTC);
-
3431 if (tz.length() > 3) {
evaluated: tz.length() > 3
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:2
2-7
3432 int tzoffset = 0;
executed (the execution status of this line is deduced): int tzoffset = 0;
-
3433 QChar sign = tz.at(3);
executed (the execution status of this line is deduced): QChar sign = tz.at(3);
-
3434 if ((sign != QLatin1Char('+'))
evaluated: (sign != QLatin1Char('+'))
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
3435 && (sign != QLatin1Char('-'))) {
evaluated: (sign != QLatin1Char('-'))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
3436 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
3437 } -
3438 int tzhour = tz.mid(4, 2).toInt(&ok);
executed (the execution status of this line is deduced): int tzhour = tz.mid(4, 2).toInt(&ok);
-
3439 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
2-4
3440 return QDateTime();
executed: return QDateTime();
Execution Count:2
2
3441 int tzminute = tz.mid(6).toInt(&ok);
executed (the execution status of this line is deduced): int tzminute = tz.mid(6).toInt(&ok);
-
3442 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
3443 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
3444 tzoffset = (tzhour*60 + tzminute) * 60;
executed (the execution status of this line is deduced): tzoffset = (tzhour*60 + tzminute) * 60;
-
3445 if (sign == QLatin1Char('-'))
evaluated: sign == QLatin1Char('-')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
3446 tzoffset = -tzoffset;
executed: tzoffset = -tzoffset;
Execution Count:1
1
3447 dt.setUtcOffset(tzoffset);
executed (the execution status of this line is deduced): dt.setUtcOffset(tzoffset);
-
3448 }
executed: }
Execution Count:3
3
3449 return dt.toLocalTime();
executed: return dt.toLocalTime();
Execution Count:5
5
3450 } -
3451#endif //QT_NO_TEXTDATE -
3452 } -
3453 -
3454 return QDateTime();
never executed: return QDateTime();
0
3455} -
3456 -
3457/*! -
3458 \fn QDateTime::fromString(const QString &string, const QString &format) -
3459 -
3460 Returns the QDateTime represented by the \a string, using the \a -
3461 format given, or an invalid datetime if the string cannot be parsed. -
3462 -
3463 These expressions may be used for the date part of the format string: -
3464 -
3465 \table -
3466 \header \li Expression \li Output -
3467 \row \li d \li the day as number without a leading zero (1 to 31) -
3468 \row \li dd \li the day as number with a leading zero (01 to 31) -
3469 \row \li ddd -
3470 \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). -
3471 Uses QDate::shortDayName(). -
3472 \row \li dddd -
3473 \li the long localized day name (e.g. 'Monday' to 'Sunday'). -
3474 Uses QDate::longDayName(). -
3475 \row \li M \li the month as number without a leading zero (1-12) -
3476 \row \li MM \li the month as number with a leading zero (01-12) -
3477 \row \li MMM -
3478 \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). -
3479 Uses QDate::shortMonthName(). -
3480 \row \li MMMM -
3481 \li the long localized month name (e.g. 'January' to 'December'). -
3482 Uses QDate::longMonthName(). -
3483 \row \li yy \li the year as two digit number (00-99) -
3484 \row \li yyyy \li the year as four digit number -
3485 \endtable -
3486 -
3487 \note Unlike the other version of this function, day and month names must -
3488 be given in the user's local language. It is only possible to use the English -
3489 names if the user's language is English. -
3490 -
3491 These expressions may be used for the time part of the format string: -
3492 -
3493 \table -
3494 \header \li Expression \li Output -
3495 \row \li h -
3496 \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) -
3497 \row \li hh -
3498 \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) -
3499 \row \li H -
3500 \li the hour without a leading zero (0 to 23, even with AM/PM display) -
3501 \row \li HH -
3502 \li the hour with a leading zero (00 to 23, even with AM/PM display) -
3503 \row \li m \li the minute without a leading zero (0 to 59) -
3504 \row \li mm \li the minute with a leading zero (00 to 59) -
3505 \row \li s \li the second without a leading zero (0 to 59) -
3506 \row \li ss \li the second with a leading zero (00 to 59) -
3507 \row \li z \li the milliseconds without leading zeroes (0 to 999) -
3508 \row \li zzz \li the milliseconds with leading zeroes (000 to 999) -
3509 \row \li AP or A -
3510 \li interpret as an AM/PM time. \e AP must be either "AM" or "PM". -
3511 \row \li ap or a -
3512 \li Interpret as an AM/PM time. \e ap must be either "am" or "pm". -
3513 \endtable -
3514 -
3515 All other input characters will be treated as text. Any sequence -
3516 of characters that are enclosed in single quotes will also be -
3517 treated as text and not be used as an expression. -
3518 -
3519 \snippet code/src_corelib_tools_qdatetime.cpp 12 -
3520 -
3521 If the format is not satisfied, an invalid QDateTime is returned. -
3522 The expressions that don't have leading zeroes (d, M, h, m, s, z) will be -
3523 greedy. This means that they will use two digits even if this will -
3524 put them outside the range and/or leave too few digits for other -
3525 sections. -
3526 -
3527 \snippet code/src_corelib_tools_qdatetime.cpp 13 -
3528 -
3529 This could have meant 1 January 00:30.00 but the M will grab -
3530 two digits. -
3531 -
3532 Incorrectly specified fields of the \a string will cause an invalid -
3533 QDateTime to be returned. For example, consider the following code, -
3534 where the two digit year 12 is read as 1912 (see the table below for all -
3535 field defaults); the resulting datetime is invalid because 23 April 1912 -
3536 was a Tuesday, not a Monday: -
3537 -
3538 \snippet code/src_corelib_tools_qdatetime.cpp 20 -
3539 -
3540 The correct code is: -
3541 -
3542 \snippet code/src_corelib_tools_qdatetime.cpp 21 -
3543 -
3544 For any field that is not represented in the format, the following -
3545 defaults are used: -
3546 -
3547 \table -
3548 \header \li Field \li Default value -
3549 \row \li Year \li 1900 -
3550 \row \li Month \li 1 (January) -
3551 \row \li Day \li 1 -
3552 \row \li Hour \li 0 -
3553 \row \li Minute \li 0 -
3554 \row \li Second \li 0 -
3555 \endtable -
3556 -
3557 For example: -
3558 -
3559 \snippet code/src_corelib_tools_qdatetime.cpp 14 -
3560 -
3561 \sa QDate::fromString(), QTime::fromString(), QDate::toString(), -
3562 QDateTime::toString(), QTime::toString() -
3563*/ -
3564 -
3565QDateTime QDateTime::fromString(const QString &string, const QString &format) -
3566{ -
3567#ifndef QT_BOOTSTRAPPED -
3568 QTime time;
executed (the execution status of this line is deduced): QTime time;
-
3569 QDate date;
executed (the execution status of this line is deduced): QDate date;
-
3570 -
3571 QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString);
executed (the execution status of this line is deduced): QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString);
-
3572 if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
partially evaluated: dt.parseFormat(format)
TRUEFALSE
yes
Evaluation Count:47
no
Evaluation Count:0
evaluated: dt.fromString(string, &date, &time)
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:9
0-47
3573 return QDateTime(date, time);
executed: return QDateTime(date, time);
Execution Count:38
38
3574#else -
3575 Q_UNUSED(string); -
3576 Q_UNUSED(format); -
3577#endif -
3578 return QDateTime(QDate(), QTime(-1, -1, -1));
executed: return QDateTime(QDate(), QTime(-1, -1, -1));
Execution Count:9
9
3579} -
3580 -
3581#endif // QT_NO_DATESTRING -
3582/*! -
3583 \fn QDateTime QDateTime::toLocalTime() const -
3584 -
3585 Returns a datetime containing the date and time information in -
3586 this datetime, but specified using the Qt::LocalTime definition. -
3587 -
3588 Example: -
3589 -
3590 \snippet code/src_corelib_tools_qdatetime.cpp 17 -
3591 -
3592 \sa toTimeSpec() -
3593*/ -
3594 -
3595/*! -
3596 \fn QDateTime QDateTime::toUTC() const -
3597 -
3598 Returns a datetime containing the date and time information in -
3599 this datetime, but specified using the Qt::UTC definition. -
3600 -
3601 Example: -
3602 -
3603 \snippet code/src_corelib_tools_qdatetime.cpp 18 -
3604 -
3605 \sa toTimeSpec() -
3606*/ -
3607 -
3608/*! -
3609 \internal -
3610 */ -
3611void QDateTime::detach() -
3612{ -
3613 d.detach();
executed (the execution status of this line is deduced): d.detach();
-
3614}
executed: }
Execution Count:7153
7153
3615 -
3616/***************************************************************************** -
3617 Date/time stream functions -
3618 *****************************************************************************/ -
3619 -
3620#ifndef QT_NO_DATASTREAM -
3621/*! -
3622 \relates QDate -
3623 -
3624 Writes the \a date to stream \a out. -
3625 -
3626 \sa {Serializing Qt Data Types} -
3627*/ -
3628 -
3629QDataStream &operator<<(QDataStream &out, const QDate &date) -
3630{ -
3631 if (out.version() < QDataStream::Qt_5_0)
evaluated: out.version() < QDataStream::Qt_5_0
TRUEFALSE
yes
Evaluation Count:158
yes
Evaluation Count:387
158-387
3632 return out << quint32(date.jd);
executed: return out << quint32(date.jd);
Execution Count:158
158
3633 else -
3634 return out << qint64(date.jd);
executed: return out << qint64(date.jd);
Execution Count:387
387
3635} -
3636 -
3637/*! -
3638 \relates QDate -
3639 -
3640 Reads a date from stream \a in into the \a date. -
3641 -
3642 \sa {Serializing Qt Data Types} -
3643*/ -
3644 -
3645QDataStream &operator>>(QDataStream &in, QDate &date) -
3646{ -
3647 if (in.version() < QDataStream::Qt_5_0) {
evaluated: in.version() < QDataStream::Qt_5_0
TRUEFALSE
yes
Evaluation Count:160
yes
Evaluation Count:381
160-381
3648 quint32 jd;
executed (the execution status of this line is deduced): quint32 jd;
-
3649 in >> jd;
executed (the execution status of this line is deduced): in >> jd;
-
3650 // Older versions consider 0 an invalid jd. -
3651 date.jd = (jd != 0 ? jd : QDate::nullJd());
evaluated: jd != 0
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:16
16-144
3652 } else {
executed: }
Execution Count:160
160
3653 qint64 jd;
executed (the execution status of this line is deduced): qint64 jd;
-
3654 in >> jd;
executed (the execution status of this line is deduced): in >> jd;
-
3655 date.jd = jd;
executed (the execution status of this line is deduced): date.jd = jd;
-
3656 }
executed: }
Execution Count:381
381
3657 -
3658 return in;
executed: return in;
Execution Count:541
541
3659} -
3660 -
3661/*! -
3662 \relates QTime -
3663 -
3664 Writes \a time to stream \a out. -
3665 -
3666 \sa {Serializing Qt Data Types} -
3667*/ -
3668 -
3669QDataStream &operator<<(QDataStream &out, const QTime &time) -
3670{ -
3671 return out << quint32(time.mds);
executed: return out << quint32(time.mds);
Execution Count:744
744
3672} -
3673 -
3674/*! -
3675 \relates QTime -
3676 -
3677 Reads a time from stream \a in into the given \a time. -
3678 -
3679 \sa {Serializing Qt Data Types} -
3680*/ -
3681 -
3682QDataStream &operator>>(QDataStream &in, QTime &time) -
3683{ -
3684 quint32 ds;
executed (the execution status of this line is deduced): quint32 ds;
-
3685 in >> ds;
executed (the execution status of this line is deduced): in >> ds;
-
3686 time.mds = int(ds);
executed (the execution status of this line is deduced): time.mds = int(ds);
-
3687 return in;
executed: return in;
Execution Count:740
740
3688} -
3689 -
3690/*! -
3691 \relates QDateTime -
3692 -
3693 Writes \a dateTime to the \a out stream. -
3694 -
3695 \sa {Serializing Qt Data Types} -
3696*/ -
3697QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime) -
3698{ -
3699 if (out.version() >= 13) {
evaluated: out.version() >= 13
TRUEFALSE
yes
Evaluation Count:282
yes
Evaluation Count:97
97-282
3700 if (dateTime.isValid()) {
evaluated: dateTime.isValid()
TRUEFALSE
yes
Evaluation Count:170
yes
Evaluation Count:112
112-170
3701 QDateTime asUTC = dateTime.toUTC();
executed (the execution status of this line is deduced): QDateTime asUTC = dateTime.toUTC();
-
3702 out << asUTC.d->date << asUTC.d->time;
executed (the execution status of this line is deduced): out << asUTC.d->date << asUTC.d->time;
-
3703 } else {
executed: }
Execution Count:170
170
3704 out << dateTime.d->date << dateTime.d->time;
executed (the execution status of this line is deduced): out << dateTime.d->date << dateTime.d->time;
-
3705 }
executed: }
Execution Count:112
112
3706 out << (qint8)dateTime.timeSpec();
executed (the execution status of this line is deduced): out << (qint8)dateTime.timeSpec();
-
3707 } else {
executed: }
Execution Count:282
282
3708 out << dateTime.d->date << dateTime.d->time;
executed (the execution status of this line is deduced): out << dateTime.d->date << dateTime.d->time;
-
3709 if (out.version() >= 7)
evaluated: out.version() >= 7
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:48
48-49
3710 out << (qint8)dateTime.d->spec;
executed: out << (qint8)dateTime.d->spec;
Execution Count:49
49
3711 }
executed: }
Execution Count:97
97
3712 return out;
executed: return out;
Execution Count:379
379
3713} -
3714 -
3715/*! -
3716 \relates QDateTime -
3717 -
3718 Reads a datetime from the stream \a in into \a dateTime. -
3719 -
3720 \sa {Serializing Qt Data Types} -
3721*/ -
3722 -
3723QDataStream &operator>>(QDataStream &in, QDateTime &dateTime) -
3724{ -
3725 dateTime.detach();
executed (the execution status of this line is deduced): dateTime.detach();
-
3726 -
3727 in >> dateTime.d->date >> dateTime.d->time;
executed (the execution status of this line is deduced): in >> dateTime.d->date >> dateTime.d->time;
-
3728 -
3729 if (in.version() >= 13) {
evaluated: in.version() >= 13
TRUEFALSE
yes
Evaluation Count:269
yes
Evaluation Count:50
50-269
3730 qint8 ts = 0;
executed (the execution status of this line is deduced): qint8 ts = 0;
-
3731 in >> ts;
executed (the execution status of this line is deduced): in >> ts;
-
3732 if (dateTime.isValid()) {
evaluated: dateTime.isValid()
TRUEFALSE
yes
Evaluation Count:179
yes
Evaluation Count:90
90-179
3733 // We always store the datetime as UTC in 13 onwards. -
3734 dateTime.d->spec = QDateTimePrivate::UTC;
executed (the execution status of this line is deduced): dateTime.d->spec = QDateTimePrivate::UTC;
-
3735 dateTime = dateTime.toTimeSpec(static_cast<Qt::TimeSpec>(ts));
executed (the execution status of this line is deduced): dateTime = dateTime.toTimeSpec(static_cast<Qt::TimeSpec>(ts));
-
3736 }
executed: }
Execution Count:179
179
3737 } else {
executed: }
Execution Count:269
269
3738 qint8 ts = (qint8)QDateTimePrivate::LocalUnknown;
executed (the execution status of this line is deduced): qint8 ts = (qint8)QDateTimePrivate::LocalUnknown;
-
3739 if (in.version() >= 7)
evaluated: in.version() >= 7
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:24
24-26
3740 in >> ts;
executed: in >> ts;
Execution Count:26
26
3741 dateTime.d->spec = (QDateTimePrivate::Spec)ts;
executed (the execution status of this line is deduced): dateTime.d->spec = (QDateTimePrivate::Spec)ts;
-
3742 }
executed: }
Execution Count:50
50
3743 return in;
executed: return in;
Execution Count:319
319
3744} -
3745#endif // QT_NO_DATASTREAM -
3746 -
3747 -
3748 -
3749// checks if there is an unquoted 'AP' or 'ap' in the string -
3750static bool hasUnquotedAP(const QString &f) -
3751{ -
3752 const QLatin1Char quote('\'');
executed (the execution status of this line is deduced): const QLatin1Char quote('\'');
-
3753 bool inquote = false;
executed (the execution status of this line is deduced): bool inquote = false;
-
3754 const int max = f.size();
executed (the execution status of this line is deduced): const int max = f.size();
-
3755 for (int i=0; i<max; ++i) {
evaluated: i<max
TRUEFALSE
yes
Evaluation Count:322540
yes
Evaluation Count:27883
27883-322540
3756 if (f.at(i) == quote) {
evaluated: f.at(i) == quote
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:322516
24-322516
3757 inquote = !inquote;
executed (the execution status of this line is deduced): inquote = !inquote;
-
3758 } else if (!inquote && f.at(i).toUpper() == QLatin1Char('A')) {
executed: }
Execution Count:24
evaluated: !inquote
TRUEFALSE
yes
Evaluation Count:322493
yes
Evaluation Count:23
evaluated: f.at(i).toUpper() == QLatin1Char('A')
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:322485
8-322493
3759 return true;
executed: return true;
Execution Count:8
8
3760 } -
3761 } -
3762 return false;
executed: return false;
Execution Count:27883
27883
3763} -
3764 -
3765#ifndef QT_NO_DATESTRING -
3766/***************************************************************************** -
3767 Some static function used by QDate, QTime and QDateTime -
3768*****************************************************************************/ -
3769 -
3770// Replaces tokens by their value. See QDateTime::toString() for a list of valid tokens -
3771static QString getFmtString(const QString& f, const QTime* dt = 0, const QDate* dd = 0, bool am_pm = false) -
3772{ -
3773 if (f.isEmpty())
evaluated: f.isEmpty()
TRUEFALSE
yes
Evaluation Count:102268
yes
Evaluation Count:102282
102268-102282
3774 return QString();
executed: return QString();
Execution Count:102268
102268
3775 -
3776 QString buf = f;
executed (the execution status of this line is deduced): QString buf = f;
-
3777 int removed = 0;
executed (the execution status of this line is deduced): int removed = 0;
-
3778 -
3779 if (dt) {
evaluated: dt
TRUEFALSE
yes
Evaluation Count:62892
yes
Evaluation Count:39390
39390-62892
3780 if (f.startsWith(QLatin1String("hh")) || f.startsWith(QLatin1String("HH"))) {
evaluated: f.startsWith(QLatin1String("hh"))
TRUEFALSE
yes
Evaluation Count:14727
yes
Evaluation Count:48165
evaluated: f.startsWith(QLatin1String("HH"))
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:48163
2-48165
3781 const bool hour12 = f.at(0) == QLatin1Char('h') && am_pm;
evaluated: f.at(0) == QLatin1Char('h')
TRUEFALSE
yes
Evaluation Count:14727
yes
Evaluation Count:2
evaluated: am_pm
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:14720
2-14727
3782 if (hour12 && dt->hour() > 12)
evaluated: hour12
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:14722
evaluated: dt->hour() > 12
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3
3-14722
3783 buf = QString::number(dt->hour() - 12).rightJustified(2, QLatin1Char('0'), true);
executed: buf = QString::number(dt->hour() - 12).rightJustified(2, QLatin1Char('0'), true);
Execution Count:4
4
3784 else if (hour12 && dt->hour() == 0)
evaluated: hour12
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:14722
evaluated: dt->hour() == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-14722
3785 buf = QLatin1String("12");
executed: buf = QLatin1String("12");
Execution Count:1
1
3786 else -
3787 buf = QString::number(dt->hour()).rightJustified(2, QLatin1Char('0'), true);
executed: buf = QString::number(dt->hour()).rightJustified(2, QLatin1Char('0'), true);
Execution Count:14724
14724
3788 removed = 2;
executed (the execution status of this line is deduced): removed = 2;
-
3789 } else if (f.at(0) == QLatin1Char('h') || f.at(0) == QLatin1Char('H')) {
executed: }
Execution Count:14729
evaluated: f.at(0) == QLatin1Char('h')
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:48158
evaluated: f.at(0) == QLatin1Char('H')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:48156
2-48158
3790 const bool hour12 = f.at(0) == QLatin1Char('h') && am_pm;
evaluated: f.at(0) == QLatin1Char('h')
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
evaluated: am_pm
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-5
3791 if (hour12 && dt->hour() > 12)
evaluated: hour12
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
evaluated: dt->hour() > 12
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-4
3792 buf = QString::number(dt->hour() - 12);
executed: buf = QString::number(dt->hour() - 12);
Execution Count:1
1
3793 else if (hour12 && dt->hour() == 0)
evaluated: hour12
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
evaluated: dt->hour() == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1-4
3794 buf = QLatin1String("12");
executed: buf = QLatin1String("12");
Execution Count:1
1
3795 else -
3796 buf = QString::number(dt->hour());
executed: buf = QString::number(dt->hour());
Execution Count:5
5
3797 removed = 1;
executed (the execution status of this line is deduced): removed = 1;
-
3798 } else if (f.startsWith(QLatin1String("mm"))) {
executed: }
Execution Count:7
evaluated: f.startsWith(QLatin1String("mm"))
TRUEFALSE
yes
Evaluation Count:14718
yes
Evaluation Count:33438
7-33438
3799 buf = QString::number(dt->minute()).rightJustified(2, QLatin1Char('0'), true);
executed (the execution status of this line is deduced): buf = QString::number(dt->minute()).rightJustified(2, QLatin1Char('0'), true);
-
3800 removed = 2;
executed (the execution status of this line is deduced): removed = 2;
-
3801 } else if (f.at(0) == (QLatin1Char('m'))) {
executed: }
Execution Count:14718
evaluated: f.at(0) == (QLatin1Char('m'))
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:33436
2-33436
3802 buf = QString::number(dt->minute());
executed (the execution status of this line is deduced): buf = QString::number(dt->minute());
-
3803 removed = 1;
executed (the execution status of this line is deduced): removed = 1;
-
3804 } else if (f.startsWith(QLatin1String("ss"))) {
executed: }
Execution Count:2
evaluated: f.startsWith(QLatin1String("ss"))
TRUEFALSE
yes
Evaluation Count:14720
yes
Evaluation Count:18716
2-18716
3805 buf = QString::number(dt->second()).rightJustified(2, QLatin1Char('0'), true);
executed (the execution status of this line is deduced): buf = QString::number(dt->second()).rightJustified(2, QLatin1Char('0'), true);
-
3806 removed = 2;
executed (the execution status of this line is deduced): removed = 2;
-
3807 } else if (f.at(0) == QLatin1Char('s')) {
executed: }
Execution Count:14720
evaluated: f.at(0) == QLatin1Char('s')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18715
1-18715
3808 buf = QString::number(dt->second());
executed (the execution status of this line is deduced): buf = QString::number(dt->second());
-
3809 } else if (f.startsWith(QLatin1String("zzz"))) {
executed: }
Execution Count:1
evaluated: f.startsWith(QLatin1String("zzz"))
TRUEFALSE
yes
Evaluation Count:14734
yes
Evaluation Count:3981
1-14734
3810 buf = QString::number(dt->msec()).rightJustified(3, QLatin1Char('0'), true);
executed (the execution status of this line is deduced): buf = QString::number(dt->msec()).rightJustified(3, QLatin1Char('0'), true);
-
3811 removed = 3;
executed (the execution status of this line is deduced): removed = 3;
-
3812 } else if (f.at(0) == QLatin1Char('z')) {
executed: }
Execution Count:14734
evaluated: f.at(0) == QLatin1Char('z')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3979
2-14734
3813 buf = QString::number(dt->msec());
executed (the execution status of this line is deduced): buf = QString::number(dt->msec());
-
3814 removed = 1;
executed (the execution status of this line is deduced): removed = 1;
-
3815 } else if (f.at(0).toUpper() == QLatin1Char('A')) {
executed: }
Execution Count:2
evaluated: f.at(0).toUpper() == QLatin1Char('A')
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:3965
2-3965
3816 const bool upper = f.at(0) == QLatin1Char('A');
executed (the execution status of this line is deduced): const bool upper = f.at(0) == QLatin1Char('A');
-
3817 buf = dt->hour() < 12 ? QLatin1String("am") : QLatin1String("pm");
evaluated: dt->hour() < 12
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
7
3818 if (upper)
evaluated: upper
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:6
6-8
3819 buf = buf.toUpper();
executed: buf = buf.toUpper();
Execution Count:8
8
3820 if (f.size() > 1 && f.at(1).toUpper() == QLatin1Char('P') &&
evaluated: f.size() > 1
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:5
partially evaluated: f.at(1).toUpper() == QLatin1Char('P')
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
3821 f.at(0).isUpper() == f.at(1).isUpper()) {
partially evaluated: f.at(0).isUpper() == f.at(1).isUpper()
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
3822 removed = 2;
executed (the execution status of this line is deduced): removed = 2;
-
3823 } else {
executed: }
Execution Count:9
9
3824 removed = 1;
executed (the execution status of this line is deduced): removed = 1;
-
3825 }
executed: }
Execution Count:5
5
3826 } -
3827 } -
3828 -
3829 if (dd) {
evaluated: dd
TRUEFALSE
yes
Evaluation Count:48656
yes
Evaluation Count:53626
48656-53626
3830 if (f.startsWith(QLatin1String("dddd"))) {
evaluated: f.startsWith(QLatin1String("dddd"))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:48655
1-48655
3831 buf = dd->longDayName(dd->dayOfWeek());
executed (the execution status of this line is deduced): buf = dd->longDayName(dd->dayOfWeek());
-
3832 removed = 4;
executed (the execution status of this line is deduced): removed = 4;
-
3833 } else if (f.startsWith(QLatin1String("ddd"))) {
executed: }
Execution Count:1
evaluated: f.startsWith(QLatin1String("ddd"))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:48654
1-48654
3834 buf = dd->shortDayName(dd->dayOfWeek());
executed (the execution status of this line is deduced): buf = dd->shortDayName(dd->dayOfWeek());
-
3835 removed = 3;
executed (the execution status of this line is deduced): removed = 3;
-
3836 } else if (f.startsWith(QLatin1String("dd"))) {
executed: }
Execution Count:1
evaluated: f.startsWith(QLatin1String("dd"))
TRUEFALSE
yes
Evaluation Count:14447
yes
Evaluation Count:34207
1-34207
3837 buf = QString::number(dd->day()).rightJustified(2, QLatin1Char('0'), true);
executed (the execution status of this line is deduced): buf = QString::number(dd->day()).rightJustified(2, QLatin1Char('0'), true);
-
3838 removed = 2;
executed (the execution status of this line is deduced): removed = 2;
-
3839 } else if (f.at(0) == QLatin1Char('d')) {
executed: }
Execution Count:14447
evaluated: f.at(0) == QLatin1Char('d')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:34205
2-34205
3840 buf = QString::number(dd->day());
executed (the execution status of this line is deduced): buf = QString::number(dd->day());
-
3841 removed = 1;
executed (the execution status of this line is deduced): removed = 1;
-
3842 } else if (f.startsWith(QLatin1String("MMMM"))) {
executed: }
Execution Count:2
evaluated: f.startsWith(QLatin1String("MMMM"))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:34204
1-34204
3843 buf = dd->longMonthName(dd->month());
executed (the execution status of this line is deduced): buf = dd->longMonthName(dd->month());
-
3844 removed = 4;
executed (the execution status of this line is deduced): removed = 4;
-
3845 } else if (f.startsWith(QLatin1String("MMM"))) {
executed: }
Execution Count:1
evaluated: f.startsWith(QLatin1String("MMM"))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:34203
1-34203
3846 buf = dd->shortMonthName(dd->month());
executed (the execution status of this line is deduced): buf = dd->shortMonthName(dd->month());
-
3847 removed = 3;
executed (the execution status of this line is deduced): removed = 3;
-
3848 } else if (f.startsWith(QLatin1String("MM"))) {
executed: }
Execution Count:1
evaluated: f.startsWith(QLatin1String("MM"))
TRUEFALSE
yes
Evaluation Count:14446
yes
Evaluation Count:19757
1-19757
3849 buf = QString::number(dd->month()).rightJustified(2, QLatin1Char('0'), true);
executed (the execution status of this line is deduced): buf = QString::number(dd->month()).rightJustified(2, QLatin1Char('0'), true);
-
3850 removed = 2;
executed (the execution status of this line is deduced): removed = 2;
-
3851 } else if (f.at(0) == QLatin1Char('M')) {
executed: }
Execution Count:14446
evaluated: f.at(0) == QLatin1Char('M')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:19755
2-19755
3852 buf = QString::number(dd->month());
executed (the execution status of this line is deduced): buf = QString::number(dd->month());
-
3853 removed = 1;
executed (the execution status of this line is deduced): removed = 1;
-
3854 } else if (f.startsWith(QLatin1String("yyyy"))) {
executed: }
Execution Count:2
evaluated: f.startsWith(QLatin1String("yyyy"))
TRUEFALSE
yes
Evaluation Count:14450
yes
Evaluation Count:5305
2-14450
3855 const int year = dd->year();
executed (the execution status of this line is deduced): const int year = dd->year();
-
3856 buf = QString::number(qAbs(year)).rightJustified(4, QLatin1Char('0'));
executed (the execution status of this line is deduced): buf = QString::number(qAbs(year)).rightJustified(4, QLatin1Char('0'));
-
3857 if(year > 0)
evaluated: year > 0
TRUEFALSE
yes
Evaluation Count:14252
yes
Evaluation Count:198
198-14252
3858 removed = 4;
executed: removed = 4;
Execution Count:14252
14252
3859 else -
3860 { -
3861 buf.prepend(QLatin1Char('-'));
executed (the execution status of this line is deduced): buf.prepend(QLatin1Char('-'));
-
3862 removed = 5;
executed (the execution status of this line is deduced): removed = 5;
-
3863 }
executed: }
Execution Count:198
198
3864 -
3865 } else if (f.startsWith(QLatin1String("yy"))) {
evaluated: f.startsWith(QLatin1String("yy"))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5301
4-5301
3866 buf = QString::number(dd->year()).right(2).rightJustified(2, QLatin1Char('0'));
executed (the execution status of this line is deduced): buf = QString::number(dd->year()).right(2).rightJustified(2, QLatin1Char('0'));
-
3867 removed = 2;
executed (the execution status of this line is deduced): removed = 2;
-
3868 }
executed: }
Execution Count:4
4
3869 } -
3870 if (removed == 0 || removed >= f.size()) {
evaluated: removed == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:102281
evaluated: removed >= f.size()
TRUEFALSE
yes
Evaluation Count:102275
yes
Evaluation Count:6
1-102281
3871 return buf;
executed: return buf;
Execution Count:102276
102276
3872 } -
3873 -
3874 return buf + getFmtString(f.mid(removed), dt, dd, am_pm);
executed: return buf + getFmtString(f.mid(removed), dt, dd, am_pm);
Execution Count:6
6
3875} -
3876 -
3877// Parses the format string and uses getFmtString to get the values for the tokens. Ret -
3878static QString fmtDateTime(const QString& f, const QTime* dt, const QDate* dd) -
3879{ -
3880 QString buf;
executed (the execution status of this line is deduced): QString buf;
-
3881 -
3882 if (f.isEmpty())
evaluated: f.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:27894
1-27894
3883 return buf;
executed: return buf;
Execution Count:1
1
3884 if (dt && !dt->isValid())
evaluated: dt
TRUEFALSE
yes
Evaluation Count:14760
yes
Evaluation Count:13134
evaluated: !dt->isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:14758
2-14760
3885 return buf;
executed: return buf;
Execution Count:2
2
3886 if (dd && !dd->isValid())
evaluated: dd
TRUEFALSE
yes
Evaluation Count:14485
yes
Evaluation Count:13407
evaluated: !dd->isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14484
1-14485
3887 return buf;
executed: return buf;
Execution Count:1
1
3888 -
3889 const bool ap = hasUnquotedAP(f);
executed (the execution status of this line is deduced): const bool ap = hasUnquotedAP(f);
-
3890 -
3891 QString frm;
executed (the execution status of this line is deduced): QString frm;
-
3892 uint status = '0';
executed (the execution status of this line is deduced): uint status = '0';
-
3893 -
3894 for (int i = 0, n = f.length(); i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:322606
yes
Evaluation Count:27891
27891-322606
3895 const QChar c = f.at(i);
executed (the execution status of this line is deduced): const QChar c = f.at(i);
-
3896 const uint cc = c.unicode();
executed (the execution status of this line is deduced): const uint cc = c.unicode();
-
3897 if (cc == '\'') {
evaluated: cc == '\''
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:322580
26-322580
3898 if (status == cc) {
evaluated: status == cc
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:14
12-14
3899 if (i > 0 && f.at(i - 1).unicode() == cc)
partially evaluated: i > 0
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
evaluated: f.at(i - 1).unicode() == cc
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:7
0-12
3900 buf += c;
executed: buf += c;
Execution Count:5
5
3901 status = '0';
executed (the execution status of this line is deduced): status = '0';
-
3902 } else {
executed: }
Execution Count:12
12
3903 if (!frm.isEmpty()) {
evaluated: !frm.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:9
5-9
3904 buf += getFmtString(frm, dt, dd, ap);
executed (the execution status of this line is deduced): buf += getFmtString(frm, dt, dd, ap);
-
3905 frm.clear();
executed (the execution status of this line is deduced): frm.clear();
-
3906 }
executed: }
Execution Count:5
5
3907 status = cc;
executed (the execution status of this line is deduced): status = cc;
-
3908 }
executed: }
Execution Count:14
14
3909 } else if (status == '\'') {
evaluated: status == '\''
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:322555
25-322555
3910 buf += c;
executed (the execution status of this line is deduced): buf += c;
-
3911 } else if (c == status) {
executed: }
Execution Count:25
evaluated: c == status
TRUEFALSE
yes
Evaluation Count:145907
yes
Evaluation Count:176648
25-176648
3912 if (ap && (cc == 'P' || cc == 'p'))
evaluated: ap
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:145864
evaluated: cc == 'P'
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:38
evaluated: cc == 'p'
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:34
4-145864
3913 status = '0';
executed: status = '0';
Execution Count:9
9
3914 frm += c;
executed (the execution status of this line is deduced): frm += c;
-
3915 } else {
executed: }
Execution Count:145907
145907
3916 buf += getFmtString(frm, dt, dd, ap);
executed (the execution status of this line is deduced): buf += getFmtString(frm, dt, dd, ap);
-
3917 frm.clear();
executed (the execution status of this line is deduced): frm.clear();
-
3918 if (cc == 'h' || cc == 'm' || cc == 'H' || cc == 's' || cc == 'z') {
evaluated: cc == 'h'
TRUEFALSE
yes
Evaluation Count:14728
yes
Evaluation Count:161920
evaluated: cc == 'm'
TRUEFALSE
yes
Evaluation Count:14720
yes
Evaluation Count:147200
evaluated: cc == 'H'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:147198
evaluated: cc == 's'
TRUEFALSE
yes
Evaluation Count:14721
yes
Evaluation Count:132477
evaluated: cc == 'z'
TRUEFALSE
yes
Evaluation Count:14736
yes
Evaluation Count:117741
2-161920
3919 status = cc;
executed (the execution status of this line is deduced): status = cc;
-
3920 frm += c;
executed (the execution status of this line is deduced): frm += c;
-
3921 } else if (cc == 'd' || cc == 'M' || cc == 'y') {
executed: }
Execution Count:58907
evaluated: cc == 'd'
TRUEFALSE
yes
Evaluation Count:14451
yes
Evaluation Count:103290
evaluated: cc == 'M'
TRUEFALSE
yes
Evaluation Count:14450
yes
Evaluation Count:88840
evaluated: cc == 'y'
TRUEFALSE
yes
Evaluation Count:14454
yes
Evaluation Count:74386
14450-103290
3922 status = cc;
executed (the execution status of this line is deduced): status = cc;
-
3923 frm += c;
executed (the execution status of this line is deduced): frm += c;
-
3924 } else if (ap && cc == 'A') {
executed: }
Execution Count:43355
evaluated: ap
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:74355
evaluated: cc == 'A'
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:23
8-74355
3925 status = 'P';
executed (the execution status of this line is deduced): status = 'P';
-
3926 frm += c;
executed (the execution status of this line is deduced): frm += c;
-
3927 } else if (ap && cc == 'a') {
executed: }
Execution Count:8
evaluated: ap
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:74355
evaluated: cc == 'a'
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:17
6-74355
3928 status = 'p';
executed (the execution status of this line is deduced): status = 'p';
-
3929 frm += c;
executed (the execution status of this line is deduced): frm += c;
-
3930 } else {
executed: }
Execution Count:6
6
3931 buf += c;
executed (the execution status of this line is deduced): buf += c;
-
3932 status = '0';
executed (the execution status of this line is deduced): status = '0';
-
3933 }
executed: }
Execution Count:74372
74372
3934 } -
3935 } -
3936 -
3937 buf += getFmtString(frm, dt, dd, ap);
executed (the execution status of this line is deduced): buf += getFmtString(frm, dt, dd, ap);
-
3938 -
3939 return buf;
executed: return buf;
Execution Count:27891
27891
3940} -
3941#endif // QT_NO_DATESTRING -
3942 -
3943#ifdef Q_OS_WIN -
3944static const int LowerYear = 1980; -
3945#else -
3946static const int LowerYear = 1970; -
3947#endif -
3948static const int UpperYear = 2037; -
3949 -
3950static QDate adjustDate(QDate date) -
3951{ -
3952 QDate lowerLimit(LowerYear, 1, 2);
executed (the execution status of this line is deduced): QDate lowerLimit(LowerYear, 1, 2);
-
3953 QDate upperLimit(UpperYear, 12, 30);
executed (the execution status of this line is deduced): QDate upperLimit(UpperYear, 12, 30);
-
3954 -
3955 if (date > lowerLimit && date < upperLimit)
evaluated: date > lowerLimit
TRUEFALSE
yes
Evaluation Count:20662
yes
Evaluation Count:405
evaluated: date < upperLimit
TRUEFALSE
yes
Evaluation Count:20452
yes
Evaluation Count:210
210-20662
3956 return date;
executed: return date;
Execution Count:20452
20452
3957 -
3958 int month = date.month();
executed (the execution status of this line is deduced): int month = date.month();
-
3959 int day = date.day();
executed (the execution status of this line is deduced): int day = date.day();
-
3960 -
3961 // neither 1970 nor 2037 are leap years, so make sure date isn't Feb 29 -
3962 if (month == 2 && day == 29)
evaluated: month == 2
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:569
evaluated: day == 29
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:14
14-569
3963 --day;
executed: --day;
Execution Count:32
32
3964 -
3965 if (date < lowerLimit)
evaluated: date < lowerLimit
TRUEFALSE
yes
Evaluation Count:390
yes
Evaluation Count:225
225-390
3966 date.setDate(LowerYear, month, day);
executed: date.setDate(LowerYear, month, day);
Execution Count:390
390
3967 else -
3968 date.setDate(UpperYear, month, day);
executed: date.setDate(UpperYear, month, day);
Execution Count:225
225
3969 -
3970 return date;
executed: return date;
Execution Count:615
615
3971} -
3972 -
3973static QDateTimePrivate::Spec utcToLocal(QDate &date, QTime &time) -
3974{ -
3975 QDate fakeDate = adjustDate(date);
executed (the execution status of this line is deduced): QDate fakeDate = adjustDate(date);
-
3976 -
3977 // won't overflow because of fakeDate -
3978 time_t secsSince1Jan1970UTC = toMSecsSinceEpoch_helper(fakeDate.toJulianDay(), QTime(0, 0, 0).msecsTo(time)) / 1000;
executed (the execution status of this line is deduced): time_t secsSince1Jan1970UTC = toMSecsSinceEpoch_helper(fakeDate.toJulianDay(), QTime(0, 0, 0).msecsTo(time)) / 1000;
-
3979 tm *brokenDown = 0;
executed (the execution status of this line is deduced): tm *brokenDown = 0;
-
3980 -
3981#if defined(Q_OS_WINCE) -
3982 tm res; -
3983 FILETIME utcTime = time_tToFt(secsSince1Jan1970UTC); -
3984 FILETIME resultTime; -
3985 FileTimeToLocalFileTime(&utcTime , &resultTime); -
3986 SYSTEMTIME sysTime; -
3987 FileTimeToSystemTime(&resultTime , &sysTime); -
3988 -
3989 res.tm_sec = sysTime.wSecond; -
3990 res.tm_min = sysTime.wMinute; -
3991 res.tm_hour = sysTime.wHour; -
3992 res.tm_mday = sysTime.wDay; -
3993 res.tm_mon = sysTime.wMonth - 1; -
3994 res.tm_year = sysTime.wYear - 1900; -
3995 brokenDown = &res; -
3996#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) -
3997 // use the reentrant version of localtime() where available -
3998 tzset();
executed (the execution status of this line is deduced): tzset();
-
3999 tm res;
executed (the execution status of this line is deduced): tm res;
-
4000 brokenDown = localtime_r(&secsSince1Jan1970UTC, &res);
executed (the execution status of this line is deduced): brokenDown = localtime_r(&secsSince1Jan1970UTC, &res);
-
4001#elif defined(_MSC_VER) && _MSC_VER >= 1400 -
4002 tm res; -
4003 if (!_localtime64_s(&res, &secsSince1Jan1970UTC)) -
4004 brokenDown = &res; -
4005#else -
4006 brokenDown = localtime(&secsSince1Jan1970UTC); -
4007#endif -
4008 if (!brokenDown) {
partially evaluated: !brokenDown
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6038
0-6038
4009 date = QDate(1970, 1, 1);
never executed (the execution status of this line is deduced): date = QDate(1970, 1, 1);
-
4010 time = QTime();
never executed (the execution status of this line is deduced): time = QTime();
-
4011 return QDateTimePrivate::LocalUnknown;
never executed: return QDateTimePrivate::LocalUnknown;
0
4012 } else { -
4013 int deltaDays = fakeDate.daysTo(date);
executed (the execution status of this line is deduced): int deltaDays = fakeDate.daysTo(date);
-
4014 date = QDate(brokenDown->tm_year + 1900, brokenDown->tm_mon + 1, brokenDown->tm_mday);
executed (the execution status of this line is deduced): date = QDate(brokenDown->tm_year + 1900, brokenDown->tm_mon + 1, brokenDown->tm_mday);
-
4015 time = QTime(brokenDown->tm_hour, brokenDown->tm_min, brokenDown->tm_sec, time.msec());
executed (the execution status of this line is deduced): time = QTime(brokenDown->tm_hour, brokenDown->tm_min, brokenDown->tm_sec, time.msec());
-
4016 date = date.addDays(deltaDays);
executed (the execution status of this line is deduced): date = date.addDays(deltaDays);
-
4017 if (brokenDown->tm_isdst > 0)
evaluated: brokenDown->tm_isdst > 0
TRUEFALSE
yes
Evaluation Count:4538
yes
Evaluation Count:1500
1500-4538
4018 return QDateTimePrivate::LocalDST;
executed: return QDateTimePrivate::LocalDST;
Execution Count:4538
4538
4019 else if (brokenDown->tm_isdst < 0)
partially evaluated: brokenDown->tm_isdst < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1500
0-1500
4020 return QDateTimePrivate::LocalUnknown;
never executed: return QDateTimePrivate::LocalUnknown;
0
4021 else -
4022 return QDateTimePrivate::LocalStandard;
executed: return QDateTimePrivate::LocalStandard;
Execution Count:1500
1500
4023 } -
4024} -
4025 -
4026static void localToUtc(QDate &date, QTime &time, int isdst) -
4027{ -
4028 if (!date.isValid())
evaluated: !date.isValid()
TRUEFALSE
yes
Evaluation Count:2181
yes
Evaluation Count:15029
2181-15029
4029 return;
executed: return;
Execution Count:2181
2181
4030 -
4031 QDate fakeDate = adjustDate(date);
executed (the execution status of this line is deduced): QDate fakeDate = adjustDate(date);
-
4032 -
4033 tm localTM;
executed (the execution status of this line is deduced): tm localTM;
-
4034 localTM.tm_sec = time.second();
executed (the execution status of this line is deduced): localTM.tm_sec = time.second();
-
4035 localTM.tm_min = time.minute();
executed (the execution status of this line is deduced): localTM.tm_min = time.minute();
-
4036 localTM.tm_hour = time.hour();
executed (the execution status of this line is deduced): localTM.tm_hour = time.hour();
-
4037 localTM.tm_mday = fakeDate.day();
executed (the execution status of this line is deduced): localTM.tm_mday = fakeDate.day();
-
4038 localTM.tm_mon = fakeDate.month() - 1;
executed (the execution status of this line is deduced): localTM.tm_mon = fakeDate.month() - 1;
-
4039 localTM.tm_year = fakeDate.year() - 1900;
executed (the execution status of this line is deduced): localTM.tm_year = fakeDate.year() - 1900;
-
4040 localTM.tm_isdst = (int)isdst;
executed (the execution status of this line is deduced): localTM.tm_isdst = (int)isdst;
-
4041#if defined(Q_OS_WINCE) -
4042 time_t secsSince1Jan1970UTC = (toMSecsSinceEpoch_helper(fakeDate.toJulianDay(), QTime().msecsTo(time)) / 1000); -
4043#else -
4044#if defined(Q_OS_WIN) -
4045 _tzset(); -
4046#endif -
4047 time_t secsSince1Jan1970UTC = mktime(&localTM);
executed (the execution status of this line is deduced): time_t secsSince1Jan1970UTC = mktime(&localTM);
-
4048#endif -
4049 tm *brokenDown = 0;
executed (the execution status of this line is deduced): tm *brokenDown = 0;
-
4050#if defined(Q_OS_WINCE) -
4051 tm res; -
4052 FILETIME localTime = time_tToFt(secsSince1Jan1970UTC); -
4053 SYSTEMTIME sysTime; -
4054 FileTimeToSystemTime(&localTime, &sysTime); -
4055 FILETIME resultTime; -
4056 LocalFileTimeToFileTime(&localTime , &resultTime); -
4057 FileTimeToSystemTime(&resultTime , &sysTime); -
4058 res.tm_sec = sysTime.wSecond; -
4059 res.tm_min = sysTime.wMinute; -
4060 res.tm_hour = sysTime.wHour; -
4061 res.tm_mday = sysTime.wDay; -
4062 res.tm_mon = sysTime.wMonth - 1; -
4063 res.tm_year = sysTime.wYear - 1900; -
4064 res.tm_isdst = (int)isdst; -
4065 brokenDown = &res; -
4066#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) -
4067 // use the reentrant version of gmtime() where available -
4068 tm res;
executed (the execution status of this line is deduced): tm res;
-
4069 brokenDown = gmtime_r(&secsSince1Jan1970UTC, &res);
executed (the execution status of this line is deduced): brokenDown = gmtime_r(&secsSince1Jan1970UTC, &res);
-
4070#elif defined(_MSC_VER) && _MSC_VER >= 1400 -
4071 tm res; -
4072 if (!_gmtime64_s(&res, &secsSince1Jan1970UTC)) -
4073 brokenDown = &res; -
4074#else -
4075 brokenDown = gmtime(&secsSince1Jan1970UTC); -
4076#endif // !QT_NO_THREAD && _POSIX_THREAD_SAFE_FUNCTIONS -
4077 if (!brokenDown) {
partially evaluated: !brokenDown
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15029
0-15029
4078 date = QDate(1970, 1, 1);
never executed (the execution status of this line is deduced): date = QDate(1970, 1, 1);
-
4079 time = QTime();
never executed (the execution status of this line is deduced): time = QTime();
-
4080 } else {
never executed: }
0
4081 int deltaDays = fakeDate.daysTo(date);
executed (the execution status of this line is deduced): int deltaDays = fakeDate.daysTo(date);
-
4082 date = QDate(brokenDown->tm_year + 1900, brokenDown->tm_mon + 1, brokenDown->tm_mday);
executed (the execution status of this line is deduced): date = QDate(brokenDown->tm_year + 1900, brokenDown->tm_mon + 1, brokenDown->tm_mday);
-
4083 time = QTime(brokenDown->tm_hour, brokenDown->tm_min, brokenDown->tm_sec, time.msec());
executed (the execution status of this line is deduced): time = QTime(brokenDown->tm_hour, brokenDown->tm_min, brokenDown->tm_sec, time.msec());
-
4084 date = date.addDays(deltaDays);
executed (the execution status of this line is deduced): date = date.addDays(deltaDays);
-
4085 }
executed: }
Execution Count:15029
15029
4086} -
4087 -
4088QDateTimePrivate::Spec QDateTimePrivate::getLocal(QDate &outDate, QTime &outTime) const -
4089{ -
4090 outDate = date;
executed (the execution status of this line is deduced): outDate = date;
-
4091 outTime = time;
executed (the execution status of this line is deduced): outTime = time;
-
4092 if (spec == QDateTimePrivate::UTC)
partially evaluated: spec == QDateTimePrivate::UTC
TRUEFALSE
yes
Evaluation Count:6038
no
Evaluation Count:0
0-6038
4093 return utcToLocal(outDate, outTime);
executed: return utcToLocal(outDate, outTime);
Execution Count:6038
6038
4094 return spec;
never executed: return spec;
0
4095} -
4096 -
4097void QDateTimePrivate::getUTC(QDate &outDate, QTime &outTime) const -
4098{ -
4099 outDate = date;
executed (the execution status of this line is deduced): outDate = date;
-
4100 outTime = time;
executed (the execution status of this line is deduced): outTime = time;
-
4101 const bool isOffset = spec == QDateTimePrivate::OffsetFromUTC;
executed (the execution status of this line is deduced): const bool isOffset = spec == QDateTimePrivate::OffsetFromUTC;
-
4102 -
4103 if (spec != QDateTimePrivate::UTC && !isOffset)
evaluated: spec != QDateTimePrivate::UTC
TRUEFALSE
yes
Evaluation Count:17241
yes
Evaluation Count:5005
evaluated: !isOffset
TRUEFALSE
yes
Evaluation Count:17210
yes
Evaluation Count:31
31-17241
4104 localToUtc(outDate, outTime, (int)spec);
executed: localToUtc(outDate, outTime, (int)spec);
Execution Count:17210
17210
4105 -
4106 if (isOffset)
evaluated: isOffset
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:22215
31-22215
4107 addMSecs(outDate, outTime, -(qint64(utcOffset) * 1000));
executed: addMSecs(outDate, outTime, -(qint64(utcOffset) * 1000));
Execution Count:31
31
4108}
executed: }
Execution Count:22246
22246
4109 -
4110#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING) -
4111QDebug operator<<(QDebug dbg, const QDate &date) -
4112{ -
4113 dbg.nospace() << "QDate(" << date.toString() << ')';
executed (the execution status of this line is deduced): dbg.nospace() << "QDate(" << date.toString() << ')';
-
4114 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
4115} -
4116 -
4117QDebug operator<<(QDebug dbg, const QTime &time) -
4118{ -
4119 dbg.nospace() << "QTime(" << time.toString() << ')';
executed (the execution status of this line is deduced): dbg.nospace() << "QTime(" << time.toString() << ')';
-
4120 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
4121} -
4122 -
4123QDebug operator<<(QDebug dbg, const QDateTime &date) -
4124{ -
4125 dbg.nospace() << "QDateTime(" << date.toString() << ')';
executed (the execution status of this line is deduced): dbg.nospace() << "QDateTime(" << date.toString() << ')';
-
4126 return dbg.space();
executed: return dbg.space();
Execution Count:2
2
4127} -
4128#endif -
4129 -
4130/*! \fn uint qHash(const QDateTime &key, uint seed = 0) -
4131 \relates QHash -
4132 \since 5.0 -
4133 -
4134 Returns the hash value for the \a key, using \a seed to seed the calculation. -
4135*/ -
4136uint qHash(const QDateTime &key, uint seed) -
4137{ -
4138 // Use to toMSecsSinceEpoch instead of individual qHash functions for -
4139 // QDate/QTime/spec/offset because QDateTime::operator== converts both arguments -
4140 // to the same timezone. If we don't, qHash would return different hashes for -
4141 // two QDateTimes that are equivalent once converted to the same timezone. -
4142 return qHash(key.toMSecsSinceEpoch(), seed);
executed: return qHash(key.toMSecsSinceEpoch(), seed);
Execution Count:16
16
4143} -
4144 -
4145/*! \fn uint qHash(const QDate &key, uint seed = 0) -
4146 \relates QHash -
4147 \since 5.0 -
4148 -
4149 Returns the hash value for the \a key, using \a seed to seed the calculation. -
4150*/ -
4151uint qHash(const QDate &key, uint seed) Q_DECL_NOTHROW -
4152{ -
4153 return qHash(key.toJulianDay(), seed);
executed: return qHash(key.toJulianDay(), seed);
Execution Count:6
6
4154} -
4155 -
4156/*! \fn uint qHash(const QTime &key, uint seed = 0) -
4157 \relates QHash -
4158 \since 5.0 -
4159 -
4160 Returns the hash value for the \a key, using \a seed to seed the calculation. -
4161*/ -
4162uint qHash(const QTime &key, uint seed) Q_DECL_NOTHROW -
4163{ -
4164 return qHash(QTime(0, 0, 0, 0).msecsTo(key), seed);
executed: return qHash(QTime(0, 0, 0, 0).msecsTo(key), seed);
Execution Count:4
4
4165} -
4166 -
4167#ifndef QT_BOOTSTRAPPED -
4168 -
4169/*! -
4170 \internal -
4171 Gets the digit from a datetime. E.g. -
4172 -
4173 QDateTime var(QDate(2004, 02, 02)); -
4174 int digit = getDigit(var, Year); -
4175 // digit = 2004 -
4176*/ -
4177 -
4178int QDateTimeParser::getDigit(const QDateTime &t, int index) const -
4179{ -
4180 if (index < 0 || index >= sectionNodes.size()) {
partially evaluated: index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2164
partially evaluated: index >= sectionNodes.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2164
0-2164
4181#ifndef QT_NO_DATESTRING -
4182 qWarning("QDateTimeParser::getDigit() Internal error (%s %d)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4182, __PRETTY_FUNCTION__).warning("QDateTimeParser::getDigit() Internal error (%s %d)",
-
4183 qPrintable(t.toString()), index);
never executed (the execution status of this line is deduced): QString(t.toString()).toLocal8Bit().constData(), index);
-
4184#else -
4185 qWarning("QDateTimeParser::getDigit() Internal error (%d)", index); -
4186#endif -
4187 return -1;
never executed: return -1;
0
4188 } -
4189 const SectionNode &node = sectionNodes.at(index);
executed (the execution status of this line is deduced): const SectionNode &node = sectionNodes.at(index);
-
4190 switch (node.type) { -
4191 case Hour24Section: case Hour12Section: return t.time().hour();
executed: return t.time().hour();
Execution Count:724
724
4192 case MinuteSection: return t.time().minute();
executed: return t.time().minute();
Execution Count:316
316
4193 case SecondSection: return t.time().second();
executed: return t.time().second();
Execution Count:299
299
4194 case MSecSection: return t.time().msec();
never executed: return t.time().msec();
0
4195 case YearSection2Digits: -
4196 case YearSection: return t.date().year();
executed: return t.date().year();
Execution Count:661
661
4197 case MonthSection: return t.date().month();
executed: return t.date().month();
Execution Count:60
60
4198 case DaySection: return t.date().day();
executed: return t.date().day();
Execution Count:95
95
4199 case DayOfWeekSectionShort: -
4200 case DayOfWeekSectionLong: return t.date().day();
executed: return t.date().day();
Execution Count:3
3
4201 case AmPmSection: return t.time().hour() > 11 ? 1 : 0;
executed: return t.time().hour() > 11 ? 1 : 0;
Execution Count:6
6
4202 -
4203 default: break;
never executed: break;
0
4204 } -
4205 -
4206#ifndef QT_NO_DATESTRING -
4207 qWarning("QDateTimeParser::getDigit() Internal error 2 (%s %d)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4207, __PRETTY_FUNCTION__).warning("QDateTimeParser::getDigit() Internal error 2 (%s %d)",
-
4208 qPrintable(t.toString()), index);
never executed (the execution status of this line is deduced): QString(t.toString()).toLocal8Bit().constData(), index);
-
4209#else -
4210 qWarning("QDateTimeParser::getDigit() Internal error 2 (%d)", index); -
4211#endif -
4212 return -1;
never executed: return -1;
0
4213} -
4214 -
4215/*! -
4216 \internal -
4217 Sets a digit in a datetime. E.g. -
4218 -
4219 QDateTime var(QDate(2004, 02, 02)); -
4220 int digit = getDigit(var, Year); -
4221 // digit = 2004 -
4222 setDigit(&var, Year, 2005); -
4223 digit = getDigit(var, Year); -
4224 // digit = 2005 -
4225*/ -
4226 -
4227bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const -
4228{ -
4229 if (index < 0 || index >= sectionNodes.size()) {
partially evaluated: index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2657
partially evaluated: index >= sectionNodes.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2657
0-2657
4230#ifndef QT_NO_DATESTRING -
4231 qWarning("QDateTimeParser::setDigit() Internal error (%s %d %d)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4231, __PRETTY_FUNCTION__).warning("QDateTimeParser::setDigit() Internal error (%s %d %d)",
-
4232 qPrintable(v.toString()), index, newVal);
never executed (the execution status of this line is deduced): QString(v.toString()).toLocal8Bit().constData(), index, newVal);
-
4233#else -
4234 qWarning("QDateTimeParser::setDigit() Internal error (%d %d)", index, newVal); -
4235#endif -
4236 return false;
never executed: return false;
0
4237 } -
4238 const SectionNode &node = sectionNodes.at(index);
executed (the execution status of this line is deduced): const SectionNode &node = sectionNodes.at(index);
-
4239 -
4240 int year, month, day, hour, minute, second, msec;
executed (the execution status of this line is deduced): int year, month, day, hour, minute, second, msec;
-
4241 year = v.date().year();
executed (the execution status of this line is deduced): year = v.date().year();
-
4242 month = v.date().month();
executed (the execution status of this line is deduced): month = v.date().month();
-
4243 day = v.date().day();
executed (the execution status of this line is deduced): day = v.date().day();
-
4244 hour = v.time().hour();
executed (the execution status of this line is deduced): hour = v.time().hour();
-
4245 minute = v.time().minute();
executed (the execution status of this line is deduced): minute = v.time().minute();
-
4246 second = v.time().second();
executed (the execution status of this line is deduced): second = v.time().second();
-
4247 msec = v.time().msec();
executed (the execution status of this line is deduced): msec = v.time().msec();
-
4248 -
4249 switch (node.type) { -
4250 case Hour24Section: case Hour12Section: hour = newVal; break;
executed: break;
Execution Count:856
856
4251 case MinuteSection: minute = newVal; break;
executed: break;
Execution Count:470
470
4252 case SecondSection: second = newVal; break;
executed: break;
Execution Count:434
434
4253 case MSecSection: msec = newVal; break;
executed: break;
Execution Count:36
36
4254 case YearSection2Digits: -
4255 case YearSection: year = newVal; break;
executed: break;
Execution Count:631
631
4256 case MonthSection: month = newVal; break;
executed: break;
Execution Count:62
62
4257 case DaySection: -
4258 case DayOfWeekSectionShort: -
4259 case DayOfWeekSectionLong: -
4260 if (newVal > 31) {
partially evaluated: newVal > 31
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:162
0-162
4261 // have to keep legacy behavior. setting the -
4262 // date to 32 should return false. Setting it -
4263 // to 31 for february should return true -
4264 return false;
never executed: return false;
0
4265 } -
4266 day = newVal;
executed (the execution status of this line is deduced): day = newVal;
-
4267 break;
executed: break;
Execution Count:162
162
4268 case AmPmSection: hour = (newVal == 0 ? hour % 12 : (hour % 12) + 12); break;
executed: break;
Execution Count:6
evaluated: newVal == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
2-6
4269 default: -
4270 qWarning("QDateTimeParser::setDigit() Internal error (%s)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4270, __PRETTY_FUNCTION__).warning("QDateTimeParser::setDigit() Internal error (%s)",
-
4271 qPrintable(sectionName(node.type)));
never executed (the execution status of this line is deduced): QString(sectionName(node.type)).toLocal8Bit().constData());
-
4272 break;
never executed: break;
0
4273 } -
4274 -
4275 if (!(node.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) {
evaluated: !(node.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))
TRUEFALSE
yes
Evaluation Count:2495
yes
Evaluation Count:162
162-2495
4276 if (day < cachedDay)
evaluated: day < cachedDay
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2486
9-2486
4277 day = cachedDay;
executed: day = cachedDay;
Execution Count:9
9
4278 const int max = QDate(year, month, 1).daysInMonth();
executed (the execution status of this line is deduced): const int max = QDate(year, month, 1).daysInMonth();
-
4279 if (day > max) {
evaluated: day > max
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:2435
60-2435
4280 day = max;
executed (the execution status of this line is deduced): day = max;
-
4281 }
executed: }
Execution Count:60
60
4282 }
executed: }
Execution Count:2495
2495
4283 if (QDate::isValid(year, month, day) && QTime::isValid(hour, minute, second, msec)) {
evaluated: QDate::isValid(year, month, day)
TRUEFALSE
yes
Evaluation Count:2618
yes
Evaluation Count:39
partially evaluated: QTime::isValid(hour, minute, second, msec)
TRUEFALSE
yes
Evaluation Count:2618
no
Evaluation Count:0
0-2618
4284 v = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), spec);
executed (the execution status of this line is deduced): v = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), spec);
-
4285 return true;
executed: return true;
Execution Count:2618
2618
4286 } -
4287 return false;
executed: return false;
Execution Count:39
39
4288} -
4289 -
4290 -
4291 -
4292/*! -
4293 \ -
4294 -
4295 Returns the absolute maximum for a section -
4296*/ -
4297 -
4298int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const -
4299{ -
4300 const SectionNode &sn = sectionNode(s);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(s);
-
4301 switch (sn.type) { -
4302 case Hour24Section: -
4303 case Hour12Section: return 23; // this is special-cased in
executed: return 23;
Execution Count:2705
2705
4304 // parseSection. We want it to be -
4305 // 23 for the stepBy case. -
4306 case MinuteSection: -
4307 case SecondSection: return 59;
executed: return 59;
Execution Count:4210
4210
4308 case MSecSection: return 999;
executed: return 999;
Execution Count:241
241
4309 case YearSection2Digits: -
4310 case YearSection: return 9999; // sectionMaxSize will prevent
executed: return 9999;
Execution Count:2220
2220
4311 // people from typing in a larger -
4312 // number in count == 2 sections. -
4313 // stepBy() will work on real years anyway -
4314 case MonthSection: return 12;
executed: return 12;
Execution Count:1065
1065
4315 case DaySection: -
4316 case DayOfWeekSectionShort: -
4317 case DayOfWeekSectionLong: return cur.isValid() ? cur.date().daysInMonth() : 31;
executed: return cur.isValid() ? cur.date().daysInMonth() : 31;
Execution Count:1834
1834
4318 case AmPmSection: return 1;
executed: return 1;
Execution Count:6
6
4319 default: break;
never executed: break;
0
4320 } -
4321 qWarning("QDateTimeParser::absoluteMax() Internal error (%s)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4321, __PRETTY_FUNCTION__).warning("QDateTimeParser::absoluteMax() Internal error (%s)",
-
4322 qPrintable(sectionName(sn.type)));
never executed (the execution status of this line is deduced): QString(sectionName(sn.type)).toLocal8Bit().constData());
-
4323 return -1;
never executed: return -1;
0
4324} -
4325 -
4326/*! -
4327 \internal -
4328 -
4329 Returns the absolute minimum for a section -
4330*/ -
4331 -
4332int QDateTimeParser::absoluteMin(int s) const -
4333{ -
4334 const SectionNode &sn = sectionNode(s);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(s);
-
4335 switch (sn.type) { -
4336 case Hour24Section: -
4337 case Hour12Section: -
4338 case MinuteSection: -
4339 case SecondSection: -
4340 case MSecSection: -
4341 case YearSection2Digits: -
4342 case YearSection: return 0;
executed: return 0;
Execution Count:9350
9350
4343 case MonthSection: -
4344 case DaySection: -
4345 case DayOfWeekSectionShort: -
4346 case DayOfWeekSectionLong: return 1;
executed: return 1;
Execution Count:2871
2871
4347 case AmPmSection: return 0;
executed: return 0;
Execution Count:6
6
4348 default: break;
never executed: break;
0
4349 } -
4350 qWarning("QDateTimeParser::absoluteMin() Internal error (%s, %0x)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4350, __PRETTY_FUNCTION__).warning("QDateTimeParser::absoluteMin() Internal error (%s, %0x)",
-
4351 qPrintable(sectionName(sn.type)), sn.type);
never executed (the execution status of this line is deduced): QString(sectionName(sn.type)).toLocal8Bit().constData(), sn.type);
-
4352 return -1;
never executed: return -1;
0
4353} -
4354 -
4355/*! -
4356 \internal -
4357 -
4358 Returns the sectionNode for the Section \a s. -
4359*/ -
4360 -
4361const QDateTimeParser::SectionNode &QDateTimeParser::sectionNode(int sectionIndex) const -
4362{ -
4363 if (sectionIndex < 0) {
evaluated: sectionIndex < 0
TRUEFALSE
yes
Evaluation Count:237
yes
Evaluation Count:108525
237-108525
4364 switch (sectionIndex) { -
4365 case FirstSectionIndex: -
4366 return first;
executed: return first;
Execution Count:122
122
4367 case LastSectionIndex: -
4368 return last;
executed: return last;
Execution Count:4
4
4369 case NoSectionIndex: -
4370 return none;
executed: return none;
Execution Count:111
111
4371 } -
4372 } else if (sectionIndex < sectionNodes.size()) {
never executed: }
partially evaluated: sectionIndex < sectionNodes.size()
TRUEFALSE
yes
Evaluation Count:108525
no
Evaluation Count:0
0-108525
4373 return sectionNodes.at(sectionIndex);
executed: return sectionNodes.at(sectionIndex);
Execution Count:108525
108525
4374 } -
4375 -
4376 qWarning("QDateTimeParser::sectionNode() Internal error (%d)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4376, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionNode() Internal error (%d)",
-
4377 sectionIndex);
never executed (the execution status of this line is deduced): sectionIndex);
-
4378 return none;
never executed: return none;
0
4379} -
4380 -
4381QDateTimeParser::Section QDateTimeParser::sectionType(int sectionIndex) const -
4382{ -
4383 return sectionNode(sectionIndex).type;
executed: return sectionNode(sectionIndex).type;
Execution Count:4768
4768
4384} -
4385 -
4386 -
4387/*! -
4388 \internal -
4389 -
4390 Returns the starting position for section \a s. -
4391*/ -
4392 -
4393int QDateTimeParser::sectionPos(int sectionIndex) const -
4394{ -
4395 return sectionPos(sectionNode(sectionIndex));
executed: return sectionPos(sectionNode(sectionIndex));
Execution Count:37116
37116
4396} -
4397 -
4398int QDateTimeParser::sectionPos(const SectionNode &sn) const -
4399{ -
4400 switch (sn.type) { -
4401 case FirstSection: return 0;
executed: return 0;
Execution Count:63
63
4402 case LastSection: return displayText().size() - 1;
never executed: return displayText().size() - 1;
0
4403 default: break;
executed: break;
Execution Count:38940
38940
4404 } -
4405 if (sn.pos == -1) {
partially evaluated: sn.pos == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:38940
0-38940
4406 qWarning("QDateTimeParser::sectionPos Internal error (%s)", qPrintable(sectionName(sn.type)));
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4406, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionPos Internal error (%s)", QString(sectionName(sn.type)).toLocal8Bit().constData());
-
4407 return -1;
never executed: return -1;
0
4408 } -
4409 return sn.pos;
executed: return sn.pos;
Execution Count:38940
38940
4410} -
4411 -
4412 -
4413/*! -
4414 \internal -
4415 -
4416 helper function for parseFormat. removes quotes that are -
4417 not escaped and removes the escaping on those that are escaped -
4418 -
4419*/ -
4420 -
4421static QString unquote(const QString &str) -
4422{ -
4423 const QChar quote(QLatin1Char('\''));
executed (the execution status of this line is deduced): const QChar quote(QLatin1Char('\''));
-
4424 const QChar slash(QLatin1Char('\\'));
executed (the execution status of this line is deduced): const QChar slash(QLatin1Char('\\'));
-
4425 const QChar zero(QLatin1Char('0'));
executed (the execution status of this line is deduced): const QChar zero(QLatin1Char('0'));
-
4426 QString ret;
executed (the execution status of this line is deduced): QString ret;
-
4427 QChar status(zero);
executed (the execution status of this line is deduced): QChar status(zero);
-
4428 const int max = str.size();
executed (the execution status of this line is deduced): const int max = str.size();
-
4429 for (int i=0; i<max; ++i) {
evaluated: i<max
TRUEFALSE
yes
Evaluation Count:460
yes
Evaluation Count:417
417-460
4430 if (str.at(i) == quote) {
evaluated: str.at(i) == quote
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:413
47-413
4431 if (status != quote) {
evaluated: status != quote
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:23
23-24
4432 status = quote;
executed (the execution status of this line is deduced): status = quote;
-
4433 } else if (!ret.isEmpty() && str.at(i - 1) == slash) {
executed: }
Execution Count:24
evaluated: !ret.isEmpty()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:1
partially evaluated: str.at(i - 1) == slash
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22
0-24
4434 ret[ret.size() - 1] = quote;
never executed (the execution status of this line is deduced): ret[ret.size() - 1] = quote;
-
4435 } else {
never executed: }
0
4436 status = zero;
executed (the execution status of this line is deduced): status = zero;
-
4437 }
executed: }
Execution Count:23
23
4438 } else { -
4439 ret += str.at(i);
executed (the execution status of this line is deduced): ret += str.at(i);
-
4440 }
executed: }
Execution Count:413
413
4441 } -
4442 return ret;
executed: return ret;
Execution Count:417
417
4443} -
4444/*! -
4445 \internal -
4446 -
4447 Parses the format \a newFormat. If successful, returns true and -
4448 sets up the format. Else keeps the old format and returns false. -
4449 -
4450*/ -
4451 -
4452static inline int countRepeat(const QString &str, int index, int maxCount) -
4453{ -
4454 int count = 1;
executed (the execution status of this line is deduced): int count = 1;
-
4455 const QChar ch(str.at(index));
executed (the execution status of this line is deduced): const QChar ch(str.at(index));
-
4456 const int max = qMin(index + maxCount, str.size());
executed (the execution status of this line is deduced): const int max = qMin(index + maxCount, str.size());
-
4457 while (index + count < max && str.at(index + count) == ch) {
evaluated: index + count < max
TRUEFALSE
yes
Evaluation Count:3496
yes
Evaluation Count:1198
evaluated: str.at(index + count) == ch
TRUEFALSE
yes
Evaluation Count:2662
yes
Evaluation Count:834
834-3496
4458 ++count;
executed (the execution status of this line is deduced): ++count;
-
4459 }
executed: }
Execution Count:2662
2662
4460 return count;
executed: return count;
Execution Count:2032
2032
4461} -
4462 -
4463static inline void appendSeparator(QStringList *list, const QString &string, int from, int size, int lastQuote) -
4464{ -
4465 QString str(string.mid(from, size));
executed (the execution status of this line is deduced): QString str(string.mid(from, size));
-
4466 if (lastQuote >= from)
evaluated: lastQuote >= from
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:1720
21-1720
4467 str = unquote(str);
executed: str = unquote(str);
Execution Count:21
21
4468 list->append(str);
executed (the execution status of this line is deduced): list->append(str);
-
4469}
executed: }
Execution Count:1741
1741
4470 -
4471 -
4472bool QDateTimeParser::parseFormat(const QString &newFormat) -
4473{ -
4474 const QLatin1Char quote('\'');
executed (the execution status of this line is deduced): const QLatin1Char quote('\'');
-
4475 const QLatin1Char slash('\\');
executed (the execution status of this line is deduced): const QLatin1Char slash('\\');
-
4476 const QLatin1Char zero('0');
executed (the execution status of this line is deduced): const QLatin1Char zero('0');
-
4477 if (newFormat == displayFormat && !newFormat.isEmpty()) {
evaluated: newFormat == displayFormat
TRUEFALSE
yes
Evaluation Count:124
yes
Evaluation Count:561
evaluated: !newFormat.isEmpty()
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:2
2-561
4478 return true;
executed: return true;
Execution Count:122
122
4479 } -
4480 -
4481 QDTPDEBUGN("parseFormat: %s", newFormat.toLatin1().constData());
never executed: QMessageLogger("tools/qdatetime.cpp", 4481, __PRETTY_FUNCTION__).debug("parseFormat: %s", newFormat.toLatin1().constData());
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:563
0-563
4482 -
4483 QVector<SectionNode> newSectionNodes;
executed (the execution status of this line is deduced): QVector<SectionNode> newSectionNodes;
-
4484 Sections newDisplay = 0;
executed (the execution status of this line is deduced): Sections newDisplay = 0;
-
4485 QStringList newSeparators;
executed (the execution status of this line is deduced): QStringList newSeparators;
-
4486 int i, index = 0;
executed (the execution status of this line is deduced): int i, index = 0;
-
4487 int add = 0;
executed (the execution status of this line is deduced): int add = 0;
-
4488 QChar status(zero);
executed (the execution status of this line is deduced): QChar status(zero);
-
4489 const int max = newFormat.size();
executed (the execution status of this line is deduced): const int max = newFormat.size();
-
4490 int lastQuote = -1;
executed (the execution status of this line is deduced): int lastQuote = -1;
-
4491 for (i = 0; i<max; ++i) {
evaluated: i<max
TRUEFALSE
yes
Evaluation Count:3723
yes
Evaluation Count:563
563-3723
4492 if (newFormat.at(i) == quote) {
evaluated: newFormat.at(i) == quote
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:3676
47-3676
4493 lastQuote = i;
executed (the execution status of this line is deduced): lastQuote = i;
-
4494 ++add;
executed (the execution status of this line is deduced): ++add;
-
4495 if (status != quote) {
evaluated: status != quote
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:23
23-24
4496 status = quote;
executed (the execution status of this line is deduced): status = quote;
-
4497 } else if (newFormat.at(i - 1) != slash) {
executed: }
Execution Count:24
partially evaluated: newFormat.at(i - 1) != slash
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-24
4498 status = zero;
executed (the execution status of this line is deduced): status = zero;
-
4499 }
executed: }
Execution Count:23
23
4500 } else if (status != quote) {
evaluated: status != quote
TRUEFALSE
yes
Evaluation Count:3612
yes
Evaluation Count:64
64-3612
4501 const char sect = newFormat.at(i).toLatin1();
executed (the execution status of this line is deduced): const char sect = newFormat.at(i).toLatin1();
-
4502 switch (sect) { -
4503 case 'H': -
4504 case 'h': -
4505 if (parserType != QVariant::Date) {
evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:277
yes
Evaluation Count:3
3-277
4506 const Section hour = (sect == 'h') ? Hour12Section : Hour24Section;
evaluated: (sect == 'h')
TRUEFALSE
yes
Evaluation Count:206
yes
Evaluation Count:71
71-206
4507 const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 };
executed (the execution status of this line is deduced): const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 };
-
4508 newSectionNodes.append(sn);
executed (the execution status of this line is deduced): newSectionNodes.append(sn);
-
4509 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
executed (the execution status of this line is deduced): appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
-
4510 i += sn.count - 1;
executed (the execution status of this line is deduced): i += sn.count - 1;
-
4511 index = i + 1;
executed (the execution status of this line is deduced): index = i + 1;
-
4512 newDisplay |= hour;
executed (the execution status of this line is deduced): newDisplay |= hour;
-
4513 }
executed: }
Execution Count:277
277
4514 break;
executed: break;
Execution Count:280
280
4515 case 'm': -
4516 if (parserType != QVariant::Date) {
partially evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:257
no
Evaluation Count:0
0-257
4517 const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 };
executed (the execution status of this line is deduced): const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 };
-
4518 newSectionNodes.append(sn);
executed (the execution status of this line is deduced): newSectionNodes.append(sn);
-
4519 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
executed (the execution status of this line is deduced): appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
-
4520 i += sn.count - 1;
executed (the execution status of this line is deduced): i += sn.count - 1;
-
4521 index = i + 1;
executed (the execution status of this line is deduced): index = i + 1;
-
4522 newDisplay |= MinuteSection;
executed (the execution status of this line is deduced): newDisplay |= MinuteSection;
-
4523 }
executed: }
Execution Count:257
257
4524 break;
executed: break;
Execution Count:257
257
4525 case 's': -
4526 if (parserType != QVariant::Date) {
partially evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:236
no
Evaluation Count:0
0-236
4527 const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 };
executed (the execution status of this line is deduced): const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 };
-
4528 newSectionNodes.append(sn);
executed (the execution status of this line is deduced): newSectionNodes.append(sn);
-
4529 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
executed (the execution status of this line is deduced): appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
-
4530 i += sn.count - 1;
executed (the execution status of this line is deduced): i += sn.count - 1;
-
4531 index = i + 1;
executed (the execution status of this line is deduced): index = i + 1;
-
4532 newDisplay |= SecondSection;
executed (the execution status of this line is deduced): newDisplay |= SecondSection;
-
4533 }
executed: }
Execution Count:236
236
4534 break;
executed: break;
Execution Count:236
236
4535 -
4536 case 'z': -
4537 if (parserType != QVariant::Date) {
partially evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:51
no
Evaluation Count:0
0-51
4538 const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 };
executed (the execution status of this line is deduced): const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 };
-
4539 newSectionNodes.append(sn);
executed (the execution status of this line is deduced): newSectionNodes.append(sn);
-
4540 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
executed (the execution status of this line is deduced): appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
-
4541 i += sn.count - 1;
executed (the execution status of this line is deduced): i += sn.count - 1;
-
4542 index = i + 1;
executed (the execution status of this line is deduced): index = i + 1;
-
4543 newDisplay |= MSecSection;
executed (the execution status of this line is deduced): newDisplay |= MSecSection;
-
4544 }
executed: }
Execution Count:51
51
4545 break;
executed: break;
Execution Count:51
51
4546 case 'A': -
4547 case 'a': -
4548 if (parserType != QVariant::Date) {
evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:94
yes
Evaluation Count:2
2-94
4549 const bool cap = (sect == 'A');
executed (the execution status of this line is deduced): const bool cap = (sect == 'A');
-
4550 const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 };
executed (the execution status of this line is deduced): const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 };
-
4551 newSectionNodes.append(sn);
executed (the execution status of this line is deduced): newSectionNodes.append(sn);
-
4552 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
executed (the execution status of this line is deduced): appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
-
4553 newDisplay |= AmPmSection;
executed (the execution status of this line is deduced): newDisplay |= AmPmSection;
-
4554 if (i + 1 < newFormat.size()
evaluated: i + 1 < newFormat.size()
TRUEFALSE
yes
Evaluation Count:93
yes
Evaluation Count:1
1-93
4555 && newFormat.at(i+1) == (cap ? QLatin1Char('P') : QLatin1Char('p'))) {
partially evaluated: newFormat.at(i+1) == (cap ? QLatin1Char('P') : QLatin1Char('p'))
TRUEFALSE
yes
Evaluation Count:93
no
Evaluation Count:0
evaluated: cap
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:76
0-93
4556 ++i;
executed (the execution status of this line is deduced): ++i;
-
4557 }
executed: }
Execution Count:93
93
4558 index = i + 1;
executed (the execution status of this line is deduced): index = i + 1;
-
4559 }
executed: }
Execution Count:94
94
4560 break;
executed: break;
Execution Count:96
96
4561 case 'y': -
4562 if (parserType != QVariant::Time) {
evaluated: parserType != QVariant::Time
TRUEFALSE
yes
Evaluation Count:397
yes
Evaluation Count:4
4-397
4563 const int repeat = countRepeat(newFormat, i, 4);
executed (the execution status of this line is deduced): const int repeat = countRepeat(newFormat, i, 4);
-
4564 if (repeat >= 2) {
evaluated: repeat >= 2
TRUEFALSE
yes
Evaluation Count:390
yes
Evaluation Count:7
7-390
4565 const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits,
executed (the execution status of this line is deduced): const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits,
-
4566 i - add, repeat == 4 ? 4 : 2, 0 };
executed (the execution status of this line is deduced): i - add, repeat == 4 ? 4 : 2, 0 };
-
4567 newSectionNodes.append(sn);
executed (the execution status of this line is deduced): newSectionNodes.append(sn);
-
4568 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
executed (the execution status of this line is deduced): appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
-
4569 i += sn.count - 1;
executed (the execution status of this line is deduced): i += sn.count - 1;
-
4570 index = i + 1;
executed (the execution status of this line is deduced): index = i + 1;
-
4571 newDisplay |= sn.type;
executed (the execution status of this line is deduced): newDisplay |= sn.type;
-
4572 }
executed: }
Execution Count:390
390
4573 }
executed: }
Execution Count:397
397
4574 break;
executed: break;
Execution Count:401
401
4575 case 'M': -
4576 if (parserType != QVariant::Time) {
partially evaluated: parserType != QVariant::Time
TRUEFALSE
yes
Evaluation Count:396
no
Evaluation Count:0
0-396
4577 const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 };
executed (the execution status of this line is deduced): const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 };
-
4578 newSectionNodes.append(sn);
executed (the execution status of this line is deduced): newSectionNodes.append(sn);
-
4579 newSeparators.append(unquote(newFormat.mid(index, i - index)));
executed (the execution status of this line is deduced): newSeparators.append(unquote(newFormat.mid(index, i - index)));
-
4580 i += sn.count - 1;
executed (the execution status of this line is deduced): i += sn.count - 1;
-
4581 index = i + 1;
executed (the execution status of this line is deduced): index = i + 1;
-
4582 newDisplay |= MonthSection;
executed (the execution status of this line is deduced): newDisplay |= MonthSection;
-
4583 }
executed: }
Execution Count:396
396
4584 break;
executed: break;
Execution Count:396
396
4585 case 'd': -
4586 if (parserType != QVariant::Time) {
partially evaluated: parserType != QVariant::Time
TRUEFALSE
yes
Evaluation Count:418
no
Evaluation Count:0
0-418
4587 const int repeat = countRepeat(newFormat, i, 4);
executed (the execution status of this line is deduced): const int repeat = countRepeat(newFormat, i, 4);
-
4588 const Section sectionType = (repeat == 4 ? DayOfWeekSectionLong
evaluated: repeat == 4
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:397
21-397
4589 : (repeat == 3 ? DayOfWeekSectionShort : DaySection));
executed (the execution status of this line is deduced): : (repeat == 3 ? DayOfWeekSectionShort : DaySection));
-
4590 const SectionNode sn = { sectionType, i - add, repeat, 0 };
executed (the execution status of this line is deduced): const SectionNode sn = { sectionType, i - add, repeat, 0 };
-
4591 newSectionNodes.append(sn);
executed (the execution status of this line is deduced): newSectionNodes.append(sn);
-
4592 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
executed (the execution status of this line is deduced): appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
-
4593 i += sn.count - 1;
executed (the execution status of this line is deduced): i += sn.count - 1;
-
4594 index = i + 1;
executed (the execution status of this line is deduced): index = i + 1;
-
4595 newDisplay |= sn.type;
executed (the execution status of this line is deduced): newDisplay |= sn.type;
-
4596 }
executed: }
Execution Count:418
418
4597 break;
executed: break;
Execution Count:418
418
4598 -
4599 default: -
4600 break;
executed: break;
Execution Count:1477
1477
4601 } -
4602 }
executed: }
Execution Count:3612
3612
4603 } -
4604 if (newSectionNodes.isEmpty() && context == DateTimeEdit) {
evaluated: newSectionNodes.isEmpty()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:552
evaluated: context == DateTimeEdit
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:9
2-552
4605 return false;
executed: return false;
Execution Count:2
2
4606 } -
4607 -
4608 if ((newDisplay & (AmPmSection|Hour12Section)) == Hour12Section) {
evaluated: (newDisplay & (AmPmSection|Hour12Section)) == Hour12Section
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:456
105-456
4609 const int max = newSectionNodes.size();
executed (the execution status of this line is deduced): const int max = newSectionNodes.size();
-
4610 for (int i=0; i<max; ++i) {
evaluated: i<max
TRUEFALSE
yes
Evaluation Count:435
yes
Evaluation Count:105
105-435
4611 SectionNode &node = newSectionNodes[i];
executed (the execution status of this line is deduced): SectionNode &node = newSectionNodes[i];
-
4612 if (node.type == Hour12Section)
evaluated: node.type == Hour12Section
TRUEFALSE
yes
Evaluation Count:118
yes
Evaluation Count:317
118-317
4613 node.type = Hour24Section;
executed: node.type = Hour24Section;
Execution Count:118
118
4614 }
executed: }
Execution Count:435
435
4615 }
executed: }
Execution Count:105
105
4616 -
4617 if (index < newFormat.size()) {
evaluated: index < newFormat.size()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:543
18-543
4618 appendSeparator(&newSeparators, newFormat, index, index - max, lastQuote);
executed (the execution status of this line is deduced): appendSeparator(&newSeparators, newFormat, index, index - max, lastQuote);
-
4619 } else {
executed: }
Execution Count:18
18
4620 newSeparators.append(QString());
executed (the execution status of this line is deduced): newSeparators.append(QString());
-
4621 }
executed: }
Execution Count:543
543
4622 -
4623 displayFormat = newFormat;
executed (the execution status of this line is deduced): displayFormat = newFormat;
-
4624 separators = newSeparators;
executed (the execution status of this line is deduced): separators = newSeparators;
-
4625 sectionNodes = newSectionNodes;
executed (the execution status of this line is deduced): sectionNodes = newSectionNodes;
-
4626 display = newDisplay;
executed (the execution status of this line is deduced): display = newDisplay;
-
4627 last.pos = -1;
executed (the execution status of this line is deduced): last.pos = -1;
-
4628 -
4629// for (int i=0; i<sectionNodes.size(); ++i) { -
4630// QDTPDEBUG << sectionName(sectionNodes.at(i).type) << sectionNodes.at(i).count; -
4631// } -
4632 -
4633 QDTPDEBUG << newFormat << displayFormat;
never executed: QMessageLogger("tools/qdatetime.cpp", 4633, __PRETTY_FUNCTION__).debug() << newFormat << displayFormat;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:561
0-561
4634 QDTPDEBUGN("separators:\n'%s'", separators.join(QLatin1String("\n")).toLatin1().constData());
never executed: QMessageLogger("tools/qdatetime.cpp", 4634, __PRETTY_FUNCTION__).debug("separators:\n'%s'", separators.join(QLatin1String("\n")).toLatin1().constData());
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:561
0-561
4635 -
4636 return true;
executed: return true;
Execution Count:561
561
4637} -
4638 -
4639/*! -
4640 \internal -
4641 -
4642 Returns the size of section \a s. -
4643*/ -
4644 -
4645int QDateTimeParser::sectionSize(int sectionIndex) const -
4646{ -
4647 if (sectionIndex < 0)
partially evaluated: sectionIndex < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14087
0-14087
4648 return 0;
never executed: return 0;
0
4649 -
4650 if (sectionIndex >= sectionNodes.size()) {
partially evaluated: sectionIndex >= sectionNodes.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14087
0-14087
4651 qWarning("QDateTimeParser::sectionSize Internal error (%d)", sectionIndex);
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4651, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionSize Internal error (%d)", sectionIndex);
-
4652 return -1;
never executed: return -1;
0
4653 } -
4654 -
4655 if (sectionIndex == sectionNodes.size() - 1) {
evaluated: sectionIndex == sectionNodes.size() - 1
TRUEFALSE
yes
Evaluation Count:3539
yes
Evaluation Count:10548
3539-10548
4656 // In some cases there is a difference between displayText() and text. -
4657 // e.g. when text is 2000/01/31 and displayText() is "2000/2/31" - text -
4658 // is the previous value and displayText() is the new value. -
4659 // The size difference is always due to leading zeroes. -
4660 int sizeAdjustment = 0;
executed (the execution status of this line is deduced): int sizeAdjustment = 0;
-
4661 if (displayText().size() != text.size()) {
evaluated: displayText().size() != text.size()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:3524
15-3524
4662 // Any zeroes added before this section will affect our size. -
4663 int preceedingZeroesAdded = 0;
executed (the execution status of this line is deduced): int preceedingZeroesAdded = 0;
-
4664 if (sectionNodes.size() > 1 && context == DateTimeEdit) {
partially evaluated: sectionNodes.size() > 1
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
partially evaluated: context == DateTimeEdit
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-15
4665 for (QVector<SectionNode>::ConstIterator sectionIt = sectionNodes.constBegin();
executed (the execution status of this line is deduced): for (QVector<SectionNode>::ConstIterator sectionIt = sectionNodes.constBegin();
-
4666 sectionIt != sectionNodes.constBegin() + sectionIndex; ++sectionIt) {
evaluated: sectionIt != sectionNodes.constBegin() + sectionIndex
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:15
15-24
4667 preceedingZeroesAdded += sectionIt->zeroesAdded;
executed (the execution status of this line is deduced): preceedingZeroesAdded += sectionIt->zeroesAdded;
-
4668 }
executed: }
Execution Count:24
24
4669 }
executed: }
Execution Count:15
15
4670 sizeAdjustment = preceedingZeroesAdded;
executed (the execution status of this line is deduced): sizeAdjustment = preceedingZeroesAdded;
-
4671 }
executed: }
Execution Count:15
15
4672 -
4673 return displayText().size() + sizeAdjustment - sectionPos(sectionIndex) - separators.last().size();
executed: return displayText().size() + sizeAdjustment - sectionPos(sectionIndex) - separators.last().size();
Execution Count:3539
3539
4674 } else { -
4675 return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex)
executed: return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex) - separators.at(sectionIndex + 1).size();
Execution Count:10548
10548
4676 - separators.at(sectionIndex + 1).size();
executed: return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex) - separators.at(sectionIndex + 1).size();
Execution Count:10548
10548
4677 } -
4678} -
4679 -
4680 -
4681int QDateTimeParser::sectionMaxSize(Section s, int count) const -
4682{ -
4683#ifndef QT_NO_TEXTDATE -
4684 int mcount = 12;
executed (the execution status of this line is deduced): int mcount = 12;
-
4685#endif -
4686 -
4687 switch (s) { -
4688 case FirstSection: -
4689 case NoSection: -
4690 case LastSection: return 0;
never executed: return 0;
0
4691 -
4692 case AmPmSection: { -
4693 const int lowerMax = qMin(getAmPmText(AmText, LowerCase).size(),
executed (the execution status of this line is deduced): const int lowerMax = qMin(getAmPmText(AmText, LowerCase).size(),
-
4694 getAmPmText(PmText, LowerCase).size());
executed (the execution status of this line is deduced): getAmPmText(PmText, LowerCase).size());
-
4695 const int upperMax = qMin(getAmPmText(AmText, UpperCase).size(),
executed (the execution status of this line is deduced): const int upperMax = qMin(getAmPmText(AmText, UpperCase).size(),
-
4696 getAmPmText(PmText, UpperCase).size());
executed (the execution status of this line is deduced): getAmPmText(PmText, UpperCase).size());
-
4697 return qMin(4, qMin(lowerMax, upperMax));
executed: return qMin(4, qMin(lowerMax, upperMax));
Execution Count:1728
1728
4698 } -
4699 -
4700 case Hour24Section: -
4701 case Hour12Section: -
4702 case MinuteSection: -
4703 case SecondSection: -
4704 case DaySection: return 2;
executed: return 2;
Execution Count:7925
7925
4705 case DayOfWeekSectionShort: -
4706 case DayOfWeekSectionLong: -
4707#ifdef QT_NO_TEXTDATE -
4708 return 2; -
4709#else -
4710 mcount = 7;
executed (the execution status of this line is deduced): mcount = 7;
-
4711 // fall through -
4712#endif -
4713 case MonthSection:
code before this statement executed: case MonthSection:
Execution Count:29
29
4714 if (count <= 2)
evaluated: count <= 2
TRUEFALSE
yes
Evaluation Count:1061
yes
Evaluation Count:816
816-1061
4715 return 2;
executed: return 2;
Execution Count:1061
1061
4716 -
4717#ifdef QT_NO_TEXTDATE -
4718 return 2; -
4719#else -
4720 { -
4721 int ret = 0;
executed (the execution status of this line is deduced): int ret = 0;
-
4722 const QLocale l = locale();
executed (the execution status of this line is deduced): const QLocale l = locale();
-
4723 for (int i=1; i<=mcount; ++i) {
evaluated: i<=mcount
TRUEFALSE
yes
Evaluation Count:9647
yes
Evaluation Count:816
816-9647
4724 const QString str = (s == MonthSection
evaluated: s == MonthSection
TRUEFALSE
yes
Evaluation Count:9444
yes
Evaluation Count:203
203-9444
4725 ? l.monthName(i, count == 4 ? QLocale::LongFormat : QLocale::ShortFormat)
executed (the execution status of this line is deduced): ? l.monthName(i, count == 4 ? QLocale::LongFormat : QLocale::ShortFormat)
-
4726 : l.dayName(i, count == 4 ? QLocale::LongFormat : QLocale::ShortFormat));
executed (the execution status of this line is deduced): : l.dayName(i, count == 4 ? QLocale::LongFormat : QLocale::ShortFormat));
-
4727 ret = qMax(str.size(), ret);
executed (the execution status of this line is deduced): ret = qMax(str.size(), ret);
-
4728 }
executed: }
Execution Count:9647
9647
4729 return ret;
executed: return ret;
Execution Count:816
816
4730 } -
4731#endif -
4732 case MSecSection: return 3;
executed: return 3;
Execution Count:269
269
4733 case YearSection: return 4;
executed: return 4;
Execution Count:1200
1200
4734 case YearSection2Digits: return 2;
executed: return 2;
Execution Count:670
670
4735 -
4736 case CalendarPopupSection: -
4737 case Internal: -
4738 case TimeSectionMask: -
4739 case DateSectionMask: -
4740 qWarning("QDateTimeParser::sectionMaxSize: Invalid section %s",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4740, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionMaxSize: Invalid section %s",
-
4741 sectionName(s).toLatin1().constData());
never executed (the execution status of this line is deduced): sectionName(s).toLatin1().constData());
-
4742 -
4743 case NoSectionIndex: -
4744 case FirstSectionIndex: -
4745 case LastSectionIndex: -
4746 case CalendarPopupIndex: -
4747 // these cases can't happen -
4748 break;
never executed: break;
0
4749 } -
4750 return -1;
never executed: return -1;
0
4751} -
4752 -
4753 -
4754int QDateTimeParser::sectionMaxSize(int index) const -
4755{ -
4756 const SectionNode &sn = sectionNode(index);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(index);
-
4757 return sectionMaxSize(sn.type, sn.count);
executed: return sectionMaxSize(sn.type, sn.count);
Execution Count:13669
13669
4758} -
4759 -
4760/*! -
4761 \internal -
4762 -
4763 Returns the text of section \a s. This function operates on the -
4764 arg text rather than edit->text(). -
4765*/ -
4766 -
4767 -
4768QString QDateTimeParser::sectionText(const QString &text, int sectionIndex, int index) const -
4769{ -
4770 const SectionNode &sn = sectionNode(sectionIndex);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(sectionIndex);
-
4771 switch (sn.type) { -
4772 case NoSectionIndex: -
4773 case FirstSectionIndex: -
4774 case LastSectionIndex: -
4775 return QString();
never executed: return QString();
0
4776 default: break;
executed: break;
Execution Count:129
129
4777 } -
4778 -
4779 return text.mid(index, sectionSize(sectionIndex));
executed: return text.mid(index, sectionSize(sectionIndex));
Execution Count:129
129
4780} -
4781 -
4782QString QDateTimeParser::sectionText(int sectionIndex) const -
4783{ -
4784 const SectionNode &sn = sectionNode(sectionIndex);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(sectionIndex);
-
4785 switch (sn.type) { -
4786 case NoSectionIndex: -
4787 case FirstSectionIndex: -
4788 case LastSectionIndex: -
4789 return QString();
never executed: return QString();
0
4790 default: break;
executed: break;
Execution Count:24
24
4791 } -
4792 -
4793 return displayText().mid(sn.pos, sectionSize(sectionIndex));
executed: return displayText().mid(sn.pos, sectionSize(sectionIndex));
Execution Count:24
24
4794} -
4795 -
4796 -
4797#ifndef QT_NO_TEXTDATE -
4798/*! -
4799 \internal:skipToNextSection -
4800 -
4801 Parses the part of \a text that corresponds to \a s and returns -
4802 the value of that field. Sets *stateptr to the right state if -
4803 stateptr != 0. -
4804*/ -
4805 -
4806int QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionIndex, -
4807 QString &text, int &cursorPosition, int index, -
4808 State &state, int *usedptr) const -
4809{ -
4810 state = Invalid;
executed (the execution status of this line is deduced): state = Invalid;
-
4811 int num = 0;
executed (the execution status of this line is deduced): int num = 0;
-
4812 const SectionNode &sn = sectionNode(sectionIndex);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(sectionIndex);
-
4813 if ((sn.type & Internal) == Internal) {
partially evaluated: (sn.type & Internal) == Internal
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11678
0-11678
4814 qWarning("QDateTimeParser::parseSection Internal error (%s %d)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4814, __PRETTY_FUNCTION__).warning("QDateTimeParser::parseSection Internal error (%s %d)",
-
4815 qPrintable(sectionName(sn.type)), sectionIndex);
never executed (the execution status of this line is deduced): QString(sectionName(sn.type)).toLocal8Bit().constData(), sectionIndex);
-
4816 return -1;
never executed: return -1;
0
4817 } -
4818 -
4819 const int sectionmaxsize = sectionMaxSize(sectionIndex);
executed (the execution status of this line is deduced): const int sectionmaxsize = sectionMaxSize(sectionIndex);
-
4820 QString sectiontext = text.mid(index, sectionmaxsize);
executed (the execution status of this line is deduced): QString sectiontext = text.mid(index, sectionmaxsize);
-
4821 int sectiontextSize = sectiontext.size();
executed (the execution status of this line is deduced): int sectiontextSize = sectiontext.size();
-
4822 -
4823 QDTPDEBUG << "sectionValue for" << sectionName(sn.type)
never executed: QMessageLogger("tools/qdatetime.cpp", 4823, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sectionName(sn.type) << "with text" << text << "and st" << sectiontext << text.mid(index, sectionmaxsize) << index;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11678
0-11678
4824 << "with text" << text << "and st" << sectiontext
never executed: QMessageLogger("tools/qdatetime.cpp", 4823, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sectionName(sn.type) << "with text" << text << "and st" << sectiontext << text.mid(index, sectionmaxsize) << index;
0
4825 << text.mid(index, sectionmaxsize)
never executed: QMessageLogger("tools/qdatetime.cpp", 4823, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sectionName(sn.type) << "with text" << text << "and st" << sectiontext << text.mid(index, sectionmaxsize) << index;
0
4826 << index;
never executed: QMessageLogger("tools/qdatetime.cpp", 4823, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sectionName(sn.type) << "with text" << text << "and st" << sectiontext << text.mid(index, sectionmaxsize) << index;
0
4827 -
4828 int used = 0;
executed (the execution status of this line is deduced): int used = 0;
-
4829 switch (sn.type) { -
4830 case AmPmSection: { -
4831 const int ampm = findAmPm(sectiontext, sectionIndex, &used);
executed (the execution status of this line is deduced): const int ampm = findAmPm(sectiontext, sectionIndex, &used);
-
4832 switch (ampm) { -
4833 case AM: // sectiontext == AM -
4834 case PM: // sectiontext == PM -
4835 num = ampm;
executed (the execution status of this line is deduced): num = ampm;
-
4836 state = Acceptable;
executed (the execution status of this line is deduced): state = Acceptable;
-
4837 break;
executed: break;
Execution Count:862
862
4838 case PossibleAM: // sectiontext => AM -
4839 case PossiblePM: // sectiontext => PM -
4840 num = ampm - 2;
never executed (the execution status of this line is deduced): num = ampm - 2;
-
4841 state = Intermediate;
never executed (the execution status of this line is deduced): state = Intermediate;
-
4842 break;
never executed: break;
0
4843 case PossibleBoth: // sectiontext => AM|PM -
4844 num = 0;
never executed (the execution status of this line is deduced): num = 0;
-
4845 state = Intermediate;
never executed (the execution status of this line is deduced): state = Intermediate;
-
4846 break;
never executed: break;
0
4847 case Neither: -
4848 state = Invalid;
executed (the execution status of this line is deduced): state = Invalid;
-
4849 QDTPDEBUG << "invalid because findAmPm(" << sectiontext << ") returned -1";
never executed: QMessageLogger("tools/qdatetime.cpp", 4849, __PRETTY_FUNCTION__).debug() << "invalid because findAmPm(" << sectiontext << ") returned -1";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
4850 break;
executed: break;
Execution Count:2
2
4851 default: -
4852 QDTPDEBUGN("This should never happen (findAmPm returned %d)", ampm);
never executed: QMessageLogger("tools/qdatetime.cpp", 4852, __PRETTY_FUNCTION__).debug("This should never happen (findAmPm returned %d)", ampm);
never evaluated: false
0
4853 break;
never executed: break;
0
4854 } -
4855 if (state != Invalid) {
evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:862
yes
Evaluation Count:2
2-862
4856 QString str = text;
executed (the execution status of this line is deduced): QString str = text;
-
4857 text.replace(index, used, sectiontext.left(used));
executed (the execution status of this line is deduced): text.replace(index, used, sectiontext.left(used));
-
4858 }
executed: }
Execution Count:862
862
4859 break; }
executed: break;
Execution Count:864
864
4860 case MonthSection: -
4861 case DayOfWeekSectionShort: -
4862 case DayOfWeekSectionLong: -
4863 if (sn.count >= 3) {
evaluated: sn.count >= 3
TRUEFALSE
yes
Evaluation Count:813
yes
Evaluation Count:1009
813-1009
4864 if (sn.type == MonthSection) {
evaluated: sn.type == MonthSection
TRUEFALSE
yes
Evaluation Count:784
yes
Evaluation Count:29
29-784
4865 int min = 1;
executed (the execution status of this line is deduced): int min = 1;
-
4866 const QDate minDate = getMinimum().date();
executed (the execution status of this line is deduced): const QDate minDate = getMinimum().date();
-
4867 if (currentValue.date().year() == minDate.year()) {
evaluated: currentValue.date().year() == minDate.year()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:767
17-767
4868 min = minDate.month();
executed (the execution status of this line is deduced): min = minDate.month();
-
4869 }
executed: }
Execution Count:17
17
4870 num = findMonth(sectiontext.toLower(), min, sectionIndex, &sectiontext, &used);
executed (the execution status of this line is deduced): num = findMonth(sectiontext.toLower(), min, sectionIndex, &sectiontext, &used);
-
4871 } else {
executed: }
Execution Count:784
784
4872 num = findDay(sectiontext.toLower(), 1, sectionIndex, &sectiontext, &used);
executed (the execution status of this line is deduced): num = findDay(sectiontext.toLower(), 1, sectionIndex, &sectiontext, &used);
-
4873 }
executed: }
Execution Count:29
29
4874 -
4875 if (num != -1) {
evaluated: num != -1
TRUEFALSE
yes
Evaluation Count:807
yes
Evaluation Count:6
6-807
4876 state = (used == sectiontext.size() ? Acceptable : Intermediate);
evaluated: used == sectiontext.size()
TRUEFALSE
yes
Evaluation Count:700
yes
Evaluation Count:107
107-700
4877 QString str = text;
executed (the execution status of this line is deduced): QString str = text;
-
4878 text.replace(index, used, sectiontext.left(used));
executed (the execution status of this line is deduced): text.replace(index, used, sectiontext.left(used));
-
4879 } else {
executed: }
Execution Count:807
807
4880 state = Intermediate;
executed (the execution status of this line is deduced): state = Intermediate;
-
4881 }
executed: }
Execution Count:6
6
4882 break; }
executed: break;
Execution Count:813
813
4883 // fall through -
4884 case DaySection: -
4885 case YearSection: -
4886 case YearSection2Digits: -
4887 case Hour12Section: -
4888 case Hour24Section: -
4889 case MinuteSection: -
4890 case SecondSection: -
4891 case MSecSection: { -
4892 if (sectiontextSize == 0) {
evaluated: sectiontextSize == 0
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:9984
17-9984
4893 num = 0;
executed (the execution status of this line is deduced): num = 0;
-
4894 used = 0;
executed (the execution status of this line is deduced): used = 0;
-
4895 state = Intermediate;
executed (the execution status of this line is deduced): state = Intermediate;
-
4896 } else {
executed: }
Execution Count:17
17
4897 const int absMax = absoluteMax(sectionIndex);
executed (the execution status of this line is deduced): const int absMax = absoluteMax(sectionIndex);
-
4898 QLocale loc;
executed (the execution status of this line is deduced): QLocale loc;
-
4899 bool ok = true;
executed (the execution status of this line is deduced): bool ok = true;
-
4900 int last = -1;
executed (the execution status of this line is deduced): int last = -1;
-
4901 used = -1;
executed (the execution status of this line is deduced): used = -1;
-
4902 -
4903 QString digitsStr(sectiontext);
executed (the execution status of this line is deduced): QString digitsStr(sectiontext);
-
4904 for (int i = 0; i < sectiontextSize; ++i) {
evaluated: i < sectiontextSize
TRUEFALSE
yes
Evaluation Count:21916
yes
Evaluation Count:9850
9850-21916
4905 if (digitsStr.at(i).isSpace()) {
evaluated: digitsStr.at(i).isSpace()
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:21782
134-21782
4906 sectiontextSize = i;
executed (the execution status of this line is deduced): sectiontextSize = i;
-
4907 break;
executed: break;
Execution Count:134
134
4908 } -
4909 }
executed: }
Execution Count:21782
21782
4910 -
4911 const int max = qMin(sectionmaxsize, sectiontextSize);
executed (the execution status of this line is deduced): const int max = qMin(sectionmaxsize, sectiontextSize);
-
4912 for (int digits = max; digits >= 1; --digits) {
evaluated: digits >= 1
TRUEFALSE
yes
Evaluation Count:10640
yes
Evaluation Count:40
40-10640
4913 digitsStr.truncate(digits);
executed (the execution status of this line is deduced): digitsStr.truncate(digits);
-
4914 int tmp = (int)loc.toUInt(digitsStr, &ok);
executed (the execution status of this line is deduced): int tmp = (int)loc.toUInt(digitsStr, &ok);
-
4915 if (ok && sn.type == Hour12Section) {
evaluated: ok
TRUEFALSE
yes
Evaluation Count:9952
yes
Evaluation Count:688
evaluated: sn.type == Hour12Section
TRUEFALSE
yes
Evaluation Count:823
yes
Evaluation Count:9129
688-9952
4916 if (tmp > 12) {
evaluated: tmp > 12
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:821
2-821
4917 tmp = -1;
executed (the execution status of this line is deduced): tmp = -1;
-
4918 ok = false;
executed (the execution status of this line is deduced): ok = false;
-
4919 } else if (tmp == 12) {
executed: }
Execution Count:2
evaluated: tmp == 12
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:721
2-721
4920 tmp = 0;
executed (the execution status of this line is deduced): tmp = 0;
-
4921 }
executed: }
Execution Count:100
100
4922 } -
4923 if (ok && tmp <= absMax) {
evaluated: ok
TRUEFALSE
yes
Evaluation Count:9950
yes
Evaluation Count:690
evaluated: tmp <= absMax
TRUEFALSE
yes
Evaluation Count:9944
yes
Evaluation Count:6
6-9950
4924 QDTPDEBUG << sectiontext.left(digits) << tmp << digits;
never executed: QMessageLogger("tools/qdatetime.cpp", 4924, __PRETTY_FUNCTION__).debug() << sectiontext.left(digits) << tmp << digits;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9944
0-9944
4925 last = tmp;
executed (the execution status of this line is deduced): last = tmp;
-
4926 used = digits;
executed (the execution status of this line is deduced): used = digits;
-
4927 break;
executed: break;
Execution Count:9944
9944
4928 } -
4929 }
executed: }
Execution Count:696
696
4930 -
4931 if (last == -1) {
evaluated: last == -1
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:9944
40-9944
4932 QChar first(sectiontext.at(0));
executed (the execution status of this line is deduced): QChar first(sectiontext.at(0));
-
4933 if (separators.at(sectionIndex + 1).startsWith(first)) {
evaluated: separators.at(sectionIndex + 1).startsWith(first)
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:2
2-38
4934 used = 0;
executed (the execution status of this line is deduced): used = 0;
-
4935 state = Intermediate;
executed (the execution status of this line is deduced): state = Intermediate;
-
4936 } else {
executed: }
Execution Count:38
38
4937 state = Invalid;
executed (the execution status of this line is deduced): state = Invalid;
-
4938 QDTPDEBUG << "invalid because" << sectiontext << "can't become a uint" << last << ok;
never executed: QMessageLogger("tools/qdatetime.cpp", 4938, __PRETTY_FUNCTION__).debug() << "invalid because" << sectiontext << "can't become a uint" << last << ok;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
4939 }
executed: }
Execution Count:2
2
4940 } else { -
4941 num += last;
executed (the execution status of this line is deduced): num += last;
-
4942 const FieldInfo fi = fieldInfo(sectionIndex);
executed (the execution status of this line is deduced): const FieldInfo fi = fieldInfo(sectionIndex);
-
4943 const bool done = (used == sectionmaxsize);
executed (the execution status of this line is deduced): const bool done = (used == sectionmaxsize);
-
4944 if (!done && fi & Fraction) { // typing 2 in a zzz field should be .200, not .002
evaluated: !done
TRUEFALSE
yes
Evaluation Count:907
yes
Evaluation Count:9037
evaluated: fi & Fraction
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:827
80-9037
4945 for (int i=used; i<sectionmaxsize; ++i) {
evaluated: i<sectionmaxsize
TRUEFALSE
yes
Evaluation Count:152
yes
Evaluation Count:80
80-152
4946 num *= 10;
executed (the execution status of this line is deduced): num *= 10;
-
4947 }
executed: }
Execution Count:152
152
4948 }
executed: }
Execution Count:80
80
4949 const int absMin = absoluteMin(sectionIndex);
executed (the execution status of this line is deduced): const int absMin = absoluteMin(sectionIndex);
-
4950 if (num < absMin) {
evaluated: num < absMin
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:9919
25-9919
4951 state = done ? Invalid : Intermediate;
evaluated: done
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:22
3-22
4952 if (done)
evaluated: done
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:22
3-22
4953 QDTPDEBUG << "invalid because" << num << "is less than absoluteMin" << absMin;
never executed: QMessageLogger("tools/qdatetime.cpp", 4953, __PRETTY_FUNCTION__).debug() << "invalid because" << num << "is less than absoluteMin" << absMin;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
4954 } else if (num > absMax) {
executed: }
Execution Count:25
partially evaluated: num > absMax
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9919
0-9919
4955 state = Intermediate;
never executed (the execution status of this line is deduced): state = Intermediate;
-
4956 } else if (!done && (fi & (FixedWidth|Numeric)) == (FixedWidth|Numeric)) {
never executed: }
evaluated: !done
TRUEFALSE
yes
Evaluation Count:885
yes
Evaluation Count:9034
evaluated: (fi & (FixedWidth|Numeric)) == (FixedWidth|Numeric)
TRUEFALSE
yes
Evaluation Count:322
yes
Evaluation Count:563
0-9034
4957 if (skipToNextSection(sectionIndex, currentValue, digitsStr)) {
evaluated: skipToNextSection(sectionIndex, currentValue, digitsStr)
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:313
9-313
4958 state = Acceptable;
executed (the execution status of this line is deduced): state = Acceptable;
-
4959 const int missingZeroes = sectionmaxsize - digitsStr.size();
executed (the execution status of this line is deduced): const int missingZeroes = sectionmaxsize - digitsStr.size();
-
4960 text.insert(index, QString().fill(QLatin1Char('0'), missingZeroes));
executed (the execution status of this line is deduced): text.insert(index, QString().fill(QLatin1Char('0'), missingZeroes));
-
4961 used = sectionmaxsize;
executed (the execution status of this line is deduced): used = sectionmaxsize;
-
4962 cursorPosition += missingZeroes;
executed (the execution status of this line is deduced): cursorPosition += missingZeroes;
-
4963 ++(const_cast<QDateTimeParser*>(this)->sectionNodes[sectionIndex].zeroesAdded);
executed (the execution status of this line is deduced): ++(const_cast<QDateTimeParser*>(this)->sectionNodes[sectionIndex].zeroesAdded);
-
4964 } else {
executed: }
Execution Count:9
9
4965 state = Intermediate;;
executed (the execution status of this line is deduced): state = Intermediate;;
-
4966 }
executed: }
Execution Count:313
313
4967 } else { -
4968 state = Acceptable;
executed (the execution status of this line is deduced): state = Acceptable;
-
4969 }
executed: }
Execution Count:9597
9597
4970 } -
4971 } -
4972 break; }
executed: break;
Execution Count:10001
10001
4973 default: -
4974 qWarning("QDateTimeParser::parseSection Internal error (%s %d)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 4974, __PRETTY_FUNCTION__).warning("QDateTimeParser::parseSection Internal error (%s %d)",
-
4975 qPrintable(sectionName(sn.type)), sectionIndex);
never executed (the execution status of this line is deduced): QString(sectionName(sn.type)).toLocal8Bit().constData(), sectionIndex);
-
4976 return -1;
never executed: return -1;
0
4977 } -
4978 -
4979 if (usedptr)
partially evaluated: usedptr
TRUEFALSE
yes
Evaluation Count:11678
no
Evaluation Count:0
0-11678
4980 *usedptr = used;
executed: *usedptr = used;
Execution Count:11678
11678
4981 -
4982 return (state != Invalid ? num : -1);
executed: return (state != Invalid ? num : -1);
Execution Count:11678
11678
4983} -
4984#endif // QT_NO_TEXTDATE -
4985 -
4986#ifndef QT_NO_DATESTRING -
4987/*! -
4988 \internal -
4989*/ -
4990 -
4991QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPosition, -
4992 const QDateTime &currentValue, bool fixup) const -
4993{ -
4994 const QDateTime minimum = getMinimum();
executed (the execution status of this line is deduced): const QDateTime minimum = getMinimum();
-
4995 const QDateTime maximum = getMaximum();
executed (the execution status of this line is deduced): const QDateTime maximum = getMaximum();
-
4996 -
4997 State state = Acceptable;
executed (the execution status of this line is deduced): State state = Acceptable;
-
4998 -
4999 QDateTime newCurrentValue;
executed (the execution status of this line is deduced): QDateTime newCurrentValue;
-
5000 int pos = 0;
executed (the execution status of this line is deduced): int pos = 0;
-
5001 bool conflicts = false;
executed (the execution status of this line is deduced): bool conflicts = false;
-
5002 const int sectionNodesCount = sectionNodes.size();
executed (the execution status of this line is deduced): const int sectionNodesCount = sectionNodes.size();
-
5003 -
5004 QDTPDEBUG << "parse" << input;
never executed: QMessageLogger("tools/qdatetime.cpp", 5004, __PRETTY_FUNCTION__).debug() << "parse" << input;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3353
0-3353
5005 { -
5006 int year, month, day, hour12, hour, minute, second, msec, ampm, dayofweek, year2digits;
executed (the execution status of this line is deduced): int year, month, day, hour12, hour, minute, second, msec, ampm, dayofweek, year2digits;
-
5007 getDateFromJulianDay(currentValue.date().toJulianDay(), &year, &month, &day);
executed (the execution status of this line is deduced): getDateFromJulianDay(currentValue.date().toJulianDay(), &year, &month, &day);
-
5008 year2digits = year % 100;
executed (the execution status of this line is deduced): year2digits = year % 100;
-
5009 hour = currentValue.time().hour();
executed (the execution status of this line is deduced): hour = currentValue.time().hour();
-
5010 hour12 = -1;
executed (the execution status of this line is deduced): hour12 = -1;
-
5011 minute = currentValue.time().minute();
executed (the execution status of this line is deduced): minute = currentValue.time().minute();
-
5012 second = currentValue.time().second();
executed (the execution status of this line is deduced): second = currentValue.time().second();
-
5013 msec = currentValue.time().msec();
executed (the execution status of this line is deduced): msec = currentValue.time().msec();
-
5014 dayofweek = currentValue.date().dayOfWeek();
executed (the execution status of this line is deduced): dayofweek = currentValue.date().dayOfWeek();
-
5015 -
5016 ampm = -1;
executed (the execution status of this line is deduced): ampm = -1;
-
5017 Sections isSet = NoSection;
executed (the execution status of this line is deduced): Sections isSet = NoSection;
-
5018 int num;
executed (the execution status of this line is deduced): int num;
-
5019 State tmpstate;
executed (the execution status of this line is deduced): State tmpstate;
-
5020 -
5021 for (int index=0; state != Invalid && index<sectionNodesCount; ++index) {
evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:15019
yes
Evaluation Count:7
evaluated: index<sectionNodesCount
TRUEFALSE
yes
Evaluation Count:11684
yes
Evaluation Count:3335
7-15019
5022 if (QStringRef(&input, pos, separators.at(index).size()) != separators.at(index)) {
evaluated: QStringRef(&input, pos, separators.at(index).size()) != separators.at(index)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:11678
6-11678
5023 QDTPDEBUG << "invalid because" << input.mid(pos, separators.at(index).size())
never executed: QMessageLogger("tools/qdatetime.cpp", 5023, __PRETTY_FUNCTION__).debug() << "invalid because" << input.mid(pos, separators.at(index).size()) << "!=" << separators.at(index) << index << pos << currentSectionIndex;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
5024 << "!=" << separators.at(index)
never executed: QMessageLogger("tools/qdatetime.cpp", 5023, __PRETTY_FUNCTION__).debug() << "invalid because" << input.mid(pos, separators.at(index).size()) << "!=" << separators.at(index) << index << pos << currentSectionIndex;
0
5025 << index << pos << currentSectionIndex;
never executed: QMessageLogger("tools/qdatetime.cpp", 5023, __PRETTY_FUNCTION__).debug() << "invalid because" << input.mid(pos, separators.at(index).size()) << "!=" << separators.at(index) << index << pos << currentSectionIndex;
0
5026 state = Invalid;
executed (the execution status of this line is deduced): state = Invalid;
-
5027 goto end;
executed: goto end;
Execution Count:6
6
5028 } -
5029 pos += separators.at(index).size();
executed (the execution status of this line is deduced): pos += separators.at(index).size();
-
5030 sectionNodes[index].pos = pos;
executed (the execution status of this line is deduced): sectionNodes[index].pos = pos;
-
5031 int *current = 0;
executed (the execution status of this line is deduced): int *current = 0;
-
5032 const SectionNode sn = sectionNodes.at(index);
executed (the execution status of this line is deduced): const SectionNode sn = sectionNodes.at(index);
-
5033 int used;
executed (the execution status of this line is deduced): int used;
-
5034 -
5035 num = parseSection(currentValue, index, input, cursorPosition, pos, tmpstate, &used);
executed (the execution status of this line is deduced): num = parseSection(currentValue, index, input, cursorPosition, pos, tmpstate, &used);
-
5036 QDTPDEBUG << "sectionValue" << sectionName(sectionType(index)) << input
never executed: QMessageLogger("tools/qdatetime.cpp", 5036, __PRETTY_FUNCTION__).debug() << "sectionValue" << sectionName(sectionType(index)) << input << "pos" << pos << "used" << used << stateName(tmpstate);
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11678
0-11678
5037 << "pos" << pos << "used" << used << stateName(tmpstate);
never executed: QMessageLogger("tools/qdatetime.cpp", 5036, __PRETTY_FUNCTION__).debug() << "sectionValue" << sectionName(sectionType(index)) << input << "pos" << pos << "used" << used << stateName(tmpstate);
0
5038 if (fixup && tmpstate == Intermediate && used < sn.count) {
evaluated: fixup
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:11608
evaluated: tmpstate == Intermediate
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:50
evaluated: used < sn.count
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:1
1-11608
5039 const FieldInfo fi = fieldInfo(index);
executed (the execution status of this line is deduced): const FieldInfo fi = fieldInfo(index);
-
5040 if ((fi & (Numeric|FixedWidth)) == (Numeric|FixedWidth)) {
evaluated: (fi & (Numeric|FixedWidth)) == (Numeric|FixedWidth)
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:3
3-16
5041 const QString newText = QString::fromLatin1("%1").arg(num, sn.count, 10, QLatin1Char('0'));
executed (the execution status of this line is deduced): const QString newText = QString::fromLatin1("%1").arg(num, sn.count, 10, QLatin1Char('0'));
-
5042 input.replace(pos, used, newText);
executed (the execution status of this line is deduced): input.replace(pos, used, newText);
-
5043 used = sn.count;
executed (the execution status of this line is deduced): used = sn.count;
-
5044 }
executed: }
Execution Count:16
16
5045 }
executed: }
Execution Count:19
19
5046 pos += qMax(0, used);
executed (the execution status of this line is deduced): pos += qMax(0, used);
-
5047 -
5048 state = qMin<State>(state, tmpstate);
executed (the execution status of this line is deduced): state = qMin<State>(state, tmpstate);
-
5049 if (state == Intermediate && context == FromString) {
evaluated: state == Intermediate
TRUEFALSE
yes
Evaluation Count:1088
yes
Evaluation Count:10590
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1083
5-10590
5050 state = Invalid;
executed (the execution status of this line is deduced): state = Invalid;
-
5051 break;
executed: break;
Execution Count:5
5
5052 } -
5053 -
5054 QDTPDEBUG << index << sectionName(sectionType(index)) << "is set to"
never executed: QMessageLogger("tools/qdatetime.cpp", 5054, __PRETTY_FUNCTION__).debug() << index << sectionName(sectionType(index)) << "is set to" << pos << "state is" << stateName(state);
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11673
0-11673
5055 << pos << "state is" << stateName(state);
never executed: QMessageLogger("tools/qdatetime.cpp", 5054, __PRETTY_FUNCTION__).debug() << index << sectionName(sectionType(index)) << "is set to" << pos << "state is" << stateName(state);
0
5056 -
5057 -
5058 if (state != Invalid) {
evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:11666
yes
Evaluation Count:7
7-11666
5059 switch (sn.type) { -
5060 case Hour24Section: current = &hour; break;
executed: break;
Execution Count:1127
1127
5061 case Hour12Section: current = &hour12; break;
executed: break;
Execution Count:821
821
5062 case MinuteSection: current = &minute; break;
executed: break;
Execution Count:1766
1766
5063 case SecondSection: current = &second; break;
executed: break;
Execution Count:1702
1702
5064 case MSecSection: current = &msec; break;
executed: break;
Execution Count:223
223
5065 case YearSection: current = &year; break;
executed: break;
Execution Count:1000
1000
5066 case YearSection2Digits: current = &year2digits; break;
executed: break;
Execution Count:646
646
5067 case MonthSection: current = &month; break;
executed: break;
Execution Count:1790
1790
5068 case DayOfWeekSectionShort: -
5069 case DayOfWeekSectionLong: current = &dayofweek; break;
executed: break;
Execution Count:28
28
5070 case DaySection: current = &day; num = qMax<int>(1, num); break;
executed: break;
Execution Count:1701
1701
5071 case AmPmSection: current = &ampm; break;
executed: break;
Execution Count:862
862
5072 default: -
5073 qWarning("QDateTimeParser::parse Internal error (%s)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 5073, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error (%s)",
-
5074 qPrintable(sectionName(sn.type)));
never executed (the execution status of this line is deduced): QString(sectionName(sn.type)).toLocal8Bit().constData());
-
5075 break;
never executed: break;
0
5076 } -
5077 if (!current) {
partially evaluated: !current
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11666
0-11666
5078 qWarning("QDateTimeParser::parse Internal error 2");
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 5078, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 2");
-
5079 return StateNode();
never executed: return StateNode();
0
5080 } -
5081 if (isSet & sn.type && *current != num) {
evaluated: isSet & sn.type
TRUEFALSE
yes
Evaluation Count:531
yes
Evaluation Count:11135
evaluated: *current != num
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:430
101-11135
5082 QDTPDEBUG << "CONFLICT " << sectionName(sn.type) << *current << num;
never executed: QMessageLogger("tools/qdatetime.cpp", 5082, __PRETTY_FUNCTION__).debug() << "CONFLICT " << sectionName(sn.type) << *current << num;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:101
0-101
5083 conflicts = true;
executed (the execution status of this line is deduced): conflicts = true;
-
5084 if (index != currentSectionIndex || num == -1) {
evaluated: index != currentSectionIndex
TRUEFALSE
yes
Evaluation Count:96
yes
Evaluation Count:5
partially evaluated: num == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-96
5085 continue;
executed: continue;
Execution Count:96
96
5086 } -
5087 }
executed: }
Execution Count:5
5
5088 if (num != -1)
evaluated: num != -1
TRUEFALSE
yes
Evaluation Count:11565
yes
Evaluation Count:5
5-11565
5089 *current = num;
executed: *current = num;
Execution Count:11565
11565
5090 isSet |= sn.type;
executed (the execution status of this line is deduced): isSet |= sn.type;
-
5091 }
executed: }
Execution Count:11570
11570
5092 }
executed: }
Execution Count:11577
11577
5093 -
5094 if (state != Invalid && QStringRef(&input, pos, input.size() - pos) != separators.last()) {
evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:3335
yes
Evaluation Count:12
evaluated: QStringRef(&input, pos, input.size() - pos) != separators.last()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:3321
12-3335
5095 QDTPDEBUG << "invalid because" << input.mid(pos)
never executed: QMessageLogger("tools/qdatetime.cpp", 5095, __PRETTY_FUNCTION__).debug() << "invalid because" << input.mid(pos) << "!=" << separators.last() << pos;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
5096 << "!=" << separators.last() << pos;
never executed: QMessageLogger("tools/qdatetime.cpp", 5095, __PRETTY_FUNCTION__).debug() << "invalid because" << input.mid(pos) << "!=" << separators.last() << pos;
0
5097 state = Invalid;
executed (the execution status of this line is deduced): state = Invalid;
-
5098 }
executed: }
Execution Count:14
14
5099 -
5100 if (state != Invalid) {
evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:3321
yes
Evaluation Count:26
26-3321
5101 if (parserType != QVariant::Time) {
evaluated: parserType != QVariant::Time
TRUEFALSE
yes
Evaluation Count:3299
yes
Evaluation Count:22
22-3299
5102 if (year % 100 != year2digits) {
evaluated: year % 100 != year2digits
TRUEFALSE
yes
Evaluation Count:115
yes
Evaluation Count:3184
115-3184
5103 switch (isSet & (YearSection2Digits|YearSection)) { -
5104 case YearSection2Digits: -
5105 year = (year / 100) * 100;
executed (the execution status of this line is deduced): year = (year / 100) * 100;
-
5106 year += year2digits;
executed (the execution status of this line is deduced): year += year2digits;
-
5107 break;
executed: break;
Execution Count:31
31
5108 case ((uint)YearSection2Digits|(uint)YearSection): { -
5109 conflicts = true;
never executed (the execution status of this line is deduced): conflicts = true;
-
5110 const SectionNode &sn = sectionNode(currentSectionIndex);
never executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(currentSectionIndex);
-
5111 if (sn.type == YearSection2Digits) {
never evaluated: sn.type == YearSection2Digits
0
5112 year = (year / 100) * 100;
never executed (the execution status of this line is deduced): year = (year / 100) * 100;
-
5113 year += year2digits;
never executed (the execution status of this line is deduced): year += year2digits;
-
5114 }
never executed: }
0
5115 break; }
never executed: break;
0
5116 default: -
5117 break;
executed: break;
Execution Count:84
84
5118 } -
5119 }
executed: }
Execution Count:115
115
5120 -
5121 const QDate date(year, month, day);
executed (the execution status of this line is deduced): const QDate date(year, month, day);
-
5122 const int diff = dayofweek - date.dayOfWeek();
executed (the execution status of this line is deduced): const int diff = dayofweek - date.dayOfWeek();
-
5123 if (diff != 0 && state == Acceptable && isSet & (DayOfWeekSectionShort|DayOfWeekSectionLong)) {
evaluated: diff != 0
TRUEFALSE
yes
Evaluation Count:150
yes
Evaluation Count:3149
evaluated: state == Acceptable
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:91
evaluated: isSet & (DayOfWeekSectionShort|DayOfWeekSectionLong)
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:46
13-3149
5124 conflicts = isSet & DaySection;
executed (the execution status of this line is deduced): conflicts = isSet & DaySection;
-
5125 const SectionNode &sn = sectionNode(currentSectionIndex);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(currentSectionIndex);
-
5126 if (sn.type & (DayOfWeekSectionShort|DayOfWeekSectionLong) || currentSectionIndex == -1) {
partially evaluated: sn.type & (DayOfWeekSectionShort|DayOfWeekSectionLong)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
partially evaluated: currentSectionIndex == -1
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
5127 // dayofweek should be preferred -
5128 day += diff;
executed (the execution status of this line is deduced): day += diff;
-
5129 if (day <= 0) {
evaluated: day <= 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:6
6-7
5130 day += 7;
executed (the execution status of this line is deduced): day += 7;
-
5131 } else if (day > date.daysInMonth()) {
executed: }
Execution Count:7
partially evaluated: day > date.daysInMonth()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-7
5132 day -= 7;
never executed (the execution status of this line is deduced): day -= 7;
-
5133 }
never executed: }
0
5134 QDTPDEBUG << year << month << day << dayofweek
never executed: QMessageLogger("tools/qdatetime.cpp", 5134, __PRETTY_FUNCTION__).debug() << year << month << day << dayofweek << diff << QDate(year, month, day).dayOfWeek();
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
5135 << diff << QDate(year, month, day).dayOfWeek();
never executed: QMessageLogger("tools/qdatetime.cpp", 5134, __PRETTY_FUNCTION__).debug() << year << month << day << dayofweek << diff << QDate(year, month, day).dayOfWeek();
0
5136 }
executed: }
Execution Count:13
13
5137 }
executed: }
Execution Count:13
13
5138 bool needfixday = false;
executed (the execution status of this line is deduced): bool needfixday = false;
-
5139 if (sectionType(currentSectionIndex) & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) {
evaluated: sectionType(currentSectionIndex) & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)
TRUEFALSE
yes
Evaluation Count:562
yes
Evaluation Count:2737
562-2737
5140 cachedDay = day;
executed (the execution status of this line is deduced): cachedDay = day;
-
5141 } else if (cachedDay > day) {
executed: }
Execution Count:562
evaluated: cachedDay > day
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2734
3-2734
5142 day = cachedDay;
executed (the execution status of this line is deduced): day = cachedDay;
-
5143 needfixday = true;
executed (the execution status of this line is deduced): needfixday = true;
-
5144 }
executed: }
Execution Count:3
3
5145 -
5146 if (!QDate::isValid(year, month, day)) {
evaluated: !QDate::isValid(year, month, day)
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:3258
41-3258
5147 if (day < 32) {
partially evaluated: day < 32
TRUEFALSE
yes
Evaluation Count:41
no
Evaluation Count:0
0-41
5148 cachedDay = day;
executed (the execution status of this line is deduced): cachedDay = day;
-
5149 }
executed: }
Execution Count:41
41
5150 if (day > 28 && QDate::isValid(year, month, 1)) {
evaluated: day > 28
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:37
partially evaluated: QDate::isValid(year, month, 1)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-37
5151 needfixday = true;
executed (the execution status of this line is deduced): needfixday = true;
-
5152 }
executed: }
Execution Count:4
4
5153 }
executed: }
Execution Count:41
41
5154 if (needfixday) {
evaluated: needfixday
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3295
4-3295
5155 if (context == FromString) {
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
5156 state = Invalid;
executed (the execution status of this line is deduced): state = Invalid;
-
5157 goto end;
executed: goto end;
Execution Count:1
1
5158 } -
5159 if (state == Acceptable && fixday) {
partially evaluated: state == Acceptable
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
partially evaluated: fixday
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
5160 day = qMin<int>(day, QDate(year, month, 1).daysInMonth());
executed (the execution status of this line is deduced): day = qMin<int>(day, QDate(year, month, 1).daysInMonth());
-
5161 -
5162 const QLocale loc = locale();
executed (the execution status of this line is deduced): const QLocale loc = locale();
-
5163 for (int i=0; i<sectionNodesCount; ++i) {
evaluated: i<sectionNodesCount
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
3-6
5164 const Section thisSectionType = sectionType(i);
executed (the execution status of this line is deduced): const Section thisSectionType = sectionType(i);
-
5165 if (thisSectionType & (DaySection)) {
evaluated: thisSectionType & (DaySection)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
5166 input.replace(sectionPos(i), sectionSize(i), loc.toString(day));
executed (the execution status of this line is deduced): input.replace(sectionPos(i), sectionSize(i), loc.toString(day));
-
5167 } else if (thisSectionType & (DayOfWeekSectionShort|DayOfWeekSectionLong)) {
executed: }
Execution Count:3
partially evaluated: thisSectionType & (DayOfWeekSectionShort|DayOfWeekSectionLong)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
5168 const int dayOfWeek = QDate(year, month, day).dayOfWeek();
never executed (the execution status of this line is deduced): const int dayOfWeek = QDate(year, month, day).dayOfWeek();
-
5169 const QLocale::FormatType dayFormat = (thisSectionType == DayOfWeekSectionShort
never evaluated: thisSectionType == DayOfWeekSectionShort
0
5170 ? QLocale::ShortFormat : QLocale::LongFormat);
never executed (the execution status of this line is deduced): ? QLocale::ShortFormat : QLocale::LongFormat);
-
5171 const QString dayName(loc.dayName(dayOfWeek, dayFormat));
never executed (the execution status of this line is deduced): const QString dayName(loc.dayName(dayOfWeek, dayFormat));
-
5172 input.replace(sectionPos(i), sectionSize(i), dayName);
never executed (the execution status of this line is deduced): input.replace(sectionPos(i), sectionSize(i), dayName);
-
5173 }
never executed: }
0
5174 } -
5175 } else {
executed: }
Execution Count:3
3
5176 state = qMin(Intermediate, state);
never executed (the execution status of this line is deduced): state = qMin(Intermediate, state);
-
5177 }
never executed: }
0
5178 } -
5179 }
executed: }
Execution Count:3298
3298
5180 -
5181 if (parserType != QVariant::Date) {
evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:3268
yes
Evaluation Count:52
52-3268
5182 if (isSet & Hour12Section) {
evaluated: isSet & Hour12Section
TRUEFALSE
yes
Evaluation Count:809
yes
Evaluation Count:2459
809-2459
5183 const bool hasHour = isSet & Hour24Section;
executed (the execution status of this line is deduced): const bool hasHour = isSet & Hour24Section;
-
5184 if (ampm == -1) {
partially evaluated: ampm == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:809
0-809
5185 if (hasHour) {
never evaluated: hasHour
0
5186 ampm = (hour < 12 ? 0 : 1);
never evaluated: hour < 12
0
5187 } else {
never executed: }
0
5188 ampm = 0; // no way to tell if this is am or pm so I assume am
never executed (the execution status of this line is deduced): ampm = 0;
-
5189 }
never executed: }
0
5190 } -
5191 hour12 = (ampm == 0 ? hour12 % 12 : (hour12 % 12) + 12);
evaluated: ampm == 0
TRUEFALSE
yes
Evaluation Count:731
yes
Evaluation Count:78
78-731
5192 if (!hasHour) {
evaluated: !hasHour
TRUEFALSE
yes
Evaluation Count:807
yes
Evaluation Count:2
2-807
5193 hour = hour12;
executed (the execution status of this line is deduced): hour = hour12;
-
5194 } else if (hour != hour12) {
executed: }
Execution Count:807
partially evaluated: hour != hour12
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-807
5195 conflicts = true;
never executed (the execution status of this line is deduced): conflicts = true;
-
5196 }
never executed: }
0
5197 } else if (ampm != -1) {
evaluated: ampm != -1
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:2408
51-2408
5198 if (!(isSet & (Hour24Section))) {
evaluated: !(isSet & (Hour24Section))
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:48
3-48
5199 hour = (12 * ampm); // special case. Only ap section
executed (the execution status of this line is deduced): hour = (12 * ampm);
-
5200 } else if ((ampm == 0) != (hour < 12)) {
executed: }
Execution Count:3
partially evaluated: (ampm == 0) != (hour < 12)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:48
0-48
5201 conflicts = true;
never executed (the execution status of this line is deduced): conflicts = true;
-
5202 }
never executed: }
0
5203 } -
5204 -
5205 } -
5206 -
5207 newCurrentValue = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), spec);
executed (the execution status of this line is deduced): newCurrentValue = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), spec);
-
5208 QDTPDEBUG << year << month << day << hour << minute << second << msec;
never executed: QMessageLogger("tools/qdatetime.cpp", 5208, __PRETTY_FUNCTION__).debug() << year << month << day << hour << minute << second << msec;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3320
0-3320
5209 }
executed: }
Execution Count:3320
3320
5210 QDTPDEBUGN("'%s' => '%s'(%s)", input.toLatin1().constData(),
never executed: QMessageLogger("tools/qdatetime.cpp", 5210, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), stateName(state).toLatin1().constData());
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3346
0-3346
5211 newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(),
never executed: QMessageLogger("tools/qdatetime.cpp", 5210, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), stateName(state).toLatin1().constData());
0
5212 stateName(state).toLatin1().constData());
never executed: QMessageLogger("tools/qdatetime.cpp", 5210, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), stateName(state).toLatin1().constData());
0
5213 } -
5214end:
code before this statement executed: end:
Execution Count:3346
3346
5215 if (newCurrentValue.isValid()) {
evaluated: newCurrentValue.isValid()
TRUEFALSE
yes
Evaluation Count:3283
yes
Evaluation Count:70
70-3283
5216 if (context != FromString && state != Invalid && newCurrentValue < minimum) {
evaluated: context != FromString
TRUEFALSE
yes
Evaluation Count:3178
yes
Evaluation Count:105
partially evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:3178
no
Evaluation Count:0
evaluated: newCurrentValue < minimum
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:3125
0-3178
5217 const QLatin1Char space(' ');
executed (the execution status of this line is deduced): const QLatin1Char space(' ');
-
5218 if (newCurrentValue >= minimum)
partially evaluated: newCurrentValue >= minimum
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:53
0-53
5219 qWarning("QDateTimeParser::parse Internal error 3 (%s %s)",
never executed: QMessageLogger("tools/qdatetime.cpp", 5219, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 3 (%s %s)", QString(newCurrentValue.toString()).toLocal8Bit().constData(), QString(minimum.toString()).toLocal8Bit().constData());
0
5220 qPrintable(newCurrentValue.toString()), qPrintable(minimum.toString()));
never executed: QMessageLogger("tools/qdatetime.cpp", 5219, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 3 (%s %s)", QString(newCurrentValue.toString()).toLocal8Bit().constData(), QString(minimum.toString()).toLocal8Bit().constData());
0
5221 -
5222 bool done = false;
executed (the execution status of this line is deduced): bool done = false;
-
5223 state = Invalid;
executed (the execution status of this line is deduced): state = Invalid;
-
5224 for (int i=0; i<sectionNodesCount && !done; ++i) {
evaluated: i<sectionNodesCount
TRUEFALSE
yes
Evaluation Count:138
yes
Evaluation Count:44
evaluated: !done
TRUEFALSE
yes
Evaluation Count:129
yes
Evaluation Count:9
9-138
5225 const SectionNode &sn = sectionNodes.at(i);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNodes.at(i);
-
5226 QString t = sectionText(input, i, sn.pos).toLower();
executed (the execution status of this line is deduced): QString t = sectionText(input, i, sn.pos).toLower();
-
5227 if ((t.size() < sectionMaxSize(i) && (((int)fieldInfo(i) & (FixedWidth|Numeric)) != Numeric))
evaluated: t.size() < sectionMaxSize(i)
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:74
partially evaluated: (((int)fieldInfo(i) & (FixedWidth|Numeric)) != Numeric)
TRUEFALSE
yes
Evaluation Count:55
no
Evaluation Count:0
0-74
5228 || t.contains(space)) {
partially evaluated: t.contains(space)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:74
0-74
5229 switch (sn.type) { -
5230 case AmPmSection: -
5231 switch (findAmPm(t, i)) { -
5232 case AM: -
5233 case PM: -
5234 state = Acceptable;
never executed (the execution status of this line is deduced): state = Acceptable;
-
5235 done = true;
never executed (the execution status of this line is deduced): done = true;
-
5236 break;
never executed: break;
0
5237 case Neither: -
5238 state = Invalid;
never executed (the execution status of this line is deduced): state = Invalid;
-
5239 done = true;
never executed (the execution status of this line is deduced): done = true;
-
5240 break;
never executed: break;
0
5241 case PossibleAM: -
5242 case PossiblePM: -
5243 case PossibleBoth: { -
5244 const QDateTime copy(newCurrentValue.addSecs(12 * 60 * 60));
never executed (the execution status of this line is deduced): const QDateTime copy(newCurrentValue.addSecs(12 * 60 * 60));
-
5245 if (copy >= minimum && copy <= maximum) {
never evaluated: copy >= minimum
never evaluated: copy <= maximum
0
5246 state = Intermediate;
never executed (the execution status of this line is deduced): state = Intermediate;
-
5247 done = true;
never executed (the execution status of this line is deduced): done = true;
-
5248 }
never executed: }
0
5249 break; }
never executed: break;
0
5250 } -
5251 case MonthSection:
code before this statement never executed: case MonthSection:
0
5252 if (sn.count >= 3) {
partially evaluated: sn.count >= 3
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
5253 int tmp = newCurrentValue.date().month();
executed (the execution status of this line is deduced): int tmp = newCurrentValue.date().month();
-
5254 // I know the first possible month makes the date too early -
5255 while ((tmp = findMonth(t, tmp + 1, i)) != -1) {
evaluated: (tmp = findMonth(t, tmp + 1, i)) != -1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
3-6
5256 const QDateTime copy(newCurrentValue.addMonths(tmp - newCurrentValue.date().month()));
executed (the execution status of this line is deduced): const QDateTime copy(newCurrentValue.addMonths(tmp - newCurrentValue.date().month()));
-
5257 if (copy >= minimum && copy <= maximum)
partially evaluated: copy >= minimum
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
never evaluated: copy <= maximum
0-6
5258 break; // break out of while
never executed: break;
0
5259 }
executed: }
Execution Count:6
6
5260 if (tmp == -1) {
partially evaluated: tmp == -1
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
5261 break;
executed: break;
Execution Count:3
3
5262 } -
5263 state = Intermediate;
never executed (the execution status of this line is deduced): state = Intermediate;
-
5264 done = true;
never executed (the execution status of this line is deduced): done = true;
-
5265 break;
never executed: break;
0
5266 } -
5267 // fallthrough -
5268 default: { -
5269 int toMin;
executed (the execution status of this line is deduced): int toMin;
-
5270 int toMax;
executed (the execution status of this line is deduced): int toMax;
-
5271 -
5272 if (sn.type & TimeSectionMask) {
evaluated: sn.type & TimeSectionMask
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:32
20-32
5273 if (newCurrentValue.daysTo(minimum) != 0) {
partially evaluated: newCurrentValue.daysTo(minimum) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
5274 break;
never executed: break;
0
5275 } -
5276 toMin = newCurrentValue.time().msecsTo(minimum.time());
executed (the execution status of this line is deduced): toMin = newCurrentValue.time().msecsTo(minimum.time());
-
5277 if (newCurrentValue.daysTo(maximum) > 0) {
partially evaluated: newCurrentValue.daysTo(maximum) > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
5278 toMax = -1; // can't get to max
never executed (the execution status of this line is deduced): toMax = -1;
-
5279 } else {
never executed: }
0
5280 toMax = newCurrentValue.time().msecsTo(maximum.time());
executed (the execution status of this line is deduced): toMax = newCurrentValue.time().msecsTo(maximum.time());
-
5281 }
executed: }
Execution Count:20
20
5282 } else { -
5283 toMin = newCurrentValue.daysTo(minimum);
executed (the execution status of this line is deduced): toMin = newCurrentValue.daysTo(minimum);
-
5284 toMax = newCurrentValue.daysTo(maximum);
executed (the execution status of this line is deduced): toMax = newCurrentValue.daysTo(maximum);
-
5285 }
executed: }
Execution Count:32
32
5286 const int maxChange = QDateTimeParser::maxChange(i);
executed (the execution status of this line is deduced): const int maxChange = QDateTimeParser::maxChange(i);
-
5287 if (toMin > maxChange) {
partially evaluated: toMin > maxChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:52
0-52
5288 QDTPDEBUG << "invalid because toMin > maxChange" << toMin
never executed: QMessageLogger("tools/qdatetime.cpp", 5288, __PRETTY_FUNCTION__).debug() << "invalid because toMin > maxChange" << toMin << maxChange << t << newCurrentValue << minimum;
never evaluated: false
0
5289 << maxChange << t << newCurrentValue << minimum;
never executed: QMessageLogger("tools/qdatetime.cpp", 5288, __PRETTY_FUNCTION__).debug() << "invalid because toMin > maxChange" << toMin << maxChange << t << newCurrentValue << minimum;
0
5290 state = Invalid;
never executed (the execution status of this line is deduced): state = Invalid;
-
5291 done = true;
never executed (the execution status of this line is deduced): done = true;
-
5292 break;
never executed: break;
0
5293 } else if (toMax > maxChange) {
evaluated: toMax > maxChange
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:38
14-38
5294 toMax = -1; // can't get to max
executed (the execution status of this line is deduced): toMax = -1;
-
5295 }
executed: }
Execution Count:14
14
5296 -
5297 const int min = getDigit(minimum, i);
executed (the execution status of this line is deduced): const int min = getDigit(minimum, i);
-
5298 if (min == -1) {
partially evaluated: min == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:52
0-52
5299 qWarning("QDateTimeParser::parse Internal error 4 (%s)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 5299, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 4 (%s)",
-
5300 qPrintable(sectionName(sn.type)));
never executed (the execution status of this line is deduced): QString(sectionName(sn.type)).toLocal8Bit().constData());
-
5301 state = Invalid;
never executed (the execution status of this line is deduced): state = Invalid;
-
5302 done = true;
never executed (the execution status of this line is deduced): done = true;
-
5303 break;
never executed: break;
0
5304 } -
5305 -
5306 int max = toMax != -1 ? getDigit(maximum, i) : absoluteMax(i, newCurrentValue);
evaluated: toMax != -1
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:14
14-38
5307 int pos = cursorPosition - sn.pos;
executed (the execution status of this line is deduced): int pos = cursorPosition - sn.pos;
-
5308 if (pos < 0 || pos >= t.size())
evaluated: pos < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:48
evaluated: pos >= t.size()
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:7
4-48
5309 pos = -1;
executed: pos = -1;
Execution Count:45
45
5310 if (!potentialValue(t.simplified(), min, max, i, newCurrentValue, pos)) {
evaluated: !potentialValue(t.simplified(), min, max, i, newCurrentValue, pos)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:50
2-50
5311 QDTPDEBUG << "invalid because potentialValue(" << t.simplified() << min << max
never executed: QMessageLogger("tools/qdatetime.cpp", 5311, __PRETTY_FUNCTION__).debug() << "invalid because potentialValue(" << t.simplified() << min << max << sectionName(sn.type) << "returned" << toMax << toMin << pos;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5312 << sectionName(sn.type) << "returned" << toMax << toMin << pos;
never executed: QMessageLogger("tools/qdatetime.cpp", 5311, __PRETTY_FUNCTION__).debug() << "invalid because potentialValue(" << t.simplified() << min << max << sectionName(sn.type) << "returned" << toMax << toMin << pos;
0
5313 state = Invalid;
executed (the execution status of this line is deduced): state = Invalid;
-
5314 done = true;
executed (the execution status of this line is deduced): done = true;
-
5315 break;
executed: break;
Execution Count:2
2
5316 } -
5317 state = Intermediate;
executed (the execution status of this line is deduced): state = Intermediate;
-
5318 done = true;
executed (the execution status of this line is deduced): done = true;
-
5319 break; }
executed: break;
Execution Count:50
50
5320 } -
5321 }
executed: }
Execution Count:55
55
5322 }
executed: }
Execution Count:129
129
5323 } else {
executed: }
Execution Count:53
53
5324 if (context == FromString) {
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:3125
105-3125
5325 // optimization -
5326 Q_ASSERT(getMaximum().date().toJulianDay() == 4642999);
executed (the execution status of this line is deduced): qt_noop();
-
5327 if (newCurrentValue.date().toJulianDay() > 4642999)
partially evaluated: newCurrentValue.date().toJulianDay() > 4642999
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:105
0-105
5328 state = Invalid;
never executed: state = Invalid;
0
5329 } else {
executed: }
Execution Count:105
105
5330 if (newCurrentValue > getMaximum())
evaluated: newCurrentValue > getMaximum()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3124
1-3124
5331 state = Invalid;
executed: state = Invalid;
Execution Count:1
1
5332 }
executed: }
Execution Count:3125
3125
5333 -
5334 QDTPDEBUG << "not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum();
never executed: QMessageLogger("tools/qdatetime.cpp", 5334, __PRETTY_FUNCTION__).debug() << "not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum();
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3230
0-3230
5335 }
executed: }
Execution Count:3230
3230
5336 } -
5337 StateNode node;
executed (the execution status of this line is deduced): StateNode node;
-
5338 node.input = input;
executed (the execution status of this line is deduced): node.input = input;
-
5339 node.state = state;
executed (the execution status of this line is deduced): node.state = state;
-
5340 node.conflicts = conflicts;
executed (the execution status of this line is deduced): node.conflicts = conflicts;
-
5341 node.value = newCurrentValue.toTimeSpec(spec);
executed (the execution status of this line is deduced): node.value = newCurrentValue.toTimeSpec(spec);
-
5342 text = input;
executed (the execution status of this line is deduced): text = input;
-
5343 return node;
executed: return node;
Execution Count:3353
3353
5344} -
5345#endif // QT_NO_DATESTRING -
5346 -
5347#ifndef QT_NO_TEXTDATE -
5348/*! -
5349 \internal -
5350 finds the first possible monthname that \a str1 can -
5351 match. Starting from \a index; str should already by lowered -
5352*/ -
5353 -
5354int QDateTimeParser::findMonth(const QString &str1, int startMonth, int sectionIndex, -
5355 QString *usedMonth, int *used) const -
5356{ -
5357 int bestMatch = -1;
executed (the execution status of this line is deduced): int bestMatch = -1;
-
5358 int bestCount = 0;
executed (the execution status of this line is deduced): int bestCount = 0;
-
5359 if (!str1.isEmpty()) {
partially evaluated: !str1.isEmpty()
TRUEFALSE
yes
Evaluation Count:793
no
Evaluation Count:0
0-793
5360 const SectionNode &sn = sectionNode(sectionIndex);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(sectionIndex);
-
5361 if (sn.type != MonthSection) {
partially evaluated: sn.type != MonthSection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:793
0-793
5362 qWarning("QDateTimeParser::findMonth Internal error");
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 5362, __PRETTY_FUNCTION__).warning("QDateTimeParser::findMonth Internal error");
-
5363 return -1;
never executed: return -1;
0
5364 } -
5365 -
5366 QLocale::FormatType type = sn.count == 3 ? QLocale::ShortFormat : QLocale::LongFormat;
evaluated: sn.count == 3
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:181
181-612
5367 QLocale l = locale();
executed (the execution status of this line is deduced): QLocale l = locale();
-
5368 -
5369 for (int month=startMonth; month<=12; ++month) {
evaluated: month<=12
TRUEFALSE
yes
Evaluation Count:2410
yes
Evaluation Count:118
118-2410
5370 QString str2 = l.monthName(month, type).toLower();
executed (the execution status of this line is deduced): QString str2 = l.monthName(month, type).toLower();
-
5371 -
5372 if (str1.startsWith(str2)) {
evaluated: str1.startsWith(str2)
TRUEFALSE
yes
Evaluation Count:672
yes
Evaluation Count:1738
672-1738
5373 if (used) {
partially evaluated: used
TRUEFALSE
yes
Evaluation Count:672
no
Evaluation Count:0
0-672
5374 QDTPDEBUG << "used is set to" << str2.size();
never executed: QMessageLogger("tools/qdatetime.cpp", 5374, __PRETTY_FUNCTION__).debug() << "used is set to" << str2.size();
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:672
0-672
5375 *used = str2.size();
executed (the execution status of this line is deduced): *used = str2.size();
-
5376 }
executed: }
Execution Count:672
672
5377 if (usedMonth)
partially evaluated: usedMonth
TRUEFALSE
yes
Evaluation Count:672
no
Evaluation Count:0
0-672
5378 *usedMonth = l.monthName(month, type);
executed: *usedMonth = l.monthName(month, type);
Execution Count:672
672
5379 -
5380 return month;
executed: return month;
Execution Count:672
672
5381 } -
5382 if (context == FromString)
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:148
yes
Evaluation Count:1590
148-1590
5383 continue;
executed: continue;
Execution Count:148
148
5384 -
5385 const int limit = qMin(str1.size(), str2.size());
executed (the execution status of this line is deduced): const int limit = qMin(str1.size(), str2.size());
-
5386 -
5387 QDTPDEBUG << "limit is" << limit << str1 << str2;
never executed: QMessageLogger("tools/qdatetime.cpp", 5387, __PRETTY_FUNCTION__).debug() << "limit is" << limit << str1 << str2;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1590
0-1590
5388 bool equal = true;
executed (the execution status of this line is deduced): bool equal = true;
-
5389 for (int i=0; i<limit; ++i) {
evaluated: i<limit
TRUEFALSE
yes
Evaluation Count:2254
yes
Evaluation Count:3
3-2254
5390 if (str1.at(i) != str2.at(i)) {
evaluated: str1.at(i) != str2.at(i)
TRUEFALSE
yes
Evaluation Count:1587
yes
Evaluation Count:667
667-1587
5391 equal = false;
executed (the execution status of this line is deduced): equal = false;
-
5392 if (i > bestCount) {
evaluated: i > bestCount
TRUEFALSE
yes
Evaluation Count:177
yes
Evaluation Count:1410
177-1410
5393 bestCount = i;
executed (the execution status of this line is deduced): bestCount = i;
-
5394 bestMatch = month;
executed (the execution status of this line is deduced): bestMatch = month;
-
5395 }
executed: }
Execution Count:177
177
5396 break;
executed: break;
Execution Count:1587
1587
5397 } -
5398 }
executed: }
Execution Count:667
667
5399 if (equal) {
evaluated: equal
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1587
3-1587
5400 if (used)
partially evaluated: used
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
5401 *used = limit;
executed: *used = limit;
Execution Count:3
3
5402 if (usedMonth)
partially evaluated: usedMonth
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
5403 *usedMonth = l.monthName(month, type);
executed: *usedMonth = l.monthName(month, type);
Execution Count:3
3
5404 return month;
executed: return month;
Execution Count:3
3
5405 } -
5406 }
executed: }
Execution Count:1587
1587
5407 if (usedMonth && bestMatch != -1)
evaluated: usedMonth
TRUEFALSE
yes
Evaluation Count:109
yes
Evaluation Count:9
evaluated: bestMatch != -1
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:5
5-109
5408 *usedMonth = l.monthName(bestMatch, type);
executed: *usedMonth = l.monthName(bestMatch, type);
Execution Count:104
104
5409 }
executed: }
Execution Count:118
118
5410 if (used) {
evaluated: used
TRUEFALSE
yes
Evaluation Count:109
yes
Evaluation Count:9
9-109
5411 QDTPDEBUG << "used is set to" << bestCount;
never executed: QMessageLogger("tools/qdatetime.cpp", 5411, __PRETTY_FUNCTION__).debug() << "used is set to" << bestCount;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:109
0-109
5412 *used = bestCount;
executed (the execution status of this line is deduced): *used = bestCount;
-
5413 }
executed: }
Execution Count:109
109
5414 return bestMatch;
executed: return bestMatch;
Execution Count:118
118
5415} -
5416 -
5417int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex, QString *usedDay, int *used) const -
5418{ -
5419 int bestMatch = -1;
executed (the execution status of this line is deduced): int bestMatch = -1;
-
5420 int bestCount = 0;
executed (the execution status of this line is deduced): int bestCount = 0;
-
5421 if (!str1.isEmpty()) {
partially evaluated: !str1.isEmpty()
TRUEFALSE
yes
Evaluation Count:29
no
Evaluation Count:0
0-29
5422 const SectionNode &sn = sectionNode(sectionIndex);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(sectionIndex);
-
5423 if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) {
partially evaluated: !(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29
0-29
5424 qWarning("QDateTimeParser::findDay Internal error");
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 5424, __PRETTY_FUNCTION__).warning("QDateTimeParser::findDay Internal error");
-
5425 return -1;
never executed: return -1;
0
5426 } -
5427 const QLocale l = locale();
executed (the execution status of this line is deduced): const QLocale l = locale();
-
5428 for (int day=startDay; day<=7; ++day) {
evaluated: day<=7
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:1
1-97
5429 const QString str2 = l.dayName(day, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat);
executed (the execution status of this line is deduced): const QString str2 = l.dayName(day, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat);
-
5430 -
5431 if (str1.startsWith(str2.toLower())) {
evaluated: str1.startsWith(str2.toLower())
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:69
28-69
5432 if (used)
partially evaluated: used
TRUEFALSE
yes
Evaluation Count:28
no
Evaluation Count:0
0-28
5433 *used = str2.size();
executed: *used = str2.size();
Execution Count:28
28
5434 if (usedDay) {
partially evaluated: usedDay
TRUEFALSE
yes
Evaluation Count:28
no
Evaluation Count:0
0-28
5435 *usedDay = str2;
executed (the execution status of this line is deduced): *usedDay = str2;
-
5436 }
executed: }
Execution Count:28
28
5437 return day;
executed: return day;
Execution Count:28
28
5438 } -
5439 if (context == FromString)
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:9
9-60
5440 continue;
executed: continue;
Execution Count:60
60
5441 -
5442 const int limit = qMin(str1.size(), str2.size());
executed (the execution status of this line is deduced): const int limit = qMin(str1.size(), str2.size());
-
5443 bool found = true;
executed (the execution status of this line is deduced): bool found = true;
-
5444 for (int i=0; i<limit; ++i) {
partially evaluated: i<limit
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
5445 if (str1.at(i) != str2.at(i) && !str1.at(i).isSpace()) {
partially evaluated: str1.at(i) != str2.at(i)
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
partially evaluated: !str1.at(i).isSpace()
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
5446 if (i > bestCount) {
partially evaluated: i > bestCount
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
5447 bestCount = i;
never executed (the execution status of this line is deduced): bestCount = i;
-
5448 bestMatch = day;
never executed (the execution status of this line is deduced): bestMatch = day;
-
5449 }
never executed: }
0
5450 found = false;
executed (the execution status of this line is deduced): found = false;
-
5451 break;
executed: break;
Execution Count:9
9
5452 } -
5453 -
5454 }
never executed: }
0
5455 if (found) {
partially evaluated: found
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
5456 if (used)
never evaluated: used
0
5457 *used = limit;
never executed: *used = limit;
0
5458 if (usedDay)
never evaluated: usedDay
0
5459 *usedDay = str2;
never executed: *usedDay = str2;
0
5460 -
5461 return day;
never executed: return day;
0
5462 } -
5463 }
executed: }
Execution Count:9
9
5464 if (usedDay && bestMatch != -1) {
partially evaluated: usedDay
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: bestMatch != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
5465 *usedDay = l.dayName(bestMatch, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat);
never executed (the execution status of this line is deduced): *usedDay = l.dayName(bestMatch, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat);
-
5466 }
never executed: }
0
5467 }
executed: }
Execution Count:1
1
5468 if (used)
partially evaluated: used
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
5469 *used = bestCount;
executed: *used = bestCount;
Execution Count:1
1
5470 -
5471 return bestMatch;
executed: return bestMatch;
Execution Count:1
1
5472} -
5473#endif // QT_NO_TEXTDATE -
5474 -
5475/*! -
5476 \internal -
5477 -
5478 returns -
5479 0 if str == QDateTimeEdit::tr("AM") -
5480 1 if str == QDateTimeEdit::tr("PM") -
5481 2 if str can become QDateTimeEdit::tr("AM") -
5482 3 if str can become QDateTimeEdit::tr("PM") -
5483 4 if str can become QDateTimeEdit::tr("PM") and can become QDateTimeEdit::tr("AM") -
5484 -1 can't become anything sensible -
5485 -
5486*/ -
5487 -
5488int QDateTimeParser::findAmPm(QString &str, int index, int *used) const -
5489{ -
5490 const SectionNode &s = sectionNode(index);
executed (the execution status of this line is deduced): const SectionNode &s = sectionNode(index);
-
5491 if (s.type != AmPmSection) {
partially evaluated: s.type != AmPmSection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:864
0-864
5492 qWarning("QDateTimeParser::findAmPm Internal error");
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 5492, __PRETTY_FUNCTION__).warning("QDateTimeParser::findAmPm Internal error");
-
5493 return -1;
never executed: return -1;
0
5494 } -
5495 if (used)
partially evaluated: used
TRUEFALSE
yes
Evaluation Count:864
no
Evaluation Count:0
0-864
5496 *used = str.size();
executed: *used = str.size();
Execution Count:864
864
5497 if (str.trimmed().isEmpty()) {
partially evaluated: str.trimmed().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:864
0-864
5498 return PossibleBoth;
never executed: return PossibleBoth;
0
5499 } -
5500 const QLatin1Char space(' ');
executed (the execution status of this line is deduced): const QLatin1Char space(' ');
-
5501 int size = sectionMaxSize(index);
executed (the execution status of this line is deduced): int size = sectionMaxSize(index);
-
5502 -
5503 enum {
executed (the execution status of this line is deduced): enum {
-
5504 amindex = 0,
executed (the execution status of this line is deduced): amindex = 0,
-
5505 pmindex = 1
executed (the execution status of this line is deduced): pmindex = 1
-
5506 };
executed (the execution status of this line is deduced): };
-
5507 QString ampm[2];
executed (the execution status of this line is deduced): QString ampm[2];
-
5508 ampm[amindex] = getAmPmText(AmText, s.count == 1 ? UpperCase : LowerCase);
executed (the execution status of this line is deduced): ampm[amindex] = getAmPmText(AmText, s.count == 1 ? UpperCase : LowerCase);
-
5509 ampm[pmindex] = getAmPmText(PmText, s.count == 1 ? UpperCase : LowerCase);
executed (the execution status of this line is deduced): ampm[pmindex] = getAmPmText(PmText, s.count == 1 ? UpperCase : LowerCase);
-
5510 for (int i=0; i<2; ++i)
evaluated: i<2
TRUEFALSE
yes
Evaluation Count:1728
yes
Evaluation Count:864
864-1728
5511 ampm[i].truncate(size);
executed: ampm[i].truncate(size);
Execution Count:1728
1728
5512 -
5513 QDTPDEBUG << "findAmPm" << str << ampm[0] << ampm[1];
never executed: QMessageLogger("tools/qdatetime.cpp", 5513, __PRETTY_FUNCTION__).debug() << "findAmPm" << str << ampm[0] << ampm[1];
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:864
0-864
5514 -
5515 if (str.indexOf(ampm[amindex], 0, Qt::CaseInsensitive) == 0) {
evaluated: str.indexOf(ampm[amindex], 0, Qt::CaseInsensitive) == 0
TRUEFALSE
yes
Evaluation Count:759
yes
Evaluation Count:105
105-759
5516 str = ampm[amindex];
executed (the execution status of this line is deduced): str = ampm[amindex];
-
5517 return AM;
executed: return AM;
Execution Count:759
759
5518 } else if (str.indexOf(ampm[pmindex], 0, Qt::CaseInsensitive) == 0) {
evaluated: str.indexOf(ampm[pmindex], 0, Qt::CaseInsensitive) == 0
TRUEFALSE
yes
Evaluation Count:103
yes
Evaluation Count:2
2-103
5519 str = ampm[pmindex];
executed (the execution status of this line is deduced): str = ampm[pmindex];
-
5520 return PM;
executed: return PM;
Execution Count:103
103
5521 } else if (context == FromString || (str.count(space) == 0 && str.size() >= size)) {
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
partially evaluated: str.count(space) == 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: str.size() >= size
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
5522 return Neither;
executed: return Neither;
Execution Count:1
1
5523 } -
5524 size = qMin(size, str.size());
executed (the execution status of this line is deduced): size = qMin(size, str.size());
-
5525 -
5526 bool broken[2] = {false, false};
executed (the execution status of this line is deduced): bool broken[2] = {false, false};
-
5527 for (int i=0; i<size; ++i) {
partially evaluated: i<size
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
5528 if (str.at(i) != space) {
partially evaluated: str.at(i) != space
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
5529 for (int j=0; j<2; ++j) {
partially evaluated: j<2
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
5530 if (!broken[j]) {
partially evaluated: !broken[j]
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
5531 int index = ampm[j].indexOf(str.at(i));
executed (the execution status of this line is deduced): int index = ampm[j].indexOf(str.at(i));
-
5532 QDTPDEBUG << "looking for" << str.at(i)
never executed: QMessageLogger("tools/qdatetime.cpp", 5532, __PRETTY_FUNCTION__).debug() << "looking for" << str.at(i) << "in" << ampm[j] << "and got" << index;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5533 << "in" << ampm[j] << "and got" << index;
never executed: QMessageLogger("tools/qdatetime.cpp", 5532, __PRETTY_FUNCTION__).debug() << "looking for" << str.at(i) << "in" << ampm[j] << "and got" << index;
0
5534 if (index == -1) {
partially evaluated: index == -1
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
5535 if (str.at(i).category() == QChar::Letter_Uppercase) {
partially evaluated: str.at(i).category() == QChar::Letter_Uppercase
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5536 index = ampm[j].indexOf(str.at(i).toLower());
never executed (the execution status of this line is deduced): index = ampm[j].indexOf(str.at(i).toLower());
-
5537 QDTPDEBUG << "trying with" << str.at(i).toLower()
never executed: QMessageLogger("tools/qdatetime.cpp", 5537, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toLower() << "in" << ampm[j] << "and got" << index;
never evaluated: false
0
5538 << "in" << ampm[j] << "and got" << index;
never executed: QMessageLogger("tools/qdatetime.cpp", 5537, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toLower() << "in" << ampm[j] << "and got" << index;
0
5539 } else if (str.at(i).category() == QChar::Letter_Lowercase) {
never executed: }
partially evaluated: str.at(i).category() == QChar::Letter_Lowercase
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5540 index = ampm[j].indexOf(str.at(i).toUpper());
never executed (the execution status of this line is deduced): index = ampm[j].indexOf(str.at(i).toUpper());
-
5541 QDTPDEBUG << "trying with" << str.at(i).toUpper()
never executed: QMessageLogger("tools/qdatetime.cpp", 5541, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toUpper() << "in" << ampm[j] << "and got" << index;
never evaluated: false
0
5542 << "in" << ampm[j] << "and got" << index;
never executed: QMessageLogger("tools/qdatetime.cpp", 5541, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toUpper() << "in" << ampm[j] << "and got" << index;
0
5543 }
never executed: }
0
5544 if (index == -1) {
partially evaluated: index == -1
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
5545 broken[j] = true;
executed (the execution status of this line is deduced): broken[j] = true;
-
5546 if (broken[amindex] && broken[pmindex]) {
partially evaluated: broken[amindex]
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
evaluated: broken[pmindex]
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
0-2
5547 QDTPDEBUG << str << "didn't make it";
never executed: QMessageLogger("tools/qdatetime.cpp", 5547, __PRETTY_FUNCTION__).debug() << str << "didn't make it";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
5548 return Neither;
executed: return Neither;
Execution Count:1
1
5549 } -
5550 continue;
executed: continue;
Execution Count:1
1
5551 } else { -
5552 str[i] = ampm[j].at(index); // fix case
never executed (the execution status of this line is deduced): str[i] = ampm[j].at(index);
-
5553 }
never executed: }
0
5554 } -
5555 ampm[j].remove(index, 1);
never executed (the execution status of this line is deduced): ampm[j].remove(index, 1);
-
5556 }
never executed: }
0
5557 }
never executed: }
0
5558 }
never executed: }
0
5559 }
never executed: }
0
5560 if (!broken[pmindex] && !broken[amindex])
never evaluated: !broken[pmindex]
never evaluated: !broken[amindex]
0
5561 return PossibleBoth;
never executed: return PossibleBoth;
0
5562 return (!broken[amindex] ? PossibleAM : PossiblePM);
never executed: return (!broken[amindex] ? PossibleAM : PossiblePM);
0
5563} -
5564 -
5565/*! -
5566 \internal -
5567 Max number of units that can be changed by this section. -
5568*/ -
5569 -
5570int QDateTimeParser::maxChange(int index) const -
5571{ -
5572 const SectionNode &sn = sectionNode(index);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(index);
-
5573 switch (sn.type) { -
5574 // Time. unit is msec -
5575 case MSecSection: return 999;
never executed: return 999;
0
5576 case SecondSection: return 59 * 1000;
never executed: return 59 * 1000;
0
5577 case MinuteSection: return 59 * 60 * 1000;
executed: return 59 * 60 * 1000;
Execution Count:11
11
5578 case Hour24Section: case Hour12Section: return 59 * 60 * 60 * 1000;
executed: return 59 * 60 * 60 * 1000;
Execution Count:9
9
5579 -
5580 // Date. unit is day -
5581 case DayOfWeekSectionShort: -
5582 case DayOfWeekSectionLong: return 7;
never executed: return 7;
0
5583 case DaySection: return 30;
never executed: return 30;
0
5584 case MonthSection: return 365 - 31;
never executed: return 365 - 31;
0
5585 case YearSection: return 9999 * 365;
executed: return 9999 * 365;
Execution Count:29
29
5586 case YearSection2Digits: return 100 * 365;
executed: return 100 * 365;
Execution Count:3
3
5587 default: -
5588 qWarning("QDateTimeParser::maxChange() Internal error (%s)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 5588, __PRETTY_FUNCTION__).warning("QDateTimeParser::maxChange() Internal error (%s)",
-
5589 qPrintable(sectionName(sectionType(index))));
never executed (the execution status of this line is deduced): QString(sectionName(sectionType(index))).toLocal8Bit().constData());
-
5590 }
never executed: }
0
5591 -
5592 return -1;
never executed: return -1;
0
5593} -
5594 -
5595QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const -
5596{ -
5597 FieldInfo ret = 0;
executed (the execution status of this line is deduced): FieldInfo ret = 0;
-
5598 const SectionNode &sn = sectionNode(index);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(index);
-
5599 const Section s = sn.type;
executed (the execution status of this line is deduced): const Section s = sn.type;
-
5600 switch (s) { -
5601 case MSecSection: -
5602 ret |= Fraction;
executed (the execution status of this line is deduced): ret |= Fraction;
-
5603 // fallthrough -
5604 case SecondSection:
code before this statement executed: case SecondSection:
Execution Count:225
225
5605 case MinuteSection: -
5606 case Hour24Section: -
5607 case Hour12Section: -
5608 case YearSection: -
5609 case YearSection2Digits: -
5610 ret |= Numeric;
executed (the execution status of this line is deduced): ret |= Numeric;
-
5611 if (s != YearSection) {
evaluated: s != YearSection
TRUEFALSE
yes
Evaluation Count:6372
yes
Evaluation Count:1019
1019-6372
5612 ret |= AllowPartial;
executed (the execution status of this line is deduced): ret |= AllowPartial;
-
5613 }
executed: }
Execution Count:6372
6372
5614 if (sn.count != 1) {
evaluated: sn.count != 1
TRUEFALSE
yes
Evaluation Count:7058
yes
Evaluation Count:333
333-7058
5615 ret |= FixedWidth;
executed (the execution status of this line is deduced): ret |= FixedWidth;
-
5616 }
executed: }
Execution Count:7058
7058
5617 break;
executed: break;
Execution Count:7391
7391
5618 case MonthSection: -
5619 case DaySection: -
5620 switch (sn.count) { -
5621 case 2: -
5622 ret |= FixedWidth;
executed (the execution status of this line is deduced): ret |= FixedWidth;
-
5623 // fallthrough -
5624 case 1:
code before this statement executed: case 1:
Execution Count:2281
2281
5625 ret |= (Numeric|AllowPartial);
executed (the execution status of this line is deduced): ret |= (Numeric|AllowPartial);
-
5626 break;
executed: break;
Execution Count:2723
2723
5627 } -
5628 break;
executed: break;
Execution Count:2743
2743
5629 case DayOfWeekSectionShort: -
5630 case DayOfWeekSectionLong: -
5631 if (sn.count == 3)
never evaluated: sn.count == 3
0
5632 ret |= FixedWidth;
never executed: ret |= FixedWidth;
0
5633 break;
never executed: break;
0
5634 case AmPmSection: -
5635 ret |= FixedWidth;
never executed (the execution status of this line is deduced): ret |= FixedWidth;
-
5636 break;
never executed: break;
0
5637 default: -
5638 qWarning("QDateTimeParser::fieldInfo Internal error 2 (%d %s %d)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 5638, __PRETTY_FUNCTION__).warning("QDateTimeParser::fieldInfo Internal error 2 (%d %s %d)",
-
5639 index, qPrintable(sectionName(sn.type)), sn.count);
never executed (the execution status of this line is deduced): index, QString(sectionName(sn.type)).toLocal8Bit().constData(), sn.count);
-
5640 break;
never executed: break;
0
5641 } -
5642 return ret;
executed: return ret;
Execution Count:10134
10134
5643} -
5644 -
5645/*! -
5646 \internal -
5647 -
5648 Get a number that str can become which is between min -
5649 and max or -1 if this is not possible. -
5650*/ -
5651 -
5652 -
5653QString QDateTimeParser::sectionFormat(int index) const -
5654{ -
5655 const SectionNode &sn = sectionNode(index);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(index);
-
5656 return sectionFormat(sn.type, sn.count);
executed: return sectionFormat(sn.type, sn.count);
Execution Count:6
6
5657} -
5658 -
5659QString QDateTimeParser::sectionFormat(Section s, int count) const -
5660{ -
5661 QChar fillChar;
executed (the execution status of this line is deduced): QChar fillChar;
-
5662 switch (s) { -
5663 case AmPmSection: return count == 1 ? QLatin1String("AP") : QLatin1String("ap");
never executed: return count == 1 ? QLatin1String("AP") : QLatin1String("ap");
0
5664 case MSecSection: fillChar = QLatin1Char('z'); break;
never executed: break;
0
5665 case SecondSection: fillChar = QLatin1Char('s'); break;
never executed: break;
0
5666 case MinuteSection: fillChar = QLatin1Char('m'); break;
never executed: break;
0
5667 case Hour24Section: fillChar = QLatin1Char('H'); break;
never executed: break;
0
5668 case Hour12Section: fillChar = QLatin1Char('h'); break;
never executed: break;
0
5669 case DayOfWeekSectionShort: -
5670 case DayOfWeekSectionLong: -
5671 case DaySection: fillChar = QLatin1Char('d'); break;
executed: break;
Execution Count:2
2
5672 case MonthSection: fillChar = QLatin1Char('M'); break;
executed: break;
Execution Count:2
2
5673 case YearSection2Digits: -
5674 case YearSection: fillChar = QLatin1Char('y'); break;
executed: break;
Execution Count:2
2
5675 default: -
5676 qWarning("QDateTimeParser::sectionFormat Internal error (%s)",
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 5676, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionFormat Internal error (%s)",
-
5677 qPrintable(sectionName(s)));
never executed (the execution status of this line is deduced): QString(sectionName(s)).toLocal8Bit().constData());
-
5678 return QString();
never executed: return QString();
0
5679 } -
5680 if (fillChar.isNull()) {
partially evaluated: fillChar.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
5681 qWarning("QDateTimeParser::sectionFormat Internal error 2");
never executed (the execution status of this line is deduced): QMessageLogger("tools/qdatetime.cpp", 5681, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionFormat Internal error 2");
-
5682 return QString();
never executed: return QString();
0
5683 } -
5684 -
5685 QString str;
executed (the execution status of this line is deduced): QString str;
-
5686 str.fill(fillChar, count);
executed (the execution status of this line is deduced): str.fill(fillChar, count);
-
5687 return str;
executed: return str;
Execution Count:6
6
5688} -
5689 -
5690 -
5691/*! -
5692 \internal -
5693 -
5694 Returns true if str can be modified to represent a -
5695 number that is within min and max. -
5696*/ -
5697 -
5698bool QDateTimeParser::potentialValue(const QString &str, int min, int max, int index, -
5699 const QDateTime &currentValue, int insert) const -
5700{ -
5701 if (str.isEmpty()) {
evaluated: str.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:992
3-992
5702 return true;
executed: return true;
Execution Count:3
3
5703 } -
5704 const int size = sectionMaxSize(index);
executed (the execution status of this line is deduced): const int size = sectionMaxSize(index);
-
5705 int val = (int)locale().toUInt(str);
executed (the execution status of this line is deduced): int val = (int)locale().toUInt(str);
-
5706 const SectionNode &sn = sectionNode(index);
executed (the execution status of this line is deduced): const SectionNode &sn = sectionNode(index);
-
5707 if (sn.type == YearSection2Digits) {
evaluated: sn.type == YearSection2Digits
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:972
20-972
5708 val += currentValue.date().year() - (currentValue.date().year() % 100);
executed (the execution status of this line is deduced): val += currentValue.date().year() - (currentValue.date().year() % 100);
-
5709 }
executed: }
Execution Count:20
20
5710 if (val >= min && val <= max && str.size() == size) {
evaluated: val >= min
TRUEFALSE
yes
Evaluation Count:791
yes
Evaluation Count:201
evaluated: val <= max
TRUEFALSE
yes
Evaluation Count:701
yes
Evaluation Count:90
evaluated: str.size() == size
TRUEFALSE
yes
Evaluation Count:362
yes
Evaluation Count:339
90-791
5711 return true;
executed: return true;
Execution Count:362
362
5712 } else if (val > max) {
evaluated: val > max
TRUEFALSE
yes
Evaluation Count:90
yes
Evaluation Count:540
90-540
5713 return false;
executed: return false;
Execution Count:90
90
5714 } else if (str.size() == size && val < min) {
evaluated: str.size() == size
TRUEFALSE
yes
Evaluation Count:115
yes
Evaluation Count:425
partially evaluated: val < min
TRUEFALSE
yes
Evaluation Count:115
no
Evaluation Count:0
0-425
5715 return false;
executed: return false;
Execution Count:115
115
5716 } -
5717 -
5718 const int len = size - str.size();
executed (the execution status of this line is deduced): const int len = size - str.size();
-
5719 for (int i=0; i<len; ++i) {
evaluated: i<len
TRUEFALSE
yes
Evaluation Count:425
yes
Evaluation Count:13
13-425
5720 for (int j=0; j<10; ++j) {
evaluated: j<10
TRUEFALSE
yes
Evaluation Count:608
yes
Evaluation Count:13
13-608
5721 if (potentialValue(str + QLatin1Char('0' + j), min, max, index, currentValue, insert)) {
evaluated: potentialValue(str + QLatin1Char('0' + j), min, max, index, currentValue, insert)
TRUEFALSE
yes
Evaluation Count:409
yes
Evaluation Count:199
199-409
5722 return true;
executed: return true;
Execution Count:409
409
5723 } else if (insert >= 0) {
evaluated: insert >= 0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:190
9-190
5724 QString tmp = str;
executed (the execution status of this line is deduced): QString tmp = str;
-
5725 tmp.insert(insert, QLatin1Char('0' + j));
executed (the execution status of this line is deduced): tmp.insert(insert, QLatin1Char('0' + j));
-
5726 if (potentialValue(tmp, min, max, index, currentValue, insert))
evaluated: potentialValue(tmp, min, max, index, currentValue, insert)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:6
3-6
5727 return true;
executed: return true;
Execution Count:3
3
5728 }
executed: }
Execution Count:6
6
5729 } -
5730 }
executed: }
Execution Count:13
13
5731 -
5732 return false;
executed: return false;
Execution Count:13
13
5733} -
5734 -
5735bool QDateTimeParser::skipToNextSection(int index, const QDateTime &current, const QString &text) const -
5736{ -
5737 Q_ASSERT(current >= getMinimum() && current <= getMaximum());
executed (the execution status of this line is deduced): qt_noop();
-
5738 -
5739 const SectionNode &node = sectionNode(index);
executed (the execution status of this line is deduced): const SectionNode &node = sectionNode(index);
-
5740 Q_ASSERT(text.size() < sectionMaxSize(index));
executed (the execution status of this line is deduced): qt_noop();
-
5741 -
5742 const QDateTime maximum = getMaximum();
executed (the execution status of this line is deduced): const QDateTime maximum = getMaximum();
-
5743 const QDateTime minimum = getMinimum();
executed (the execution status of this line is deduced): const QDateTime minimum = getMinimum();
-
5744 QDateTime tmp = current;
executed (the execution status of this line is deduced): QDateTime tmp = current;
-
5745 int min = absoluteMin(index);
executed (the execution status of this line is deduced): int min = absoluteMin(index);
-
5746 setDigit(tmp, index, min);
executed (the execution status of this line is deduced): setDigit(tmp, index, min);
-
5747 if (tmp < minimum) {
evaluated: tmp < minimum
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:309
17-309
5748 min = getDigit(minimum, index);
executed (the execution status of this line is deduced): min = getDigit(minimum, index);
-
5749 }
executed: }
Execution Count:17
17
5750 -
5751 int max = absoluteMax(index, current);
executed (the execution status of this line is deduced): int max = absoluteMax(index, current);
-
5752 setDigit(tmp, index, max);
executed (the execution status of this line is deduced): setDigit(tmp, index, max);
-
5753 if (tmp > maximum) {
evaluated: tmp > maximum
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:293
33-293
5754 max = getDigit(maximum, index);
executed (the execution status of this line is deduced): max = getDigit(maximum, index);
-
5755 }
executed: }
Execution Count:33
33
5756 int pos = cursorPosition() - node.pos;
executed (the execution status of this line is deduced): int pos = cursorPosition() - node.pos;
-
5757 if (pos < 0 || pos >= text.size())
evaluated: pos < 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:319
evaluated: pos >= text.size()
TRUEFALSE
yes
Evaluation Count:312
yes
Evaluation Count:7
7-319
5758 pos = -1;
executed: pos = -1;
Execution Count:319
319
5759 -
5760 const bool potential = potentialValue(text, min, max, index, current, pos);
executed (the execution status of this line is deduced): const bool potential = potentialValue(text, min, max, index, current, pos);
-
5761 return !potential;
executed: return !potential;
Execution Count:326
326
5762 -
5763 /* If the value potentially can become another valid entry we -
5764 * don't want to skip to the next. E.g. In a M field (month -
5765 * without leading 0 if you type 1 we don't want to autoskip but -
5766 * if you type 3 we do -
5767 */ -
5768} -
5769 -
5770/*! -
5771 \internal -
5772 For debugging. Returns the name of the section \a s. -
5773*/ -
5774 -
5775QString QDateTimeParser::sectionName(int s) const -
5776{ -
5777 switch (s) { -
5778 case QDateTimeParser::AmPmSection: return QLatin1String("AmPmSection");
never executed: return QLatin1String("AmPmSection");
0
5779 case QDateTimeParser::DaySection: return QLatin1String("DaySection");
never executed: return QLatin1String("DaySection");
0
5780 case QDateTimeParser::DayOfWeekSectionShort: return QLatin1String("DayOfWeekSectionShort");
never executed: return QLatin1String("DayOfWeekSectionShort");
0
5781 case QDateTimeParser::DayOfWeekSectionLong: return QLatin1String("DayOfWeekSectionLong");
never executed: return QLatin1String("DayOfWeekSectionLong");
0
5782 case QDateTimeParser::Hour24Section: return QLatin1String("Hour24Section");
never executed: return QLatin1String("Hour24Section");
0
5783 case QDateTimeParser::Hour12Section: return QLatin1String("Hour12Section");
never executed: return QLatin1String("Hour12Section");
0
5784 case QDateTimeParser::MSecSection: return QLatin1String("MSecSection");
never executed: return QLatin1String("MSecSection");
0
5785 case QDateTimeParser::MinuteSection: return QLatin1String("MinuteSection");
never executed: return QLatin1String("MinuteSection");
0
5786 case QDateTimeParser::MonthSection: return QLatin1String("MonthSection");
never executed: return QLatin1String("MonthSection");
0
5787 case QDateTimeParser::SecondSection: return QLatin1String("SecondSection");
never executed: return QLatin1String("SecondSection");
0
5788 case QDateTimeParser::YearSection: return QLatin1String("YearSection");
never executed: return QLatin1String("YearSection");
0
5789 case QDateTimeParser::YearSection2Digits: return QLatin1String("YearSection2Digits");
never executed: return QLatin1String("YearSection2Digits");
0
5790 case QDateTimeParser::NoSection: return QLatin1String("NoSection");
never executed: return QLatin1String("NoSection");
0
5791 case QDateTimeParser::FirstSection: return QLatin1String("FirstSection");
never executed: return QLatin1String("FirstSection");
0
5792 case QDateTimeParser::LastSection: return QLatin1String("LastSection");
never executed: return QLatin1String("LastSection");
0
5793 default: return QLatin1String("Unknown section ") + QString::number(s);
never executed: return QLatin1String("Unknown section ") + QString::number(s);
0
5794 } -
5795}
never executed: }
0
5796 -
5797/*! -
5798 \internal -
5799 For debugging. Returns the name of the state \a s. -
5800*/ -
5801 -
5802QString QDateTimeParser::stateName(int s) const -
5803{ -
5804 switch (s) { -
5805 case Invalid: return QLatin1String("Invalid");
never executed: return QLatin1String("Invalid");
0
5806 case Intermediate: return QLatin1String("Intermediate");
never executed: return QLatin1String("Intermediate");
0
5807 case Acceptable: return QLatin1String("Acceptable");
never executed: return QLatin1String("Acceptable");
0
5808 default: return QLatin1String("Unknown state ") + QString::number(s);
never executed: return QLatin1String("Unknown state ") + QString::number(s);
0
5809 } -
5810}
never executed: }
0
5811 -
5812#ifndef QT_NO_DATESTRING -
5813bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) const -
5814{ -
5815 QDateTime val(QDate(1900, 1, 1), QDATETIMEEDIT_TIME_MIN);
executed (the execution status of this line is deduced): QDateTime val(QDate(1900, 1, 1), QTime(0, 0, 0, 0));
-
5816 QString text = t;
executed (the execution status of this line is deduced): QString text = t;
-
5817 int copy = -1;
executed (the execution status of this line is deduced): int copy = -1;
-
5818 const StateNode tmp = parse(text, copy, val, false);
executed (the execution status of this line is deduced): const StateNode tmp = parse(text, copy, val, false);
-
5819 if (tmp.state != Acceptable || tmp.conflicts) {
evaluated: tmp.state != Acceptable
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:105
evaluated: tmp.conflicts
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:101
4-105
5820 return false;
executed: return false;
Execution Count:23
23
5821 } -
5822 if (time) {
evaluated: time
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:36
36-65
5823 const QTime t = tmp.value.time();
executed (the execution status of this line is deduced): const QTime t = tmp.value.time();
-
5824 if (!t.isValid()) {
partially evaluated: !t.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:65
0-65
5825 return false;
never executed: return false;
0
5826 } -
5827 *time = t;
executed (the execution status of this line is deduced): *time = t;
-
5828 }
executed: }
Execution Count:65
65
5829 -
5830 if (date) {
evaluated: date
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:6
6-95
5831 const QDate d = tmp.value.date();
executed (the execution status of this line is deduced): const QDate d = tmp.value.date();
-
5832 if (!d.isValid()) {
partially evaluated: !d.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:95
0-95
5833 return false;
never executed: return false;
0
5834 } -
5835 *date = d;
executed (the execution status of this line is deduced): *date = d;
-
5836 }
executed: }
Execution Count:95
95
5837 return true;
executed: return true;
Execution Count:101
101
5838} -
5839#endif // QT_NO_DATESTRING -
5840 -
5841QDateTime QDateTimeParser::getMinimum() const -
5842{ -
5843 return QDateTime(QDATETIMEEDIT_DATE_MIN, QDATETIMEEDIT_TIME_MIN, spec);
executed: return QDateTime(QDate(100, 1, 1), QTime(0, 0, 0, 0), spec);
Execution Count:147
147
5844} -
5845 -
5846QDateTime QDateTimeParser::getMaximum() const -
5847{ -
5848 return QDateTime(QDATETIMEEDIT_DATE_MAX, QDATETIMEEDIT_TIME_MAX, spec);
executed: return QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999), spec);
Execution Count:127
127
5849} -
5850 -
5851QString QDateTimeParser::getAmPmText(AmPm ap, Case cs) const -
5852{ -
5853 if (ap == AmText) {
evaluated: ap == AmText
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:65
65
5854 return (cs == UpperCase ? QLatin1String("AM") : QLatin1String("am"));
executed: return (cs == UpperCase ? QLatin1String("AM") : QLatin1String("am"));
Execution Count:65
65
5855 } else { -
5856 return (cs == UpperCase ? QLatin1String("PM") : QLatin1String("pm"));
executed: return (cs == UpperCase ? QLatin1String("PM") : QLatin1String("pm"));
Execution Count:65
65
5857 } -
5858} -
5859 -
5860/* -
5861 \internal -
5862 -
5863 I give arg2 preference because arg1 is always a QDateTime. -
5864*/ -
5865 -
5866bool operator==(const QDateTimeParser::SectionNode &s1, const QDateTimeParser::SectionNode &s2) -
5867{ -
5868 return (s1.type == s2.type) && (s1.pos == s2.pos) && (s1.count == s2.count);
never executed: return (s1.type == s2.type) && (s1.pos == s2.pos) && (s1.count == s2.count);
0
5869} -
5870 -
5871#endif // QT_BOOTSTRAPPED -
5872 -
5873QT_END_NAMESPACE -
5874 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial