tools/qdatetime.cpp

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

Generated by Squish Coco Non-Commercial