tools/qdatetime.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8enum { -
9 SECS_PER_DAY = 86400, -
10 MSECS_PER_DAY = 86400000, -
11 SECS_PER_HOUR = 3600, -
12 MSECS_PER_HOUR = 3600000, -
13 SECS_PER_MIN = 60, -
14 MSECS_PER_MIN = 60000, -
15 JULIAN_DAY_FOR_EPOCH = 2440588 -
16}; -
17 -
18static inline QDate fixedDate(int y, int m, int d) -
19{ -
20 QDate result(y, m, 1); -
21 result.setDate(y, m, qMin(d, result.daysInMonth())); -
22 return result;
executed: return result;
Execution Count:202
202
23} -
24 -
25static inline qint64 floordiv(qint64 a, qint64 b) -
26{ -
27 return (a - (a < 0 ? b-1 : 0)) / b;
never executed: return (a - (a < 0 ? b-1 : 0)) / b;
0
28} -
29 -
30static inline qint64 floordiv(qint64 a, int b) -
31{ -
32 return (a - (a < 0 ? b-1 : 0)) / b;
executed: return (a - (a < 0 ? b-1 : 0)) / b;
Execution Count:5915935
5915935
33} -
34 -
35static inline int floordiv(int a, int b) -
36{ -
37 return (a - (a < 0 ? b-1 : 0)) / b;
executed: return (a - (a < 0 ? b-1 : 0)) / b;
Execution Count:12871262
12871262
38} -
39 -
40static inline qint64 julianDayFromDate(int year, int month, int day) -
41{ -
42 -
43 if (year < 0)
evaluated: year < 0
TRUEFALSE
yes
Evaluation Count:239346
yes
Evaluation Count:457303
239346-457303
44 ++year;
executed: ++year;
Execution Count:239346
239346
45 -
46 -
47 -
48 -
49 -
50 -
51 int a = floordiv(14 - month, 12); -
52 qint64 y = (qint64)year + 4800 - a; -
53 int m = month + 12 * a - 3; -
54 return day + floordiv(153 * m + 2, 5) + 365 * y + floordiv(y, 4) - floordiv(y, 100) + floordiv(y, 400) - 32045;
executed: return day + floordiv(153 * m + 2, 5) + 365 * y + floordiv(y, 4) - floordiv(y, 100) + floordiv(y, 400) - 32045;
Execution Count:696649
696649
55} -
56 -
57static void getDateFromJulianDay(qint64 julianDay, int *yearp, int *monthp, int *dayp) -
58{ -
59 -
60 -
61 -
62 -
63 -
64 qint64 a = julianDay + 32044; -
65 qint64 b = floordiv(4 * a + 3, 146097); -
66 int c = a - floordiv(146097 * b, 4); -
67 -
68 int d = floordiv(4 * c + 3, 1461); -
69 int e = c - floordiv(1461 * d, 4); -
70 int m = floordiv(5 * e + 2, 153); -
71 -
72 int day = e - floordiv(153 * m + 2, 5) + 1; -
73 int month = m + 3 - 12 * floordiv(m, 10); -
74 int year = 100 * b + d - 4800 + floordiv(m, 10); -
75 -
76 -
77 if (year <= 0)
evaluated: year <= 0
TRUEFALSE
yes
Evaluation Count:715387
yes
Evaluation Count:1197608
715387-1197608
78 --year ;
executed: --year ;
Execution Count:715387
715387
79 -
80 if (yearp)
evaluated: yearp
TRUEFALSE
yes
Evaluation Count:642902
yes
Evaluation Count:1270093
642902-1270093
81 *yearp = year;
executed: *yearp = year;
Execution Count:642902
642902
82 if (monthp)
evaluated: monthp
TRUEFALSE
yes
Evaluation Count:624035
yes
Evaluation Count:1288960
624035-1288960
83 *monthp = month;
executed: *monthp = month;
Execution Count:624035
624035
84 if (dayp)
evaluated: dayp
TRUEFALSE
yes
Evaluation Count:659443
yes
Evaluation Count:1253552
659443-1253552
85 *dayp = day;
executed: *dayp = day;
Execution Count:659443
659443
86}
executed: }
Execution Count:1912995
1912995
87 -
88 -
89static const char monthDays[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; -
90 -
91 -
92static const char * const qt_shortMonthNames[] = { -
93 "Jan", "Feb", "Mar", "Apr", "May", "Jun", -
94 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -
95 -
96 -
97static QString fmtDateTime(const QString& f, const QTime* dt = 0, const QDate* dd = 0); -
98QDate::QDate(int y, int m, int d) -
99{ -
100 setDate(y, m, d); -
101}
executed: }
Execution Count:129452
129452
102int QDate::year() const -
103{ -
104 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:634780
25-634780
105 return 0;
executed: return 0;
Execution Count:25
25
106 -
107 int y; -
108 getDateFromJulianDay(jd, &y, 0, 0); -
109 return y;
executed: return y;
Execution Count:634780
634780
110} -
111int QDate::month() const -
112{ -
113 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:615917
24-615917
114 return 0;
executed: return 0;
Execution Count:24
24
115 -
116 int m; -
117 getDateFromJulianDay(jd, 0, &m, 0); -
118 return m;
executed: return m;
Execution Count:615917
615917
119} -
120int QDate::day() const -
121{ -
122 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:654174
24-654174
123 return 0;
executed: return 0;
Execution Count:24
24
124 -
125 int d; -
126 getDateFromJulianDay(jd, 0, 0, &d); -
127 return d;
executed: return d;
Execution Count:654174
654174
128} -
129int QDate::dayOfWeek() const -
130{ -
131 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:29688
39-29688
132 return 0;
executed: return 0;
Execution Count:39
39
133 -
134 if (jd >= 0)
evaluated: jd >= 0
TRUEFALSE
yes
Evaluation Count:29680
yes
Evaluation Count:8
8-29680
135 return (jd % 7) + 1;
executed: return (jd % 7) + 1;
Execution Count:29680
29680
136 else -
137 return ((jd + 1) % 7) + 7;
executed: return ((jd + 1) % 7) + 7;
Execution Count:8
8
138} -
139int QDate::dayOfYear() const -
140{ -
141 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:316
1-316
142 return 0;
executed: return 0;
Execution Count:1
1
143 -
144 return jd - julianDayFromDate(year(), 1, 1) + 1;
executed: return jd - julianDayFromDate(year(), 1, 1) + 1;
Execution Count:316
316
145} -
146int QDate::daysInMonth() const -
147{ -
148 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:2849
41-2849
149 return 0;
executed: return 0;
Execution Count:41
41
150 -
151 int y, m; -
152 getDateFromJulianDay(jd, &y, &m, 0); -
153 if (m == 2 && isLeapYear(y))
evaluated: m == 2
TRUEFALSE
yes
Evaluation Count:107
yes
Evaluation Count:2742
evaluated: isLeapYear(y)
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:47
47-2742
154 return 29;
executed: return 29;
Execution Count:60
60
155 else -
156 return monthDays[m];
executed: return monthDays[m];
Execution Count:2789
2789
157} -
158int QDate::daysInYear() const -
159{ -
160 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
161 return 0;
executed: return 0;
Execution Count:1
1
162 -
163 int y; -
164 getDateFromJulianDay(jd, &y, 0, 0); -
165 return isLeapYear(y) ? 366 : 365;
executed: return isLeapYear(y) ? 366 : 365;
Execution Count:4
4
166} -
167int QDate::weekNumber(int *yearNumber) const -
168{ -
169 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:303
3-303
170 return 0;
executed: return 0;
Execution Count:3
3
171 -
172 int year = QDate::year(); -
173 int yday = dayOfYear() - 1; -
174 int wday = dayOfWeek(); -
175 if (wday == 7)
evaluated: wday == 7
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:302
1-302
176 wday = 0;
executed: wday = 0;
Execution Count:1
1
177 int w; -
178 -
179 for (;;) { -
180 int len; -
181 int bot; -
182 int top; -
183 -
184 len = isLeapYear(year) ? 366 : 365;
evaluated: isLeapYear(year)
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:267
38-267
185 -
186 -
187 -
188 -
189 bot = ((yday + 11 - wday) % 7) - 3; -
190 -
191 -
192 -
193 -
194 top = bot - (len % 7); -
195 if (top < -3)
evaluated: top < -3
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:303
2-303
196 top += 7;
executed: top += 7;
Execution Count:2
2
197 top += len; -
198 if (yday >= top) {
evaluated: yday >= top
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:303
2-303
199 ++year; -
200 w = 1; -
201 break;
executed: break;
Execution Count:2
2
202 } -
203 if (yday >= bot) {
evaluated: yday >= bot
TRUEFALSE
yes
Evaluation Count:301
yes
Evaluation Count:2
2-301
204 w = 1 + ((yday - bot) / 7); -
205 break;
executed: break;
Execution Count:301
301
206 } -
207 --year; -
208 yday += isLeapYear(year) ? 366 : 365;
evaluated: isLeapYear(year)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
209 }
executed: }
Execution Count:2
2
210 if (yearNumber != 0)
evaluated: yearNumber != 0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:294
9-294
211 *yearNumber = year;
executed: *yearNumber = year;
Execution Count:9
9
212 return w;
executed: return w;
Execution Count:303
303
213} -
214QString QDate::shortMonthName(int month, QDate::MonthNameType type) -
215{ -
216 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
217 return QString();
executed: return QString();
Execution Count:4
4
218 -
219 switch (type) { -
220 case QDate::DateFormat: -
221 return QLocale::system().monthName(month, QLocale::ShortFormat);
executed: return QLocale::system().monthName(month, QLocale::ShortFormat);
Execution Count:268
268
222 case QDate::StandaloneFormat: -
223 return QLocale::system().standaloneMonthName(month, QLocale::ShortFormat);
executed: return QLocale::system().standaloneMonthName(month, QLocale::ShortFormat);
Execution Count:12
12
224 default: -
225 break;
never executed: break;
0
226 } -
227 return QString();
never executed: return QString();
0
228} -
229QString QDate::longMonthName(int month, MonthNameType type) -
230{ -
231 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
232 return QString();
executed: return QString();
Execution Count:4
4
233 -
234 switch (type) { -
235 case QDate::DateFormat: -
236 return QLocale::system().monthName(month, QLocale::LongFormat);
executed: return QLocale::system().monthName(month, QLocale::LongFormat);
Execution Count:25
25
237 case QDate::StandaloneFormat: -
238 return QLocale::system().standaloneMonthName(month, QLocale::LongFormat);
executed: return QLocale::system().standaloneMonthName(month, QLocale::LongFormat);
Execution Count:12
12
239 default: -
240 break;
never executed: break;
0
241 } -
242 return QString();
never executed: return QString();
0
243} -
244QString QDate::shortDayName(int weekday, MonthNameType type) -
245{ -
246 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
247 return QString();
executed: return QString();
Execution Count:4
4
248 -
249 switch (type) { -
250 case QDate::DateFormat: -
251 return QLocale::system().dayName(weekday, QLocale::ShortFormat);
executed: return QLocale::system().dayName(weekday, QLocale::ShortFormat);
Execution Count:71
71
252 case QDate::StandaloneFormat: -
253 return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat);
executed: return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat);
Execution Count:7
7
254 default: -
255 break;
never executed: break;
0
256 } -
257 return QString();
never executed: return QString();
0
258} -
259QString QDate::longDayName(int weekday, MonthNameType type) -
260{ -
261 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
262 return QString();
executed: return QString();
Execution Count:4
4
263 -
264 switch (type) { -
265 case QDate::DateFormat: -
266 return QLocale::system().dayName(weekday, QLocale::LongFormat);
executed: return QLocale::system().dayName(weekday, QLocale::LongFormat);
Execution Count:15
15
267 case QDate::StandaloneFormat: -
268 return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat);
executed: return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat);
Execution Count:7
7
269 default: -
270 break;
never executed: break;
0
271 } -
272 return QLocale::system().dayName(weekday, QLocale::LongFormat);
never executed: return QLocale::system().dayName(weekday, QLocale::LongFormat);
0
273} -
274QString QDate::toString(Qt::DateFormat f) const -
275{ -
276 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1712
1-1712
277 return QString();
executed: return QString();
Execution Count:1
1
278 int y, m, d; -
279 getDateFromJulianDay(jd, &y, &m, &d); -
280 switch (f) { -
281 case Qt::SystemLocaleDate: -
282 case Qt::SystemLocaleShortDate: -
283 case Qt::SystemLocaleLongDate: -
284 return QLocale::system().toString(*this, f == Qt::SystemLocaleLongDate ? QLocale::LongFormat 1657
285 : QLocale::ShortFormat);
executed: return QLocale::system().toString(*this, f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:1657
1657
286 case Qt::LocaleDate: -
287 case Qt::DefaultLocaleShortDate: -
288 case Qt::DefaultLocaleLongDate: -
289 return QLocale().toString(*this, f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat 15
290 : QLocale::ShortFormat);
executed: return QLocale().toString(*this, f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:15
15
291 default: -
292 -
293 case Qt::TextDate: -
294 { -
295 return QString::fromLatin1("%0 %1 %2 %3") 2
296 .arg(shortDayName(dayOfWeek())) 2
297 .arg(shortMonthName(m)) 2
298 .arg(d) 2
299 .arg(y);
executed: return QString::fromLatin1("%0 %1 %2 %3") .arg(shortDayName(dayOfWeek())) .arg(shortMonthName(m)) .arg(d) .arg(y);
Execution Count:2
2
300 } -
301 -
302 case Qt::ISODate: -
303 { -
304 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
305 return QString();
executed: return QString();
Execution Count:3
3
306 QString year(QString::number(y).rightJustified(4, QLatin1Char('0'))); -
307 QString month(QString::number(m).rightJustified(2, QLatin1Char('0'))); -
308 QString day(QString::number(d).rightJustified(2, QLatin1Char('0'))); -
309 return year + QLatin1Char('-') + month + QLatin1Char('-') + day;
executed: return year + QLatin1Char('-') + month + QLatin1Char('-') + day;
Execution Count:35
35
310 } -
311 } -
312}
never executed: }
0
313QString QDate::toString(const QString& format) const -
314{ -
315 if (year() > 9999)
evaluated: year() > 9999
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:13134
2-13134
316 return QString();
executed: return QString();
Execution Count:2
2
317 return fmtDateTime(format, 0, this);
executed: return fmtDateTime(format, 0, this);
Execution Count:13134
13134
318} -
319bool QDate::setDate(int year, int month, int day) -
320{ -
321 if (isValid(year, month, day))
evaluated: isValid(year, month, day)
TRUEFALSE
yes
Evaluation Count:686490
yes
Evaluation Count:11328
11328-686490
322 jd = julianDayFromDate(year, month, day);
executed: jd = julianDayFromDate(year, month, day);
Execution Count:686490
686490
323 else -
324 jd = nullJd();
executed: jd = nullJd();
Execution Count:11328
11328
325 -
326 return isValid();
executed: return isValid();
Execution Count:697818
697818
327} -
328void QDate::getDate(int *year, int *month, int *day) -
329{ -
330 if (isValid()) {
evaluated: isValid()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3
3-4
331 getDateFromJulianDay(jd, year, month, day); -
332 } else {
executed: }
Execution Count:4
4
333 if (year)
evaluated: year
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
334 *year = 0;
executed: *year = 0;
Execution Count:2
2
335 if (month)
evaluated: month
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
336 *month = 0;
executed: *month = 0;
Execution Count:2
2
337 if (day)
evaluated: day
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
338 *day = 0;
executed: *day = 0;
Execution Count:2
2
339 }
executed: }
Execution Count:3
3
340} -
341QDate QDate::addDays(qint64 ndays) const -
342{ -
343 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:618514
1-618514
344 return QDate();
executed: return QDate();
Execution Count:1
1
345 -
346 -
347 -
348 return fromJulianDay(jd + ndays);
executed: return fromJulianDay(jd + ndays);
Execution Count:618514
618514
349} -
350QDate QDate::addMonths(int nmonths) const -
351{ -
352 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:123
1-123
353 return QDate();
executed: return QDate();
Execution Count:1
1
354 if (!nmonths)
evaluated: !nmonths
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:120
3-120
355 return *this;
executed: return *this;
Execution Count:3
3
356 -
357 int old_y, y, m, d; -
358 getDateFromJulianDay(jd, &y, &m, &d); -
359 old_y = y; -
360 -
361 bool increasing = nmonths > 0; -
362 -
363 while (nmonths != 0) {
evaluated: nmonths != 0
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:120
120-134
364 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
365 y--; -
366 nmonths+=12; -
367 } else if (nmonths < 0) {
evaluated: nmonths < 0
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:61
executed: }
Execution Count:11
11-62
368 m+= nmonths; -
369 nmonths = 0; -
370 if (m <= 0) {
evaluated: m <= 0
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:27
27-35
371 --y; -
372 m += 12; -
373 }
executed: }
Execution Count:35
35
374 } else if (nmonths - 12 >= 0) {
evaluated: nmonths - 12 >= 0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:49
executed: }
Execution Count:62
12-62
375 y++; -
376 nmonths -= 12; -
377 } else if (m == 12) {
evaluated: m == 12
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:47
executed: }
Execution Count:12
2-47
378 y++; -
379 m = 0; -
380 } else {
executed: }
Execution Count:2
2
381 m += nmonths; -
382 nmonths = 0; -
383 if (m > 12) {
evaluated: m > 12
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:46
1-46
384 ++y; -
385 m -= 12; -
386 }
executed: }
Execution Count:1
1
387 }
executed: }
Execution Count:47
47
388 } -
389 -
390 -
391 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
392 (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
393 -
394 y += increasing ? +1 : -1;
evaluated: increasing
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
executed: y += increasing ? +1 : -1;
Execution Count:4
2-4
395 -
396 return fixedDate(y, m, d);
executed: return fixedDate(y, m, d);
Execution Count:120
120
397} -
398QDate QDate::addYears(int nyears) const -
399{ -
400 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:82
1-82
401 return QDate();
executed: return QDate();
Execution Count:1
1
402 -
403 int y, m, d; -
404 getDateFromJulianDay(jd, &y, &m, &d); -
405 -
406 int old_y = y; -
407 y += nyears; -
408 -
409 -
410 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
411 (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
412 -
413 y += nyears > 0 ? +1 : -1;
evaluated: nyears > 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
executed: y += nyears > 0 ? +1 : -1;
Execution Count:12
6-12
414 -
415 return fixedDate(y, m, d);
executed: return fixedDate(y, m, d);
Execution Count:82
82
416} -
417qint64 QDate::daysTo(const QDate &d) const -
418{ -
419 if (isNull() || d.isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:30395
evaluated: d.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:30394
1-30395
420 return 0;
executed: return 0;
Execution Count:2
2
421 -
422 -
423 return d.jd - jd;
executed: return d.jd - jd;
Execution Count:30394
30394
424} -
425QDate QDate::fromString(const QString& s, Qt::DateFormat f) -
426{ -
427 if (s.isEmpty())
evaluated: s.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:76
1-76
428 return QDate();
executed: return QDate();
Execution Count:1
1
429 -
430 switch (f) { -
431 case Qt::ISODate: -
432 { -
433 int year(s.mid(0, 4).toInt()); -
434 int month(s.mid(5, 2).toInt()); -
435 int day(s.mid(8, 2).toInt()); -
436 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
437 return QDate(year, month, day);
executed: return QDate(year, month, day);
Execution Count:50
50
438 } -
439 break;
executed: break;
Execution Count:12
12
440 case Qt::SystemLocaleDate: -
441 case Qt::SystemLocaleShortDate: -
442 case Qt::SystemLocaleLongDate: -
443 return fromString(s, QLocale::system().dateFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat 0
444 : QLocale::ShortFormat));
never executed: return fromString(s, QLocale::system().dateFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
0
445 case Qt::LocaleDate: -
446 case Qt::DefaultLocaleShortDate: -
447 case Qt::DefaultLocaleLongDate: -
448 return fromString(s, QLocale().dateFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat 0
449 : QLocale::ShortFormat));
never executed: return fromString(s, QLocale().dateFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
0
450 default: -
451 -
452 case Qt::TextDate: { -
453 QStringList parts = s.split(QLatin1Char(' '), QString::SkipEmptyParts); -
454 -
455 if (parts.count() != 4) {
evaluated: parts.count() != 4
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
456 return QDate();
executed: return QDate();
Execution Count:1
1
457 } -
458 -
459 QString monthName = parts.at(1); -
460 int month = -1; -
461 -
462 for (int i = 0; i < 12; ++i) {
evaluated: i < 12
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:1
1-72
463 if (monthName == QLatin1String(qt_shortMonthNames[i])) {
evaluated: monthName == QLatin1String(qt_shortMonthNames[i])
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:60
12-60
464 month = i + 1; -
465 break;
executed: break;
Execution Count:12
12
466 } -
467 }
executed: }
Execution Count:60
60
468 -
469 if (month == -1) {
evaluated: month == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12
1-12
470 for (int i = 1; i <= 12; ++i) {
evaluated: i <= 12
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
471 if (monthName == QDate::shortMonthName(i)) {
partially evaluated: monthName == QDate::shortMonthName(i)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
472 month = i; -
473 break;
never executed: break;
0
474 } -
475 }
executed: }
Execution Count:12
12
476 if (month == -1) {
partially evaluated: month == -1
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
477 -
478 return QDate();
executed: return QDate();
Execution Count:1
1
479 } -
480 }
never executed: }
0
481 -
482 bool ok; -
483 int day = parts.at(2).toInt(&ok); -
484 if (!ok) {
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:11
1-11
485 return QDate();
executed: return QDate();
Execution Count:1
1
486 } -
487 -
488 int year = parts.at(3).toInt(&ok); -
489 if (!ok) {
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-10
490 return QDate();
executed: return QDate();
Execution Count:1
1
491 } -
492 -
493 return QDate(year, month, day);
executed: return QDate(year, month, day);
Execution Count:10
10
494 } -
495 -
496 -
497 -
498 } -
499 return QDate();
executed: return QDate();
Execution Count:12
12
500} -
501QDate QDate::fromString(const QString &string, const QString &format) -
502{ -
503 QDate date; -
504 -
505 QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString); -
506 if (dt.parseFormat(format))
partially evaluated: dt.parseFormat(format)
TRUEFALSE
yes
Evaluation Count:44
no
Evaluation Count:0
0-44
507 dt.fromString(string, &date, 0);
executed: dt.fromString(string, &date, 0);
Execution Count:44
44
508 -
509 -
510 -
511 -
512 return date;
executed: return date;
Execution Count:44
44
513} -
514bool QDate::isValid(int year, int month, int day) -
515{ -
516 -
517 if (year == 0)
evaluated: year == 0
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:703683
139-703683
518 return false;
executed: return false;
Execution Count:139
139
519 -
520 return (day > 0 && month > 0 && month <= 12) && 703683
521 (day <= monthDays[month] || (day == 29 && month == 2 && isLeapYear(year)));
executed: return (day > 0 && month > 0 && month <= 12) && (day <= monthDays[month] || (day == 29 && month == 2 && isLeapYear(year)));
Execution Count:703683
703683
522} -
523bool QDate::isLeapYear(int y) -
524{ -
525 -
526 if ( y < 1)
evaluated: y < 1
TRUEFALSE
yes
Evaluation Count:9596
yes
Evaluation Count:27053
9596-27053
527 ++y;
executed: ++y;
Execution Count:9596
9596
528 -
529 return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
executed: return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
Execution Count:36649
36649
530} -
531QTime::QTime(int h, int m, int s, int ms) -
532{ -
533 setHMS(h, m, s, ms); -
534}
executed: }
Execution Count:58571
58571
535bool QTime::isValid() const -
536{ -
537 return mds > NullTime && mds < MSECS_PER_DAY;
executed: return mds > NullTime && mds < MSECS_PER_DAY;
Execution Count:28356753
28356753
538} -
539int QTime::hour() const -
540{ -
541 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:44354
2-44354
542 return -1;
executed: return -1;
Execution Count:2
2
543 -
544 return ds() / MSECS_PER_HOUR;
executed: return ds() / MSECS_PER_HOUR;
Execution Count:44354
44354
545} -
546int QTime::minute() const -
547{ -
548 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:40316
2-40316
549 return -1;
executed: return -1;
Execution Count:2
2
550 -
551 return (ds() % MSECS_PER_HOUR) / MSECS_PER_MIN;
executed: return (ds() % MSECS_PER_HOUR) / MSECS_PER_MIN;
Execution Count:40316
40316
552} -
553int QTime::second() const -
554{ -
555 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:38565
2-38565
556 return -1;
executed: return -1;
Execution Count:2
2
557 -
558 return (ds() / 1000)%SECS_PER_MIN;
executed: return (ds() / 1000)%SECS_PER_MIN;
Execution Count:38565
38565
559} -
560int QTime::msec() const -
561{ -
562 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:42215
1-42215
563 return -1;
executed: return -1;
Execution Count:1
1
564 -
565 return ds() % 1000;
executed: return ds() % 1000;
Execution Count:42215
42215
566} -
567QString QTime::toString(Qt::DateFormat format) const -
568{ -
569 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1749
1-1749
570 return QString();
executed: return QString();
Execution Count:1
1
571 -
572 switch (format) { -
573 case Qt::SystemLocaleDate: -
574 case Qt::SystemLocaleShortDate: -
575 case Qt::SystemLocaleLongDate: -
576 return QLocale::system().toString(*this, format == Qt::SystemLocaleLongDate ? QLocale::LongFormat 1647
577 : QLocale::ShortFormat);
executed: return QLocale::system().toString(*this, format == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:1647
1647
578 case Qt::LocaleDate: -
579 case Qt::DefaultLocaleShortDate: -
580 case Qt::DefaultLocaleLongDate: -
581 return QLocale().toString(*this, format == Qt::DefaultLocaleLongDate ? QLocale::LongFormat 5
582 : QLocale::ShortFormat);
executed: return QLocale().toString(*this, format == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat);
Execution Count:5
5
583 -
584 default: -
585 case Qt::ISODate: -
586 case Qt::TextDate: -
587 return QString::fromLatin1("%1:%2:%3") 97
588 .arg(hour(), 2, 10, QLatin1Char('0')) 97
589 .arg(minute(), 2, 10, QLatin1Char('0')) 97
590 .arg(second(), 2, 10, QLatin1Char('0'));
executed: return QString::fromLatin1("%1:%2:%3") .arg(hour(), 2, 10, QLatin1Char('0')) .arg(minute(), 2, 10, QLatin1Char('0')) .arg(second(), 2, 10, QLatin1Char('0'));
Execution Count:97
97
591 } -
592}
never executed: }
0
593QString QTime::toString(const QString& format) const -
594{ -
595 return fmtDateTime(format, this, 0);
executed: return fmtDateTime(format, this, 0);
Execution Count:13408
13408
596} -
597bool QTime::setHMS(int h, int m, int s, int ms) -
598{ -
599 -
600 -
601 -
602 if (!isValid(h,m,s,ms)) {
evaluated: !isValid(h,m,s,ms)
TRUEFALSE
yes
Evaluation Count:90
yes
Evaluation Count:58491
90-58491
603 mds = NullTime; -
604 return false;
executed: return false;
Execution Count:90
90
605 } -
606 mds = (h*SECS_PER_HOUR + m*SECS_PER_MIN + s)*1000 + ms; -
607 return true;
executed: return true;
Execution Count:58491
58491
608} -
609QTime QTime::addSecs(int s) const -
610{ -
611 return addMSecs(s * 1000);
executed: return addMSecs(s * 1000);
Execution Count:5013
5013
612} -
613int QTime::secsTo(const QTime &t) const -
614{ -
615 if (!isValid() || !t.isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5852
evaluated: !t.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5851
1-5852
616 return 0;
executed: return 0;
Execution Count:3
3
617 -
618 -
619 int ourSeconds = ds() / 1000; -
620 int theirSeconds = t.ds() / 1000; -
621 return theirSeconds - ourSeconds;
executed: return theirSeconds - ourSeconds;
Execution Count:5851
5851
622} -
623QTime QTime::addMSecs(int ms) const -
624{ -
625 QTime t; -
626 if (isValid()) {
evaluated: isValid()
TRUEFALSE
yes
Evaluation Count:7413
yes
Evaluation Count:1
1-7413
627 if (ms < 0) {
evaluated: ms < 0
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:7375
38-7375
628 -
629 int negdays = (MSECS_PER_DAY - ms) / MSECS_PER_DAY; -
630 t.mds = (ds() + ms + negdays * MSECS_PER_DAY) % MSECS_PER_DAY; -
631 } else {
executed: }
Execution Count:38
38
632 t.mds = (ds() + ms) % MSECS_PER_DAY; -
633 }
executed: }
Execution Count:7375
7375
634 } -
635 -
636 -
637 -
638 -
639 return t;
executed: return t;
Execution Count:7414
7414
640} -
641int QTime::msecsTo(const QTime &t) const -
642{ -
643 if (!isValid() || !t.isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:14035969
evaluated: !t.isValid()
TRUEFALSE
yes
Evaluation Count:1666
yes
Evaluation Count:14034155
5-14035969
644 return 0;
executed: return 0;
Execution Count:1671
1671
645 -
646 -
647 -
648 -
649 -
650 -
651 return t.ds() - ds();
executed: return t.ds() - ds();
Execution Count:14034143
14034143
652} -
653namespace { -
654inline bool isMidnight(int hour, int minute, int second, int msec) -
655{ -
656 return hour == 24 && minute == 0 && second == 0 && msec == 0;
executed: return hour == 24 && minute == 0 && second == 0 && msec == 0;
Execution Count:51
51
657} -
658 -
659QTime fromStringImpl(const QString &s, Qt::DateFormat f, bool &isMidnight24) -
660{ -
661 if (s.isEmpty()) {
evaluated: s.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:76
5-76
662 -
663 return QTime();
executed: return QTime();
Execution Count:5
5
664 } -
665 -
666 switch (f) { -
667 case Qt::SystemLocaleDate: -
668 case Qt::SystemLocaleShortDate: -
669 case Qt::SystemLocaleLongDate: -
670 { -
671 QLocale::FormatType formatType(Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat); -
672 return QTime::fromString(s, QLocale::system().timeFormat(formatType));
never executed: return QTime::fromString(s, QLocale::system().timeFormat(formatType));
0
673 } -
674 case Qt::LocaleDate: -
675 case Qt::DefaultLocaleShortDate: -
676 case Qt::DefaultLocaleLongDate: -
677 { -
678 QLocale::FormatType formatType(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat); -
679 return QTime::fromString(s, QLocale().timeFormat(formatType));
never executed: return QTime::fromString(s, QLocale().timeFormat(formatType));
0
680 } -
681 case Qt::TextDate: -
682 case Qt::ISODate: -
683 { -
684 bool ok = true; -
685 const int hour(s.mid(0, 2).toInt(&ok)); -
686 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:68
8-68
687 return QTime();
executed: return QTime();
Execution Count:8
8
688 const int minute(s.mid(3, 2).toInt(&ok)); -
689 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:66
2-66
690 return QTime();
executed: return QTime();
Execution Count:2
2
691 if (f == Qt::ISODate) {
evaluated: f == Qt::ISODate
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:6
6-60
692 if (s.size() == 5) {
evaluated: s.size() == 5
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:55
5-55
693 -
694 return QTime(hour, minute, 0, 0);
executed: return QTime(hour, minute, 0, 0);
Execution Count:5
5
695 } 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
696 const QString minuteFractionStr(QLatin1String("0.") + s.mid(6, 5)); -
697 const float minuteFraction = minuteFractionStr.toFloat(&ok); -
698 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
699 return QTime();
executed: return QTime();
Execution Count:1
1
700 const float secondWithMs = minuteFraction * 60; -
701 const float second = std::floor(secondWithMs); -
702 const float millisecond = 1000 * (secondWithMs - second); -
703 const int millisecondRounded = qMin(qRound(millisecond), 999); -
704 -
705 if (isMidnight(hour, minute, second, millisecondRounded)) {
evaluated: isMidnight(hour, minute, second, millisecondRounded)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
706 isMidnight24 = true; -
707 return QTime(0, 0, 0, 0);
executed: return QTime(0, 0, 0, 0);
Execution Count:1
1
708 } -
709 -
710 return QTime(hour, minute, second, millisecondRounded);
executed: return QTime(hour, minute, second, millisecondRounded);
Execution Count:6
6
711 } -
712 } -
713 -
714 const int second(s.mid(6, 2).toInt(&ok)); -
715 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:50
3-50
716 return QTime();
executed: return QTime();
Execution Count:3
3
717 const QString msec_s(QLatin1String("0.") + s.mid(9, 4)); -
718 const double msec(msec_s.toDouble(&ok)); -
719 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:48
2-48
720 return QTime(hour, minute, second, 0);
executed: return QTime(hour, minute, second, 0);
Execution Count:2
2
721 -
722 if (f == Qt::ISODate) {
evaluated: f == Qt::ISODate
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:4
4-44
723 if (isMidnight(hour, minute, second, msec)) {
evaluated: isMidnight(hour, minute, second, msec)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:39
5-39
724 isMidnight24 = true; -
725 return QTime(0, 0, 0, 0);
executed: return QTime(0, 0, 0, 0);
Execution Count:5
5
726 } -
727 }
executed: }
Execution Count:39
39
728 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
729 } -
730 } -
731 do { qt_noop(); qt_noop(); } while (0);
never evaluated: 0
never executed: }
0
732 return QTime();
never executed: return QTime();
0
733} -
734} -
735QTime QTime::fromString(const QString& s, Qt::DateFormat f) -
736{ -
737 bool unused; -
738 return fromStringImpl(s, f, unused);
executed: return fromStringImpl(s, f, unused);
Execution Count:29
29
739} -
740QTime QTime::fromString(const QString &string, const QString &format) -
741{ -
742 QTime time; -
743 -
744 QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString); -
745 if (dt.parseFormat(format))
partially evaluated: dt.parseFormat(format)
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
746 dt.fromString(string, 0, &time);
executed: dt.fromString(string, 0, &time);
Execution Count:12
12
747 -
748 -
749 -
750 -
751 return time;
executed: return time;
Execution Count:12
12
752} -
753bool QTime::isValid(int h, int m, int s, int ms) -
754{ -
755 return (uint)h < 24 && (uint)m < 60 && (uint)s < 60 && (uint)ms < 1000;
executed: return (uint)h < 24 && (uint)m < 60 && (uint)s < 60 && (uint)ms < 1000;
Execution Count:61199
61199
756} -
757void QTime::start() -
758{ -
759 *this = currentTime(); -
760}
executed: }
Execution Count:1136
1136
761int QTime::restart() -
762{ -
763 QTime t = currentTime(); -
764 int n = msecsTo(t); -
765 if (n < 0)
partially evaluated: n < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:202
0-202
766 n += 86400*1000;
never executed: n += 86400*1000;
0
767 *this = t; -
768 return n;
executed: return n;
Execution Count:202
202
769} -
770int QTime::elapsed() const -
771{ -
772 int n = msecsTo(currentTime()); -
773 if (n < 0)
partially evaluated: n < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14025440
0-14025440
774 n += 86400 * 1000;
never executed: n += 86400 * 1000;
0
775 return n;
executed: return n;
Execution Count:14025437
14025437
776} -
777QDateTime::QDateTime() -
778 : d(new QDateTimePrivate) -
779{ -
780}
executed: }
Execution Count:543637
543637
781 -
782 -
783 -
784 -
785 -
786 -
787 -
788QDateTime::QDateTime(const QDate &date) -
789 : d(new QDateTimePrivate) -
790{ -
791 d->date = date; -
792 d->time = QTime(0, 0, 0); -
793}
executed: }
Execution Count:6
6
794QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec) -
795 : d(new QDateTimePrivate) -
796{ -
797 d->date = date; -
798 d->time = date.isValid() && !time.isValid() ? QTime(0, 0, 0) : time;
evaluated: date.isValid()
TRUEFALSE
yes
Evaluation Count:21184
yes
Evaluation Count:105
evaluated: !time.isValid()
TRUEFALSE
yes
Evaluation Count:863
yes
Evaluation Count:20321
105-21184
799 d->spec = (spec == Qt::UTC) ? QDateTimePrivate::UTC : QDateTimePrivate::LocalUnknown;
evaluated: (spec == Qt::UTC)
TRUEFALSE
yes
Evaluation Count:3974
yes
Evaluation Count:17315
3974-17315
800}
executed: }
Execution Count:21289
21289
801 -
802 -
803 -
804 -
805 -
806QDateTime::QDateTime(const QDateTime &other) -
807 : d(other.d) -
808{ -
809}
executed: }
Execution Count:183717
183717
810 -
811 -
812 -
813 -
814QDateTime::~QDateTime() -
815{ -
816} -
817 -
818 -
819 -
820 -
821 -
822 -
823QDateTime &QDateTime::operator=(const QDateTime &other) -
824{ -
825 d = other.d; -
826 return *this;
executed: return *this;
Execution Count:24547
24547
827} -
828bool QDateTime::isNull() const -
829{ -
830 return d->date.isNull() && d->time.isNull();
executed: return d->date.isNull() && d->time.isNull();
Execution Count:3970
3970
831} -
832bool QDateTime::isValid() const -
833{ -
834 return d->date.isValid() && d->time.isValid();
executed: return d->date.isValid() && d->time.isValid();
Execution Count:31518
31518
835} -
836 -
837 -
838 -
839 -
840 -
841 -
842 -
843QDate QDateTime::date() const -
844{ -
845 return d->date;
executed: return d->date;
Execution Count:54759
54759
846} -
847 -
848 -
849 -
850 -
851 -
852 -
853 -
854QTime QDateTime::time() const -
855{ -
856 return d->time;
executed: return d->time;
Execution Count:45807
45807
857} -
858 -
859 -
860 -
861 -
862 -
863 -
864 -
865Qt::TimeSpec QDateTime::timeSpec() const -
866{ -
867 switch(d->spec) -
868 { -
869 case QDateTimePrivate::UTC: -
870 return Qt::UTC;
executed: return Qt::UTC;
Execution Count:2098
2098
871 case QDateTimePrivate::OffsetFromUTC: -
872 return Qt::OffsetFromUTC;
executed: return Qt::OffsetFromUTC;
Execution Count:7
7
873 default: -
874 return Qt::LocalTime;
executed: return Qt::LocalTime;
Execution Count:8092
8092
875 } -
876}
never executed: }
0
877void QDateTime::setDate(const QDate &date) -
878{ -
879 detach(); -
880 d->date = date; -
881 if (d->spec == QDateTimePrivate::LocalStandard
evaluated: d->spec == QDateTimePrivate::LocalStandard
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12
1-12
882 || d->spec == QDateTimePrivate::LocalDST)
partially evaluated: d->spec == QDateTimePrivate::LocalDST
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
883 d->spec = QDateTimePrivate::LocalUnknown;
executed: d->spec = QDateTimePrivate::LocalUnknown;
Execution Count:1
1
884 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
885 d->time = QTime(0, 0, 0);
executed: d->time = QTime(0, 0, 0);
Execution Count:2
2
886}
executed: }
Execution Count:13
13
887 -
888 -
889 -
890 -
891 -
892 -
893 -
894void QDateTime::setTime(const QTime &time) -
895{ -
896 detach(); -
897 if (d->spec == QDateTimePrivate::LocalStandard
partially evaluated: d->spec == QDateTimePrivate::LocalStandard
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:134
0-134
898 || d->spec == QDateTimePrivate::LocalDST)
evaluated: d->spec == QDateTimePrivate::LocalDST
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:133
1-133
899 d->spec = QDateTimePrivate::LocalUnknown;
executed: d->spec = QDateTimePrivate::LocalUnknown;
Execution Count:1
1
900 d->time = time; -
901}
executed: }
Execution Count:134
134
902void QDateTime::setTimeSpec(Qt::TimeSpec spec) -
903{ -
904 detach(); -
905 -
906 switch(spec) -
907 { -
908 case Qt::UTC: -
909 d->spec = QDateTimePrivate::UTC; -
910 break;
executed: break;
Execution Count:1627
1627
911 case Qt::OffsetFromUTC: -
912 d->spec = QDateTimePrivate::OffsetFromUTC; -
913 break;
executed: break;
Execution Count:1
1
914 default: -
915 d->spec = QDateTimePrivate::LocalUnknown; -
916 break;
executed: break;
Execution Count:10
10
917 } -
918}
executed: }
Execution Count:1638
1638
919 -
920qint64 toMSecsSinceEpoch_helper(qint64 jd, int msecs) -
921{ -
922 qint64 days = jd - JULIAN_DAY_FOR_EPOCH; -
923 qint64 retval = (days * MSECS_PER_DAY) + msecs; -
924 return retval;
executed: return retval;
Execution Count:7830
7830
925} -
926qint64 QDateTime::toMSecsSinceEpoch() const -
927{ -
928 QDate utcDate; -
929 QTime utcTime; -
930 d->getUTC(utcDate, utcTime); -
931 -
932 return toMSecsSinceEpoch_helper(utcDate.toJulianDay(), QTime(0, 0, 0).msecsTo(utcTime));
executed: return toMSecsSinceEpoch_helper(utcDate.toJulianDay(), QTime(0, 0, 0).msecsTo(utcTime));
Execution Count:1792
1792
933} -
934uint QDateTime::toTime_t() const -
935{ -
936 qint64 retval = toMSecsSinceEpoch() / 1000; -
937 if (quint64(retval) >= static_cast<unsigned long long>(0xFFFFFFFFULL))
evaluated: quint64(retval) >= static_cast<unsigned long long>(0xFFFFFFFFULL)
TRUEFALSE
yes
Evaluation Count:1666
yes
Evaluation Count:92
92-1666
938 return uint(-1);
executed: return uint(-1);
Execution Count:1666
1666
939 return uint(retval);
executed: return uint(retval);
Execution Count:92
92
940} -
941void QDateTime::setMSecsSinceEpoch(qint64 msecs) -
942{ -
943 detach(); -
944 -
945 QDateTimePrivate::Spec oldSpec = d->spec; -
946 -
947 qint64 ddays = msecs / MSECS_PER_DAY; -
948 msecs %= MSECS_PER_DAY; -
949 if (msecs < 0) {
evaluated: msecs < 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:18
6-18
950 -
951 --ddays; -
952 msecs += MSECS_PER_DAY; -
953 }
executed: }
Execution Count:6
6
954 -
955 d->date = QDate(1970, 1, 1).addDays(ddays); -
956 d->time = QTime(0, 0, 0).addMSecs(msecs); -
957 d->spec = QDateTimePrivate::UTC; -
958 -
959 if (oldSpec != QDateTimePrivate::UTC)
evaluated: oldSpec != QDateTimePrivate::UTC
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:8
8-16
960 d->spec = d->getLocal(d->date, d->time);
executed: d->spec = d->getLocal(d->date, d->time);
Execution Count:16
16
961}
executed: }
Execution Count:24
24
962void QDateTime::setTime_t(uint secsSince1Jan1970UTC) -
963{ -
964 detach(); -
965 -
966 QDateTimePrivate::Spec oldSpec = d->spec; -
967 -
968 d->date = QDate(1970, 1, 1).addDays(secsSince1Jan1970UTC / SECS_PER_DAY); -
969 d->time = QTime(0, 0, 0).addSecs(secsSince1Jan1970UTC % SECS_PER_DAY); -
970 d->spec = QDateTimePrivate::UTC; -
971 -
972 if (oldSpec != QDateTimePrivate::UTC)
evaluated: oldSpec != QDateTimePrivate::UTC
TRUEFALSE
yes
Evaluation Count:5004
yes
Evaluation Count:5
5-5004
973 d->spec = d->getLocal(d->date, d->time);
executed: d->spec = d->getLocal(d->date, d->time);
Execution Count:5004
5004
974}
executed: }
Execution Count:5009
5009
975QString QDateTime::toString(Qt::DateFormat f) const -
976{ -
977 QString buf; -
978 if (!isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1731
1-1731
979 return buf;
executed: return buf;
Execution Count:1
1
980 -
981 if (f == Qt::ISODate) {
evaluated: f == Qt::ISODate
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:1705
26-1705
982 buf = d->date.toString(Qt::ISODate); -
983 if (buf.isEmpty())
evaluated: buf.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:25
1-25
984 return QString();
executed: return QString();
Execution Count:1
1
985 buf += QLatin1Char('T'); -
986 buf += d->time.toString(Qt::ISODate); -
987 switch (d->spec) { -
988 case QDateTimePrivate::UTC: -
989 buf += QLatin1Char('Z'); -
990 break;
executed: break;
Execution Count:9
9
991 case QDateTimePrivate::OffsetFromUTC: { -
992 int sign = d->utcOffset >= 0 ? 1: -1;
evaluated: d->utcOffset >= 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
993 buf += QString::fromLatin1("%1%2:%3"). -
994 arg(sign == 1 ? QLatin1Char('+') : QLatin1Char('-')). -
995 arg(d->utcOffset * sign / SECS_PER_HOUR, 2, 10, QLatin1Char('0')). -
996 arg((d->utcOffset / 60) % 60, 2, 10, QLatin1Char('0')); -
997 break;
executed: break;
Execution Count:2
2
998 } -
999 default: -
1000 break;
executed: break;
Execution Count:14
14
1001 } -
1002 }
executed: }
Execution Count:25
25
1003 -
1004 else if (f == Qt::TextDate) {
evaluated: f == Qt::TextDate
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:1648
57-1648
1005 -
1006 buf = d->date.shortDayName(d->date.dayOfWeek()); -
1007 buf += QLatin1Char(' '); -
1008 buf += d->date.shortMonthName(d->date.month()); -
1009 buf += QLatin1Char(' '); -
1010 buf += QString::number(d->date.day()); -
1011 buf += QLatin1Char(' '); -
1012 buf += d->time.toString(); -
1013 buf += QLatin1Char(' '); -
1014 buf += QString::number(d->date.year()); -
1015 }
executed: }
Execution Count:57
57
1016 -
1017 else { -
1018 buf = d->date.toString(f); -
1019 if (buf.isEmpty())
partially evaluated: buf.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1648
0-1648
1020 return QString();
never executed: return QString();
0
1021 buf += QLatin1Char(' '); -
1022 buf += d->time.toString(f); -
1023 }
executed: }
Execution Count:1648
1648
1024 -
1025 return buf;
executed: return buf;
Execution Count:1730
1730
1026} -
1027QString QDateTime::toString(const QString& format) const -
1028{ -
1029 return fmtDateTime(format, &d->time, &d->date);
executed: return fmtDateTime(format, &d->time, &d->date);
Execution Count:1353
1353
1030} -
1031QDateTime QDateTime::addDays(qint64 ndays) const -
1032{ -
1033 return QDateTime(d->date.addDays(ndays), d->time, timeSpec());
executed: return QDateTime(d->date.addDays(ndays), d->time, timeSpec());
Execution Count:6263
6263
1034} -
1035QDateTime QDateTime::addMonths(int nmonths) const -
1036{ -
1037 return QDateTime(d->date.addMonths(nmonths), d->time, timeSpec());
executed: return QDateTime(d->date.addMonths(nmonths), d->time, timeSpec());
Execution Count:70
70
1038} -
1039QDateTime QDateTime::addYears(int nyears) const -
1040{ -
1041 return QDateTime(d->date.addYears(nyears), d->time, timeSpec());
executed: return QDateTime(d->date.addYears(nyears), d->time, timeSpec());
Execution Count:57
57
1042} -
1043 -
1044QDateTime QDateTimePrivate::addMSecs(const QDateTime &dt, qint64 msecs) -
1045{ -
1046 if (!dt.isValid())
evaluated: !dt.isValid()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2148
5-2148
1047 return QDateTime();
executed: return QDateTime();
Execution Count:5
5
1048 -
1049 QDate utcDate; -
1050 QTime utcTime; -
1051 dt.d->getUTC(utcDate, utcTime); -
1052 -
1053 addMSecs(utcDate, utcTime, msecs); -
1054 -
1055 return QDateTime(utcDate, utcTime, Qt::UTC).toTimeSpec(dt.timeSpec());
executed: return QDateTime(utcDate, utcTime, Qt::UTC).toTimeSpec(dt.timeSpec());
Execution Count:2148
2148
1056} -
1057void QDateTimePrivate::addMSecs(QDate &utcDate, QTime &utcTime, qint64 msecs) -
1058{ -
1059 qint64 dd = utcDate.toJulianDay(); -
1060 int tt = QTime(0, 0, 0).msecsTo(utcTime); -
1061 int sign = 1; -
1062 if (msecs < 0) {
evaluated: msecs < 0
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:2095
84-2095
1063 msecs = -msecs; -
1064 sign = -1; -
1065 }
executed: }
Execution Count:84
84
1066 if (msecs >= int(MSECS_PER_DAY)) {
evaluated: msecs >= int(MSECS_PER_DAY)
TRUEFALSE
yes
Evaluation Count:89
yes
Evaluation Count:2090
89-2090
1067 dd += sign * (msecs / MSECS_PER_DAY); -
1068 msecs %= MSECS_PER_DAY; -
1069 }
executed: }
Execution Count:89
89
1070 -
1071 tt += sign * msecs; -
1072 if (tt < 0) {
evaluated: tt < 0
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:2164
15-2164
1073 tt = MSECS_PER_DAY - tt - 1; -
1074 dd -= tt / MSECS_PER_DAY; -
1075 tt = tt % MSECS_PER_DAY; -
1076 tt = MSECS_PER_DAY - tt - 1; -
1077 } else if (tt >= int(MSECS_PER_DAY)) {
executed: }
Execution Count:15
evaluated: tt >= int(MSECS_PER_DAY)
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:2147
15-2147
1078 dd += tt / MSECS_PER_DAY; -
1079 tt = tt % MSECS_PER_DAY; -
1080 }
executed: }
Execution Count:17
17
1081 -
1082 utcDate = QDate::fromJulianDay(dd); -
1083 utcTime = QTime(0, 0, 0).addMSecs(tt); -
1084}
executed: }
Execution Count:2179
2179
1085QDateTime QDateTime::addSecs(qint64 s) const -
1086{ -
1087 return d->addMSecs(*this, s * 1000);
executed: return d->addMSecs(*this, s * 1000);
Execution Count:2089
2089
1088} -
1089QDateTime QDateTime::addMSecs(qint64 msecs) const -
1090{ -
1091 return d->addMSecs(*this, msecs);
executed: return d->addMSecs(*this, msecs);
Execution Count:64
64
1092} -
1093qint64 QDateTime::daysTo(const QDateTime &other) const -
1094{ -
1095 return d->date.daysTo(other.d->date);
executed: return d->date.daysTo(other.d->date);
Execution Count:114
114
1096} -
1097qint64 QDateTime::secsTo(const QDateTime &other) const -
1098{ -
1099 if (!isValid() || !other.isValid())
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5847
evaluated: !other.isValid()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5843
2-5847
1100 return 0;
executed: return 0;
Execution Count:6
6
1101 -
1102 QDate date1, date2; -
1103 QTime time1, time2; -
1104 -
1105 d->getUTC(date1, time1); -
1106 other.d->getUTC(date2, time2); -
1107 -
1108 return (date1.daysTo(date2) * SECS_PER_DAY) + time1.secsTo(time2);
executed: return (date1.daysTo(date2) * SECS_PER_DAY) + time1.secsTo(time2);
Execution Count:5843
5843
1109} -
1110qint64 QDateTime::msecsTo(const QDateTime &other) const -
1111{ -
1112 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
1113 return 0;
executed: return 0;
Execution Count:2
2
1114 -
1115 QDate selfDate; -
1116 QDate otherDate; -
1117 QTime selfTime; -
1118 QTime otherTime; -
1119 -
1120 d->getUTC(selfDate, selfTime); -
1121 other.d->getUTC(otherDate, otherTime); -
1122 -
1123 return (static_cast<qint64>(selfDate.daysTo(otherDate)) * static_cast<qint64>(MSECS_PER_DAY)) 45
1124 + 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
1125} -
1126QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const -
1127{ -
1128 if ((d->spec == QDateTimePrivate::UTC) == (spec == Qt::UTC))
evaluated: (d->spec == QDateTimePrivate::UTC) == (spec == Qt::UTC)
TRUEFALSE
yes
Evaluation Count:14783
yes
Evaluation Count:2716
2716-14783
1129 return *this;
executed: return *this;
Execution Count:14783
14783
1130 -
1131 QDateTime ret; -
1132 if (spec == Qt::UTC) {
evaluated: spec == Qt::UTC
TRUEFALSE
yes
Evaluation Count:1698
yes
Evaluation Count:1018
1018-1698
1133 d->getUTC(ret.d->date, ret.d->time); -
1134 ret.d->spec = QDateTimePrivate::UTC; -
1135 } else {
executed: }
Execution Count:1698
1698
1136 ret.d->spec = d->getLocal(ret.d->date, ret.d->time); -
1137 }
executed: }
Execution Count:1018
1018
1138 return ret;
executed: return ret;
Execution Count:2716
2716
1139} -
1140bool QDateTime::operator==(const QDateTime &other) const -
1141{ -
1142 if (d->spec == other.d->spec && d->utcOffset == other.d->utcOffset)
evaluated: d->spec == other.d->spec
TRUEFALSE
yes
Evaluation Count:46938
yes
Evaluation Count:322
evaluated: d->utcOffset == other.d->utcOffset
TRUEFALSE
yes
Evaluation Count:46934
yes
Evaluation Count:4
4-46938
1143 return d->time == other.d->time && d->date == other.d->date;
executed: return d->time == other.d->time && d->date == other.d->date;
Execution Count:46934
46934
1144 else { -
1145 QDate date1, date2; -
1146 QTime time1, time2; -
1147 -
1148 d->getUTC(date1, time1); -
1149 other.d->getUTC(date2, time2); -
1150 return time1 == time2 && date1 == date2;
executed: return time1 == time2 && date1 == date2;
Execution Count:326
326
1151 } -
1152} -
1153bool QDateTime::operator<(const QDateTime &other) const -
1154{ -
1155 if (d->spec == other.d->spec && d->spec != QDateTimePrivate::OffsetFromUTC) {
evaluated: d->spec == other.d->spec
TRUEFALSE
yes
Evaluation Count:29479
yes
Evaluation Count:2088
evaluated: d->spec != QDateTimePrivate::OffsetFromUTC
TRUEFALSE
yes
Evaluation Count:29477
yes
Evaluation Count:2
2-29479
1156 if (d->date != other.d->date)
evaluated: d->date != other.d->date
TRUEFALSE
yes
Evaluation Count:14029
yes
Evaluation Count:15448
14029-15448
1157 return d->date < other.d->date;
executed: return d->date < other.d->date;
Execution Count:14029
14029
1158 return d->time < other.d->time;
executed: return d->time < other.d->time;
Execution Count:15448
15448
1159 } else { -
1160 QDate date1, date2; -
1161 QTime time1, time2; -
1162 d->getUTC(date1, time1); -
1163 other.d->getUTC(date2, time2); -
1164 if (date1 != date2)
evaluated: date1 != date2
TRUEFALSE
yes
Evaluation Count:2065
yes
Evaluation Count:25
25-2065
1165 return date1 < date2;
executed: return date1 < date2;
Execution Count:2065
2065
1166 return time1 < time2;
executed: return time1 < time2;
Execution Count:25
25
1167 } -
1168} -
1169static inline uint msecsFromDecomposed(int hour, int minute, int sec, int msec = 0) -
1170{ -
1171 return MSECS_PER_HOUR * hour + MSECS_PER_MIN * minute + 1000 * sec + msec;
executed: return MSECS_PER_HOUR * hour + MSECS_PER_MIN * minute + 1000 * sec + msec;
Execution Count:14036866
14036866
1172} -
1173QDate QDate::currentDate() -
1174{ -
1175 QDate d; -
1176 -
1177 time_t ltime; -
1178 time(&ltime); -
1179 struct tm *t = 0; -
1180 -
1181 -
1182 -
1183 tzset(); -
1184 struct tm res; -
1185 t = localtime_r(&ltime, &res); -
1186 -
1187 -
1188 -
1189 -
1190 d.jd = julianDayFromDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday); -
1191 return d;
executed: return d;
Execution Count:74
74
1192} -
1193 -
1194QTime QTime::currentTime() -
1195{ -
1196 QTime ct; -
1197 -
1198 struct timeval tv; -
1199 gettimeofday(&tv, 0); -
1200 time_t ltime = tv.tv_sec; -
1201 struct tm *t = 0; -
1202 -
1203 -
1204 -
1205 tzset(); -
1206 struct tm res; -
1207 t = localtime_r(&ltime, &res); -
1208 -
1209 -
1210 -
1211 do { if (!(t)) qBadAlloc(); } while (0);
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14027133
never executed: qBadAlloc();
executed: }
Execution Count:14027095
partially evaluated: !(t)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14027065
0-14027133
1212 -
1213 ct.mds = msecsFromDecomposed(t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec / 1000); -
1214 return ct;
executed: return ct;
Execution Count:14027143
14027143
1215} -
1216 -
1217QDateTime QDateTime::currentDateTime() -
1218{ -
1219 -
1220 -
1221 struct timeval tv; -
1222 gettimeofday(&tv, 0); -
1223 time_t ltime = tv.tv_sec; -
1224 struct tm *t = 0; -
1225 -
1226 -
1227 -
1228 tzset(); -
1229 struct tm res; -
1230 t = localtime_r(&ltime, &res); -
1231 -
1232 -
1233 -
1234 -
1235 QDateTime dt; -
1236 dt.d->time.mds = msecsFromDecomposed(t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec / 1000); -
1237 -
1238 dt.d->date.jd = julianDayFromDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday); -
1239 dt.d->spec = t->tm_isdst > 0 ? QDateTimePrivate::LocalDST :
evaluated: t->tm_isdst > 0
TRUEFALSE
yes
Evaluation Count:9756
yes
Evaluation Count:9
9-9756
1240 t->tm_isdst == 0 ? QDateTimePrivate::LocalStandard : -
1241 QDateTimePrivate::LocalUnknown; -
1242 return dt;
executed: return dt;
Execution Count:9765
9765
1243} -
1244 -
1245QDateTime QDateTime::currentDateTimeUtc() -
1246{ -
1247 -
1248 -
1249 struct timeval tv; -
1250 gettimeofday(&tv, 0); -
1251 time_t ltime = tv.tv_sec; -
1252 struct tm *t = 0; -
1253 -
1254 -
1255 -
1256 struct tm res; -
1257 t = gmtime_r(&ltime, &res); -
1258 -
1259 -
1260 -
1261 -
1262 QDateTime dt; -
1263 dt.d->time.mds = msecsFromDecomposed(t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec / 1000); -
1264 -
1265 dt.d->date.jd = julianDayFromDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday); -
1266 dt.d->spec = QDateTimePrivate::UTC; -
1267 return dt;
executed: return dt;
Execution Count:4
4
1268} -
1269 -
1270qint64 QDateTime::currentMSecsSinceEpoch() -
1271{ -
1272 -
1273 -
1274 struct timeval tv; -
1275 gettimeofday(&tv, 0); -
1276 return qint64(tv.tv_sec) * static_cast<long long>(1000LL) + tv.tv_usec / 1000;
executed: return qint64(tv.tv_sec) * static_cast<long long>(1000LL) + tv.tv_usec / 1000;
Execution Count:1
1
1277} -
1278QDateTime QDateTime::fromTime_t(uint seconds) -
1279{ -
1280 QDateTime d; -
1281 d.setTime_t(seconds); -
1282 return d;
executed: return d;
Execution Count:4991
4991
1283} -
1284QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs) -
1285{ -
1286 QDateTime d; -
1287 d.setMSecsSinceEpoch(msecs); -
1288 return d;
executed: return d;
Execution Count:8
8
1289} -
1290void QDateTime::setUtcOffset(int seconds) -
1291{ -
1292 detach(); -
1293 -
1294 -
1295 -
1296 -
1297 if(seconds == 0)
evaluated: seconds == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:15
1-15
1298 d->spec = QDateTimePrivate::UTC;
executed: d->spec = QDateTimePrivate::UTC;
Execution Count:1
1
1299 else -
1300 d->spec = QDateTimePrivate::OffsetFromUTC;
executed: d->spec = QDateTimePrivate::OffsetFromUTC;
Execution Count:15
15
1301 -
1302 -
1303 d->utcOffset = seconds; -
1304}
executed: }
Execution Count:16
16
1305int QDateTime::utcOffset() const -
1306{ -
1307 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
1308 return d->utcOffset;
executed: return d->utcOffset;
Execution Count:5
5
1309 else -
1310 return 0;
executed: return 0;
Execution Count:3
3
1311} -
1312 -
1313 -
1314 -
1315static int fromShortMonthName(const QString &monthName) -
1316{ -
1317 -
1318 for (int i = 0; i < 12; ++i) {
evaluated: i < 12
TRUEFALSE
yes
Evaluation Count:254
yes
Evaluation Count:15
15-254
1319 if (monthName == QLatin1String(qt_shortMonthNames[i]))
evaluated: monthName == QLatin1String(qt_shortMonthNames[i])
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:220
34-220
1320 return i + 1;
executed: return i + 1;
Execution Count:34
34
1321 }
executed: }
Execution Count:220
220
1322 -
1323 for (int i = 1; i <= 12; ++i) {
evaluated: i <= 12
TRUEFALSE
yes
Evaluation Count:180
yes
Evaluation Count:15
15-180
1324 if (monthName == QDate::shortMonthName(i))
partially evaluated: monthName == QDate::shortMonthName(i)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:180
0-180
1325 return i;
never executed: return i;
0
1326 }
executed: }
Execution Count:180
180
1327 return -1;
executed: return -1;
Execution Count:15
15
1328} -
1329QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) -
1330{ -
1331 if (s.isEmpty()) {
evaluated: s.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:98
2-98
1332 return QDateTime();
executed: return QDateTime();
Execution Count:2
2
1333 } -
1334 -
1335 switch (f) { -
1336 case Qt::ISODate: { -
1337 QString tmp = s; -
1338 Qt::TimeSpec ts = Qt::LocalTime; -
1339 QDate date = QDate::fromString(tmp.left(10), Qt::ISODate); -
1340 if (tmp.size() == 10)
evaluated: tmp.size() == 10
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:54
1-54
1341 return QDateTime(date);
executed: return QDateTime(date);
Execution Count:1
1
1342 -
1343 tmp = tmp.mid(11); -
1344 -
1345 -
1346 if (tmp.endsWith(QLatin1Char('Z'))) {
evaluated: tmp.endsWith(QLatin1Char('Z'))
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:49
5-49
1347 ts = Qt::UTC; -
1348 tmp.chop(1); -
1349 }
executed: }
Execution Count:5
5
1350 -
1351 -
1352 QRegExp rx(QLatin1String("[+-]")); -
1353 if (tmp.contains(rx)) {
evaluated: tmp.contains(rx)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:50
4-50
1354 int idx = tmp.indexOf(rx); -
1355 QString tmp2 = tmp.mid(idx); -
1356 tmp = tmp.left(idx); -
1357 bool ok = true; -
1358 int ntzhour = 1; -
1359 int ntzminute = 3; -
1360 if ( tmp2.indexOf(QLatin1Char(':')) == 3 )
evaluated: tmp2.indexOf(QLatin1Char(':')) == 3
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
1361 ntzminute = 4;
executed: ntzminute = 4;
Execution Count:3
3
1362 const int tzhour(tmp2.mid(ntzhour, 2).toInt(&ok)); -
1363 const int tzminute(tmp2.mid(ntzminute, 2).toInt(&ok)); -
1364 QTime tzt(tzhour, tzminute); -
1365 int utcOffset = (tzt.hour() * 60 + tzt.minute()) * 60; -
1366 if ( utcOffset != 0 ) {
evaluated: utcOffset != 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1367 ts = Qt::OffsetFromUTC; -
1368 QDateTime dt(date, QTime::fromString(tmp, Qt::ISODate), ts); -
1369 dt.setUtcOffset( utcOffset * (tmp2.startsWith(QLatin1Char('-')) ? -1 : 1) ); -
1370 return dt;
executed: return dt;
Execution Count:2
2
1371 } -
1372 }
executed: }
Execution Count:2
2
1373 -
1374 bool isMidnight24 = false; -
1375 -
1376 QTime time(fromStringImpl(tmp, Qt::ISODate, isMidnight24)); -
1377 if (isMidnight24) {
evaluated: isMidnight24
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:47
5-47
1378 -
1379 date = date.addDays(1); -
1380 }
executed: }
Execution Count:5
5
1381 -
1382 return QDateTime(date, time, ts);
executed: return QDateTime(date, time, ts);
Execution Count:52
52
1383 } -
1384 case Qt::SystemLocaleDate: -
1385 case Qt::SystemLocaleShortDate: -
1386 case Qt::SystemLocaleLongDate: -
1387 return fromString(s, QLocale::system().dateTimeFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat 3
1388 : QLocale::ShortFormat));
executed: return fromString(s, QLocale::system().dateTimeFormat(f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
Execution Count:3
3
1389 case Qt::LocaleDate: -
1390 case Qt::DefaultLocaleShortDate: -
1391 case Qt::DefaultLocaleLongDate: -
1392 return fromString(s, QLocale().dateTimeFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat 3
1393 : QLocale::ShortFormat));
executed: return fromString(s, QLocale().dateTimeFormat(f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat));
Execution Count:3
3
1394 -
1395 case Qt::TextDate: { -
1396 QStringList parts = s.split(QLatin1Char(' '), QString::SkipEmptyParts); -
1397 -
1398 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
1399 return QDateTime();
executed: return QDateTime();
Execution Count:2
2
1400 } -
1401 -
1402 -
1403 int month = -1, day = -1; -
1404 bool ok; -
1405 -
1406 month = fromShortMonthName(parts.at(1)); -
1407 if (month != -1) {
evaluated: month != -1
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:13
13-22
1408 day = parts.at(2).toInt(&ok); -
1409 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:21
1-21
1410 day = -1;
executed: day = -1;
Execution Count:1
1
1411 }
executed: }
Execution Count:22
22
1412 -
1413 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
1414 -
1415 month = fromShortMonthName(parts.at(2)); -
1416 if (month != -1) {
evaluated: month != -1
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:2
2-12
1417 QString dayStr = parts.at(1); -
1418 if (dayStr.endsWith(QLatin1Char('.'))) {
evaluated: dayStr.endsWith(QLatin1Char('.'))
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1
1-11
1419 dayStr.chop(1); -
1420 day = dayStr.toInt(&ok); -
1421 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-10
1422 day = -1;
executed: day = -1;
Execution Count:1
1
1423 } else {
executed: }
Execution Count:11
11
1424 day = -1; -
1425 }
executed: }
Execution Count:1
1
1426 } -
1427 }
executed: }
Execution Count:14
14
1428 -
1429 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
1430 -
1431 return QDateTime();
executed: return QDateTime();
Execution Count:4
4
1432 } -
1433 -
1434 int year; -
1435 QStringList timeParts = parts.at(3).split(QLatin1Char(':')); -
1436 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
1437 -
1438 year = parts.at(4).toInt(&ok); -
1439 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:17
1-17
1440 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
1441 } else {
executed: }
Execution Count:17
17
1442 timeParts = parts.at(4).split(QLatin1Char(':')); -
1443 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
1444 return QDateTime();
executed: return QDateTime();
Execution Count:2
2
1445 year = parts.at(3).toInt(&ok); -
1446 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-10
1447 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
1448 }
executed: }
Execution Count:10
10
1449 -
1450 int hour = timeParts.at(0).toInt(&ok); -
1451 if (!ok) {
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:26
1-26
1452 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
1453 } -
1454 -
1455 int minute = timeParts.at(1).toInt(&ok); -
1456 if (!ok) {
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:25
1-25
1457 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
1458 } -
1459 -
1460 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
1461 if (!ok) {
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:24
1-24
1462 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
1463 } -
1464 -
1465 QDate date(year, month, day); -
1466 QTime time(hour, minute, second); -
1467 -
1468 if (parts.count() == 5)
evaluated: parts.count() == 5
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:10
10-14
1469 return QDateTime(date, time, Qt::LocalTime);
executed: return QDateTime(date, time, Qt::LocalTime);
Execution Count:14
14
1470 -
1471 QString tz = parts.at(5); -
1472 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
1473 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
1474 QDateTime dt(date, time, Qt::UTC); -
1475 if (tz.length() > 3) {
evaluated: tz.length() > 3
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:2
2-7
1476 int tzoffset = 0; -
1477 QChar sign = tz.at(3); -
1478 if ((sign != QLatin1Char('+'))
evaluated: (sign != QLatin1Char('+'))
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
1479 && (sign != QLatin1Char('-'))) {
evaluated: (sign != QLatin1Char('-'))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1480 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
1481 } -
1482 int tzhour = tz.mid(4, 2).toInt(&ok); -
1483 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
2-4
1484 return QDateTime();
executed: return QDateTime();
Execution Count:2
2
1485 int tzminute = tz.mid(6).toInt(&ok); -
1486 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
1487 return QDateTime();
executed: return QDateTime();
Execution Count:1
1
1488 tzoffset = (tzhour*60 + tzminute) * 60; -
1489 if (sign == QLatin1Char('-'))
evaluated: sign == QLatin1Char('-')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
1490 tzoffset = -tzoffset;
executed: tzoffset = -tzoffset;
Execution Count:1
1
1491 dt.setUtcOffset(tzoffset); -
1492 }
executed: }
Execution Count:3
3
1493 return dt.toLocalTime();
executed: return dt.toLocalTime();
Execution Count:5
5
1494 } -
1495 -
1496 } -
1497 -
1498 return QDateTime();
never executed: return QDateTime();
0
1499} -
1500QDateTime QDateTime::fromString(const QString &string, const QString &format) -
1501{ -
1502 -
1503 QTime time; -
1504 QDate date; -
1505 -
1506 QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString); -
1507 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
1508 return QDateTime(date, time);
executed: return QDateTime(date, time);
Execution Count:38
38
1509 -
1510 -
1511 -
1512 -
1513 return QDateTime(QDate(), QTime(-1, -1, -1));
executed: return QDateTime(QDate(), QTime(-1, -1, -1));
Execution Count:9
9
1514} -
1515void QDateTime::detach() -
1516{ -
1517 d.detach(); -
1518}
executed: }
Execution Count:7153
7153
1519QDataStream &operator<<(QDataStream &out, const QDate &date) -
1520{ -
1521 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
1522 return out << quint32(date.jd);
executed: return out << quint32(date.jd);
Execution Count:158
158
1523 else -
1524 return out << qint64(date.jd);
executed: return out << qint64(date.jd);
Execution Count:387
387
1525} -
1526QDataStream &operator>>(QDataStream &in, QDate &date) -
1527{ -
1528 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
1529 quint32 jd; -
1530 in >> jd; -
1531 -
1532 date.jd = (jd != 0 ? jd : QDate::nullJd());
evaluated: jd != 0
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:16
16-144
1533 } else {
executed: }
Execution Count:160
160
1534 qint64 jd; -
1535 in >> jd; -
1536 date.jd = jd; -
1537 }
executed: }
Execution Count:381
381
1538 -
1539 return in;
executed: return in;
Execution Count:541
541
1540} -
1541QDataStream &operator<<(QDataStream &out, const QTime &time) -
1542{ -
1543 return out << quint32(time.mds);
executed: return out << quint32(time.mds);
Execution Count:744
744
1544} -
1545QDataStream &operator>>(QDataStream &in, QTime &time) -
1546{ -
1547 quint32 ds; -
1548 in >> ds; -
1549 time.mds = int(ds); -
1550 return in;
executed: return in;
Execution Count:740
740
1551} -
1552QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime) -
1553{ -
1554 if (out.version() >= 13) {
evaluated: out.version() >= 13
TRUEFALSE
yes
Evaluation Count:282
yes
Evaluation Count:97
97-282
1555 if (dateTime.isValid()) {
evaluated: dateTime.isValid()
TRUEFALSE
yes
Evaluation Count:170
yes
Evaluation Count:112
112-170
1556 QDateTime asUTC = dateTime.toUTC(); -
1557 out << asUTC.d->date << asUTC.d->time; -
1558 } else {
executed: }
Execution Count:170
170
1559 out << dateTime.d->date << dateTime.d->time; -
1560 }
executed: }
Execution Count:112
112
1561 out << (qint8)dateTime.timeSpec(); -
1562 } else {
executed: }
Execution Count:282
282
1563 out << dateTime.d->date << dateTime.d->time; -
1564 if (out.version() >= 7)
evaluated: out.version() >= 7
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:48
48-49
1565 out << (qint8)dateTime.d->spec;
executed: out << (qint8)dateTime.d->spec;
Execution Count:49
49
1566 }
executed: }
Execution Count:97
97
1567 return out;
executed: return out;
Execution Count:379
379
1568} -
1569QDataStream &operator>>(QDataStream &in, QDateTime &dateTime) -
1570{ -
1571 dateTime.detach(); -
1572 -
1573 in >> dateTime.d->date >> dateTime.d->time; -
1574 -
1575 if (in.version() >= 13) {
evaluated: in.version() >= 13
TRUEFALSE
yes
Evaluation Count:269
yes
Evaluation Count:50
50-269
1576 qint8 ts = 0; -
1577 in >> ts; -
1578 if (dateTime.isValid()) {
evaluated: dateTime.isValid()
TRUEFALSE
yes
Evaluation Count:179
yes
Evaluation Count:90
90-179
1579 -
1580 dateTime.d->spec = QDateTimePrivate::UTC; -
1581 dateTime = dateTime.toTimeSpec(static_cast<Qt::TimeSpec>(ts)); -
1582 }
executed: }
Execution Count:179
179
1583 } else {
executed: }
Execution Count:269
269
1584 qint8 ts = (qint8)QDateTimePrivate::LocalUnknown; -
1585 if (in.version() >= 7)
evaluated: in.version() >= 7
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:24
24-26
1586 in >> ts;
executed: in >> ts;
Execution Count:26
26
1587 dateTime.d->spec = (QDateTimePrivate::Spec)ts; -
1588 }
executed: }
Execution Count:50
50
1589 return in;
executed: return in;
Execution Count:319
319
1590} -
1591 -
1592 -
1593 -
1594 -
1595 -
1596static bool hasUnquotedAP(const QString &f) -
1597{ -
1598 const QLatin1Char quote('\''); -
1599 bool inquote = false; -
1600 const int max = f.size(); -
1601 for (int i=0; i<max; ++i) {
evaluated: i<max
TRUEFALSE
yes
Evaluation Count:322540
yes
Evaluation Count:27883
27883-322540
1602 if (f.at(i) == quote) {
evaluated: f.at(i) == quote
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:322516
24-322516
1603 inquote = !inquote; -
1604 } else if (!inquote && f.at(i).toUpper() == QLatin1Char('A')) {
evaluated: !inquote
TRUEFALSE
yes
Evaluation Count:322493
yes
Evaluation Count:23
evaluated: f.at(i).toUpper() == QLatin1Char('A')
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:322485
executed: }
Execution Count:24
8-322493
1605 return true;
executed: return true;
Execution Count:8
8
1606 } -
1607 } -
1608 return false;
executed: return false;
Execution Count:27883
27883
1609} -
1610 -
1611 -
1612 -
1613 -
1614 -
1615 -
1616 -
1617static QString getFmtString(const QString& f, const QTime* dt = 0, const QDate* dd = 0, bool am_pm = false) -
1618{ -
1619 if (f.isEmpty())
evaluated: f.isEmpty()
TRUEFALSE
yes
Evaluation Count:102268
yes
Evaluation Count:102282
102268-102282
1620 return QString();
executed: return QString();
Execution Count:102268
102268
1621 -
1622 QString buf = f; -
1623 int removed = 0; -
1624 -
1625 if (dt) {
evaluated: dt
TRUEFALSE
yes
Evaluation Count:62892
yes
Evaluation Count:39390
39390-62892
1626 if (f.startsWith(QLatin1String("hh")) || f.startsWith(QLatin1String("HH"))) {
evaluated: f.startsWith(QLatin1String("hh"))
TRUEFALSE
yes
Evaluation Count:14727
yes
Evaluation Count:48165
evaluated: f.startsWith(QLatin1String("HH"))
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:48163
2-48165
1627 const bool hour12 = f.at(0) == QLatin1Char('h') && am_pm;
evaluated: f.at(0) == QLatin1Char('h')
TRUEFALSE
yes
Evaluation Count:14727
yes
Evaluation Count:2
evaluated: am_pm
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:14720
2-14727
1628 if (hour12 && dt->hour() > 12)
evaluated: hour12
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:14722
evaluated: dt->hour() > 12
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3
3-14722
1629 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
1630 else if (hour12 && dt->hour() == 0)
evaluated: hour12
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:14722
evaluated: dt->hour() == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-14722
1631 buf = QLatin1String("12");
executed: buf = QLatin1String("12");
Execution Count:1
1
1632 else -
1633 buf = QString::number(dt->hour()).rightJustified(2, QLatin1Char('0'), true);
executed: buf = QString::number(dt->hour()).rightJustified(2, QLatin1Char('0'), true);
Execution Count:14724
14724
1634 removed = 2; -
1635 } else if (f.at(0) == QLatin1Char('h') || f.at(0) == QLatin1Char('H')) {
evaluated: f.at(0) == QLatin1Char('h')
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:48158
evaluated: f.at(0) == QLatin1Char('H')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:48156
executed: }
Execution Count:14729
2-48158
1636 const bool hour12 = f.at(0) == QLatin1Char('h') && am_pm;
evaluated: f.at(0) == QLatin1Char('h')
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
evaluated: am_pm
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-5
1637 if (hour12 && dt->hour() > 12)
evaluated: hour12
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
evaluated: dt->hour() > 12
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-4
1638 buf = QString::number(dt->hour() - 12);
executed: buf = QString::number(dt->hour() - 12);
Execution Count:1
1
1639 else if (hour12 && dt->hour() == 0)
evaluated: hour12
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
evaluated: dt->hour() == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1-4
1640 buf = QLatin1String("12");
executed: buf = QLatin1String("12");
Execution Count:1
1
1641 else -
1642 buf = QString::number(dt->hour());
executed: buf = QString::number(dt->hour());
Execution Count:5
5
1643 removed = 1; -
1644 } else if (f.startsWith(QLatin1String("mm"))) {
evaluated: f.startsWith(QLatin1String("mm"))
TRUEFALSE
yes
Evaluation Count:14718
yes
Evaluation Count:33438
executed: }
Execution Count:7
7-33438
1645 buf = QString::number(dt->minute()).rightJustified(2, QLatin1Char('0'), true); -
1646 removed = 2; -
1647 } else if (f.at(0) == (QLatin1Char('m'))) {
evaluated: f.at(0) == (QLatin1Char('m'))
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:33436
executed: }
Execution Count:14718
2-33436
1648 buf = QString::number(dt->minute()); -
1649 removed = 1; -
1650 } else if (f.startsWith(QLatin1String("ss"))) {
evaluated: f.startsWith(QLatin1String("ss"))
TRUEFALSE
yes
Evaluation Count:14720
yes
Evaluation Count:18716
executed: }
Execution Count:2
2-18716
1651 buf = QString::number(dt->second()).rightJustified(2, QLatin1Char('0'), true); -
1652 removed = 2; -
1653 } else if (f.at(0) == QLatin1Char('s')) {
evaluated: f.at(0) == QLatin1Char('s')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18715
executed: }
Execution Count:14720
1-18715
1654 buf = QString::number(dt->second()); -
1655 } else if (f.startsWith(QLatin1String("zzz"))) {
evaluated: f.startsWith(QLatin1String("zzz"))
TRUEFALSE
yes
Evaluation Count:14734
yes
Evaluation Count:3981
executed: }
Execution Count:1
1-14734
1656 buf = QString::number(dt->msec()).rightJustified(3, QLatin1Char('0'), true); -
1657 removed = 3; -
1658 } else if (f.at(0) == QLatin1Char('z')) {
evaluated: f.at(0) == QLatin1Char('z')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3979
executed: }
Execution Count:14734
2-14734
1659 buf = QString::number(dt->msec()); -
1660 removed = 1; -
1661 } else if (f.at(0).toUpper() == QLatin1Char('A')) {
executed: }
Execution Count:2
evaluated: f.at(0).toUpper() == QLatin1Char('A')
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:3965
2-3965
1662 const bool upper = f.at(0) == QLatin1Char('A'); -
1663 buf = dt->hour() < 12 ? QLatin1String("am") : QLatin1String("pm");
evaluated: dt->hour() < 12
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
7
1664 if (upper)
evaluated: upper
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:6
6-8
1665 buf = buf.toUpper();
executed: buf = buf.toUpper();
Execution Count:8
8
1666 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
1667 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
1668 removed = 2; -
1669 } else {
executed: }
Execution Count:9
9
1670 removed = 1; -
1671 }
executed: }
Execution Count:5
5
1672 } -
1673 } -
1674 -
1675 if (dd) {
evaluated: dd
TRUEFALSE
yes
Evaluation Count:48656
yes
Evaluation Count:53626
48656-53626
1676 if (f.startsWith(QLatin1String("dddd"))) {
evaluated: f.startsWith(QLatin1String("dddd"))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:48655
1-48655
1677 buf = dd->longDayName(dd->dayOfWeek()); -
1678 removed = 4; -
1679 } else if (f.startsWith(QLatin1String("ddd"))) {
evaluated: f.startsWith(QLatin1String("ddd"))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:48654
executed: }
Execution Count:1
1-48654
1680 buf = dd->shortDayName(dd->dayOfWeek()); -
1681 removed = 3; -
1682 } else if (f.startsWith(QLatin1String("dd"))) {
evaluated: f.startsWith(QLatin1String("dd"))
TRUEFALSE
yes
Evaluation Count:14447
yes
Evaluation Count:34207
executed: }
Execution Count:1
1-34207
1683 buf = QString::number(dd->day()).rightJustified(2, QLatin1Char('0'), true); -
1684 removed = 2; -
1685 } else if (f.at(0) == QLatin1Char('d')) {
evaluated: f.at(0) == QLatin1Char('d')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:34205
executed: }
Execution Count:14447
2-34205
1686 buf = QString::number(dd->day()); -
1687 removed = 1; -
1688 } else if (f.startsWith(QLatin1String("MMMM"))) {
evaluated: f.startsWith(QLatin1String("MMMM"))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:34204
executed: }
Execution Count:2
1-34204
1689 buf = dd->longMonthName(dd->month()); -
1690 removed = 4; -
1691 } else if (f.startsWith(QLatin1String("MMM"))) {
evaluated: f.startsWith(QLatin1String("MMM"))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:34203
executed: }
Execution Count:1
1-34203
1692 buf = dd->shortMonthName(dd->month()); -
1693 removed = 3; -
1694 } else if (f.startsWith(QLatin1String("MM"))) {
evaluated: f.startsWith(QLatin1String("MM"))
TRUEFALSE
yes
Evaluation Count:14446
yes
Evaluation Count:19757
executed: }
Execution Count:1
1-19757
1695 buf = QString::number(dd->month()).rightJustified(2, QLatin1Char('0'), true); -
1696 removed = 2; -
1697 } else if (f.at(0) == QLatin1Char('M')) {
evaluated: f.at(0) == QLatin1Char('M')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:19755
executed: }
Execution Count:14446
2-19755
1698 buf = QString::number(dd->month()); -
1699 removed = 1; -
1700 } else if (f.startsWith(QLatin1String("yyyy"))) {
evaluated: f.startsWith(QLatin1String("yyyy"))
TRUEFALSE
yes
Evaluation Count:14450
yes
Evaluation Count:5305
executed: }
Execution Count:2
2-14450
1701 const int year = dd->year(); -
1702 buf = QString::number(qAbs(year)).rightJustified(4, QLatin1Char('0')); -
1703 if(year > 0)
evaluated: year > 0
TRUEFALSE
yes
Evaluation Count:14252
yes
Evaluation Count:198
198-14252
1704 removed = 4;
executed: removed = 4;
Execution Count:14252
14252
1705 else -
1706 { -
1707 buf.prepend(QLatin1Char('-')); -
1708 removed = 5; -
1709 }
executed: }
Execution Count:198
198
1710 -
1711 } else if (f.startsWith(QLatin1String("yy"))) {
evaluated: f.startsWith(QLatin1String("yy"))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5301
4-5301
1712 buf = QString::number(dd->year()).right(2).rightJustified(2, QLatin1Char('0')); -
1713 removed = 2; -
1714 }
executed: }
Execution Count:4
4
1715 } -
1716 if (removed == 0 || removed >= f.size()) {
evaluated: removed == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:102281
evaluated: removed >= f.size()
TRUEFALSE
yes
Evaluation Count:102275
yes
Evaluation Count:6
1-102281
1717 return buf;
executed: return buf;
Execution Count:102276
102276
1718 } -
1719 -
1720 return buf + getFmtString(f.mid(removed), dt, dd, am_pm);
executed: return buf + getFmtString(f.mid(removed), dt, dd, am_pm);
Execution Count:6
6
1721} -
1722 -
1723 -
1724static QString fmtDateTime(const QString& f, const QTime* dt, const QDate* dd) -
1725{ -
1726 QString buf; -
1727 -
1728 if (f.isEmpty())
evaluated: f.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:27894
1-27894
1729 return buf;
executed: return buf;
Execution Count:1
1
1730 if (dt && !dt->isValid())
evaluated: dt
TRUEFALSE
yes
Evaluation Count:14760
yes
Evaluation Count:13134
evaluated: !dt->isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:14758
2-14760
1731 return buf;
executed: return buf;
Execution Count:2
2
1732 if (dd && !dd->isValid())
evaluated: dd
TRUEFALSE
yes
Evaluation Count:14485
yes
Evaluation Count:13407
evaluated: !dd->isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14484
1-14485
1733 return buf;
executed: return buf;
Execution Count:1
1
1734 -
1735 const bool ap = hasUnquotedAP(f); -
1736 -
1737 QString frm; -
1738 uint status = '0'; -
1739 -
1740 for (int i = 0, n = f.length(); i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:322606
yes
Evaluation Count:27891
27891-322606
1741 const QChar c = f.at(i); -
1742 const uint cc = c.unicode(); -
1743 if (cc == '\'') {
evaluated: cc == '\''
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:322580
26-322580
1744 if (status == cc) {
evaluated: status == cc
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:14
12-14
1745 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
1746 buf += c;
executed: buf += c;
Execution Count:5
5
1747 status = '0'; -
1748 } else {
executed: }
Execution Count:12
12
1749 if (!frm.isEmpty()) {
evaluated: !frm.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:9
5-9
1750 buf += getFmtString(frm, dt, dd, ap); -
1751 frm.clear(); -
1752 }
executed: }
Execution Count:5
5
1753 status = cc; -
1754 }
executed: }
Execution Count:14
14
1755 } else if (status == '\'') {
evaluated: status == '\''
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:322555
25-322555
1756 buf += c; -
1757 } else if (c == status) {
evaluated: c == status
TRUEFALSE
yes
Evaluation Count:145907
yes
Evaluation Count:176648
executed: }
Execution Count:25
25-176648
1758 if (ap && (cc == 'P' || cc == 'p'))
evaluated: ap
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:145864
evaluated: cc == 'P'
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:38
evaluated: cc == 'p'
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:34
4-145864
1759 status = '0';
executed: status = '0';
Execution Count:9
9
1760 frm += c; -
1761 } else {
executed: }
Execution Count:145907
145907
1762 buf += getFmtString(frm, dt, dd, ap); -
1763 frm.clear(); -
1764 if (cc == 'h' || cc == 'm' || cc == 'H' || cc == 's' || cc == 'z') {
evaluated: cc == 'h'
TRUEFALSE
yes
Evaluation Count:14728
yes
Evaluation Count:161920
evaluated: cc == 'm'
TRUEFALSE
yes
Evaluation Count:14720
yes
Evaluation Count:147200
evaluated: cc == 'H'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:147198
evaluated: cc == 's'
TRUEFALSE
yes
Evaluation Count:14721
yes
Evaluation Count:132477
evaluated: cc == 'z'
TRUEFALSE
yes
Evaluation Count:14736
yes
Evaluation Count:117741
2-161920
1765 status = cc; -
1766 frm += c; -
1767 } else if (cc == 'd' || cc == 'M' || cc == 'y') {
evaluated: cc == 'd'
TRUEFALSE
yes
Evaluation Count:14451
yes
Evaluation Count:103290
evaluated: cc == 'M'
TRUEFALSE
yes
Evaluation Count:14450
yes
Evaluation Count:88840
evaluated: cc == 'y'
TRUEFALSE
yes
Evaluation Count:14454
yes
Evaluation Count:74386
executed: }
Execution Count:58907
14450-103290
1768 status = cc; -
1769 frm += c; -
1770 } else if (ap && cc == 'A') {
evaluated: ap
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:74355
evaluated: cc == 'A'
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:23
executed: }
Execution Count:43355
8-74355
1771 status = 'P'; -
1772 frm += c; -
1773 } else if (ap && cc == 'a') {
evaluated: ap
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:74355
evaluated: cc == 'a'
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:17
executed: }
Execution Count:8
6-74355
1774 status = 'p'; -
1775 frm += c; -
1776 } else {
executed: }
Execution Count:6
6
1777 buf += c; -
1778 status = '0'; -
1779 }
executed: }
Execution Count:74372
74372
1780 } -
1781 } -
1782 -
1783 buf += getFmtString(frm, dt, dd, ap); -
1784 -
1785 return buf;
executed: return buf;
Execution Count:27891
27891
1786} -
1787 -
1788 -
1789 -
1790 -
1791 -
1792static const int LowerYear = 1970; -
1793 -
1794static const int UpperYear = 2037; -
1795 -
1796static QDate adjustDate(QDate date) -
1797{ -
1798 QDate lowerLimit(LowerYear, 1, 2); -
1799 QDate upperLimit(UpperYear, 12, 30); -
1800 -
1801 if (date > lowerLimit && date < upperLimit)
evaluated: date > lowerLimit
TRUEFALSE
yes
Evaluation Count:20662
yes
Evaluation Count:405
evaluated: date < upperLimit
TRUEFALSE
yes
Evaluation Count:20452
yes
Evaluation Count:210
210-20662
1802 return date;
executed: return date;
Execution Count:20452
20452
1803 -
1804 int month = date.month(); -
1805 int day = date.day(); -
1806 -
1807 -
1808 if (month == 2 && day == 29)
evaluated: month == 2
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:569
evaluated: day == 29
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:14
14-569
1809 --day;
executed: --day;
Execution Count:32
32
1810 -
1811 if (date < lowerLimit)
evaluated: date < lowerLimit
TRUEFALSE
yes
Evaluation Count:390
yes
Evaluation Count:225
225-390
1812 date.setDate(LowerYear, month, day);
executed: date.setDate(LowerYear, month, day);
Execution Count:390
390
1813 else -
1814 date.setDate(UpperYear, month, day);
executed: date.setDate(UpperYear, month, day);
Execution Count:225
225
1815 -
1816 return date;
executed: return date;
Execution Count:615
615
1817} -
1818 -
1819static QDateTimePrivate::Spec utcToLocal(QDate &date, QTime &time) -
1820{ -
1821 QDate fakeDate = adjustDate(date); -
1822 -
1823 -
1824 time_t secsSince1Jan1970UTC = toMSecsSinceEpoch_helper(fakeDate.toJulianDay(), QTime(0, 0, 0).msecsTo(time)) / 1000; -
1825 tm *brokenDown = 0; -
1826 tzset(); -
1827 tm res; -
1828 brokenDown = localtime_r(&secsSince1Jan1970UTC, &res); -
1829 -
1830 -
1831 -
1832 -
1833 -
1834 -
1835 -
1836 if (!brokenDown) {
partially evaluated: !brokenDown
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6038
0-6038
1837 date = QDate(1970, 1, 1); -
1838 time = QTime(); -
1839 return QDateTimePrivate::LocalUnknown;
never executed: return QDateTimePrivate::LocalUnknown;
0
1840 } else { -
1841 int deltaDays = fakeDate.daysTo(date); -
1842 date = QDate(brokenDown->tm_year + 1900, brokenDown->tm_mon + 1, brokenDown->tm_mday); -
1843 time = QTime(brokenDown->tm_hour, brokenDown->tm_min, brokenDown->tm_sec, time.msec()); -
1844 date = date.addDays(deltaDays); -
1845 if (brokenDown->tm_isdst > 0)
evaluated: brokenDown->tm_isdst > 0
TRUEFALSE
yes
Evaluation Count:4538
yes
Evaluation Count:1500
1500-4538
1846 return QDateTimePrivate::LocalDST;
executed: return QDateTimePrivate::LocalDST;
Execution Count:4538
4538
1847 else if (brokenDown->tm_isdst < 0)
partially evaluated: brokenDown->tm_isdst < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1500
0-1500
1848 return QDateTimePrivate::LocalUnknown;
never executed: return QDateTimePrivate::LocalUnknown;
0
1849 else -
1850 return QDateTimePrivate::LocalStandard;
executed: return QDateTimePrivate::LocalStandard;
Execution Count:1500
1500
1851 } -
1852} -
1853 -
1854static void localToUtc(QDate &date, QTime &time, int isdst) -
1855{ -
1856 if (!date.isValid())
evaluated: !date.isValid()
TRUEFALSE
yes
Evaluation Count:2181
yes
Evaluation Count:15029
2181-15029
1857 return;
executed: return;
Execution Count:2181
2181
1858 -
1859 QDate fakeDate = adjustDate(date); -
1860 -
1861 tm localTM; -
1862 localTM.tm_sec = time.second(); -
1863 localTM.tm_min = time.minute(); -
1864 localTM.tm_hour = time.hour(); -
1865 localTM.tm_mday = fakeDate.day(); -
1866 localTM.tm_mon = fakeDate.month() - 1; -
1867 localTM.tm_year = fakeDate.year() - 1900; -
1868 localTM.tm_isdst = (int)isdst; -
1869 -
1870 -
1871 -
1872 -
1873 -
1874 -
1875 time_t secsSince1Jan1970UTC = mktime(&localTM); -
1876 -
1877 tm *brokenDown = 0; -
1878 tm res; -
1879 brokenDown = gmtime_r(&secsSince1Jan1970UTC, &res); -
1880 -
1881 -
1882 -
1883 -
1884 -
1885 -
1886 -
1887 if (!brokenDown) {
partially evaluated: !brokenDown
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15029
0-15029
1888 date = QDate(1970, 1, 1); -
1889 time = QTime(); -
1890 } else {
never executed: }
0
1891 int deltaDays = fakeDate.daysTo(date); -
1892 date = QDate(brokenDown->tm_year + 1900, brokenDown->tm_mon + 1, brokenDown->tm_mday); -
1893 time = QTime(brokenDown->tm_hour, brokenDown->tm_min, brokenDown->tm_sec, time.msec()); -
1894 date = date.addDays(deltaDays); -
1895 }
executed: }
Execution Count:15029
15029
1896} -
1897 -
1898QDateTimePrivate::Spec QDateTimePrivate::getLocal(QDate &outDate, QTime &outTime) const -
1899{ -
1900 outDate = date; -
1901 outTime = time; -
1902 if (spec == QDateTimePrivate::UTC)
partially evaluated: spec == QDateTimePrivate::UTC
TRUEFALSE
yes
Evaluation Count:6038
no
Evaluation Count:0
0-6038
1903 return utcToLocal(outDate, outTime);
executed: return utcToLocal(outDate, outTime);
Execution Count:6038
6038
1904 return spec;
never executed: return spec;
0
1905} -
1906 -
1907void QDateTimePrivate::getUTC(QDate &outDate, QTime &outTime) const -
1908{ -
1909 outDate = date; -
1910 outTime = time; -
1911 const bool isOffset = spec == QDateTimePrivate::OffsetFromUTC; -
1912 -
1913 if (spec != QDateTimePrivate::UTC && !isOffset)
evaluated: spec != QDateTimePrivate::UTC
TRUEFALSE
yes
Evaluation Count:17241
yes
Evaluation Count:5005
evaluated: !isOffset
TRUEFALSE
yes
Evaluation Count:17210
yes
Evaluation Count:31
31-17241
1914 localToUtc(outDate, outTime, (int)spec);
executed: localToUtc(outDate, outTime, (int)spec);
Execution Count:17210
17210
1915 -
1916 if (isOffset)
evaluated: isOffset
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:22215
31-22215
1917 addMSecs(outDate, outTime, -(qint64(utcOffset) * 1000));
executed: addMSecs(outDate, outTime, -(qint64(utcOffset) * 1000));
Execution Count:31
31
1918}
executed: }
Execution Count:22246
22246
1919 -
1920 -
1921QDebug operator<<(QDebug dbg, const QDate &date) -
1922{ -
1923 dbg.nospace() << "QDate(" << date.toString() << ')'; -
1924 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
1925} -
1926 -
1927QDebug operator<<(QDebug dbg, const QTime &time) -
1928{ -
1929 dbg.nospace() << "QTime(" << time.toString() << ')'; -
1930 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
1931} -
1932 -
1933QDebug operator<<(QDebug dbg, const QDateTime &date) -
1934{ -
1935 dbg.nospace() << "QDateTime(" << date.toString() << ')'; -
1936 return dbg.space();
executed: return dbg.space();
Execution Count:2
2
1937} -
1938uint qHash(const QDateTime &key, uint seed) -
1939{ -
1940 -
1941 -
1942 -
1943 -
1944 return qHash(key.toMSecsSinceEpoch(), seed);
executed: return qHash(key.toMSecsSinceEpoch(), seed);
Execution Count:16
16
1945} -
1946 -
1947 -
1948 -
1949 -
1950 -
1951 -
1952 -
1953uint qHash(const QDate &key, uint seed) -
1954{ -
1955 return qHash(key.toJulianDay(), seed);
executed: return qHash(key.toJulianDay(), seed);
Execution Count:6
6
1956} -
1957 -
1958 -
1959 -
1960 -
1961 -
1962 -
1963 -
1964uint qHash(const QTime &key, uint seed) -
1965{ -
1966 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
1967} -
1968int QDateTimeParser::getDigit(const QDateTime &t, int index) const -
1969{ -
1970 if (index < 0 || index >= sectionNodes.size()) {
partially evaluated: index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2164
partially evaluated: index >= sectionNodes.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2164
0-2164
1971 -
1972 QMessageLogger("tools/qdatetime.cpp", 4182, __PRETTY_FUNCTION__).warning("QDateTimeParser::getDigit() Internal error (%s %d)", -
1973 QString(t.toString()).toLocal8Bit().constData(), index); -
1974 -
1975 -
1976 -
1977 return -1;
never executed: return -1;
0
1978 } -
1979 const SectionNode &node = sectionNodes.at(index); -
1980 switch (node.type) { -
1981 case Hour24Section: case Hour12Section: return t.time().hour();
executed: return t.time().hour();
Execution Count:724
724
1982 case MinuteSection: return t.time().minute();
executed: return t.time().minute();
Execution Count:316
316
1983 case SecondSection: return t.time().second();
executed: return t.time().second();
Execution Count:299
299
1984 case MSecSection: return t.time().msec();
never executed: return t.time().msec();
0
1985 case YearSection2Digits: -
1986 case YearSection: return t.date().year();
executed: return t.date().year();
Execution Count:661
661
1987 case MonthSection: return t.date().month();
executed: return t.date().month();
Execution Count:60
60
1988 case DaySection: return t.date().day();
executed: return t.date().day();
Execution Count:95
95
1989 case DayOfWeekSectionShort: -
1990 case DayOfWeekSectionLong: return t.date().day();
executed: return t.date().day();
Execution Count:3
3
1991 case AmPmSection: return t.time().hour() > 11 ? 1 : 0;
executed: return t.time().hour() > 11 ? 1 : 0;
Execution Count:6
6
1992 -
1993 default: break;
never executed: break;
0
1994 } -
1995 -
1996 -
1997 QMessageLogger("tools/qdatetime.cpp", 4207, __PRETTY_FUNCTION__).warning("QDateTimeParser::getDigit() Internal error 2 (%s %d)", -
1998 QString(t.toString()).toLocal8Bit().constData(), index); -
1999 -
2000 -
2001 -
2002 return -1;
never executed: return -1;
0
2003} -
2004bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const -
2005{ -
2006 if (index < 0 || index >= sectionNodes.size()) {
partially evaluated: index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2657
partially evaluated: index >= sectionNodes.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2657
0-2657
2007 -
2008 QMessageLogger("tools/qdatetime.cpp", 4231, __PRETTY_FUNCTION__).warning("QDateTimeParser::setDigit() Internal error (%s %d %d)", -
2009 QString(v.toString()).toLocal8Bit().constData(), index, newVal); -
2010 -
2011 -
2012 -
2013 return false;
never executed: return false;
0
2014 } -
2015 const SectionNode &node = sectionNodes.at(index); -
2016 -
2017 int year, month, day, hour, minute, second, msec; -
2018 year = v.date().year(); -
2019 month = v.date().month(); -
2020 day = v.date().day(); -
2021 hour = v.time().hour(); -
2022 minute = v.time().minute(); -
2023 second = v.time().second(); -
2024 msec = v.time().msec(); -
2025 -
2026 switch (node.type) { -
2027 case Hour24Section: case Hour12Section: hour = newVal; break;
executed: break;
Execution Count:856
856
2028 case MinuteSection: minute = newVal; break;
executed: break;
Execution Count:470
470
2029 case SecondSection: second = newVal; break;
executed: break;
Execution Count:434
434
2030 case MSecSection: msec = newVal; break;
executed: break;
Execution Count:36
36
2031 case YearSection2Digits: -
2032 case YearSection: year = newVal; break;
executed: break;
Execution Count:631
631
2033 case MonthSection: month = newVal; break;
executed: break;
Execution Count:62
62
2034 case DaySection: -
2035 case DayOfWeekSectionShort: -
2036 case DayOfWeekSectionLong: -
2037 if (newVal > 31) {
partially evaluated: newVal > 31
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:162
0-162
2038 -
2039 -
2040 -
2041 return false;
never executed: return false;
0
2042 } -
2043 day = newVal; -
2044 break;
executed: break;
Execution Count:162
162
2045 case AmPmSection: hour = (newVal == 0 ? hour % 12 : (hour % 12) + 12); break;
evaluated: newVal == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
executed: break;
Execution Count:6
2-6
2046 default: -
2047 QMessageLogger("tools/qdatetime.cpp", 4270, __PRETTY_FUNCTION__).warning("QDateTimeParser::setDigit() Internal error (%s)", -
2048 QString(sectionName(node.type)).toLocal8Bit().constData()); -
2049 break;
never executed: break;
0
2050 } -
2051 -
2052 if (!(node.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) {
evaluated: !(node.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))
TRUEFALSE
yes
Evaluation Count:2495
yes
Evaluation Count:162
162-2495
2053 if (day < cachedDay)
evaluated: day < cachedDay
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2486
9-2486
2054 day = cachedDay;
executed: day = cachedDay;
Execution Count:9
9
2055 const int max = QDate(year, month, 1).daysInMonth(); -
2056 if (day > max) {
evaluated: day > max
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:2435
60-2435
2057 day = max; -
2058 }
executed: }
Execution Count:60
60
2059 }
executed: }
Execution Count:2495
2495
2060 if (QDate::isValid(year, month, day) && QTime::isValid(hour, minute, second, msec)) {
evaluated: QDate::isValid(year, month, day)
TRUEFALSE
yes
Evaluation Count:2618
yes
Evaluation Count:39
partially evaluated: QTime::isValid(hour, minute, second, msec)
TRUEFALSE
yes
Evaluation Count:2618
no
Evaluation Count:0
0-2618
2061 v = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), spec); -
2062 return true;
executed: return true;
Execution Count:2618
2618
2063 } -
2064 return false;
executed: return false;
Execution Count:39
39
2065} -
2066int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const -
2067{ -
2068 const SectionNode &sn = sectionNode(s); -
2069 switch (sn.type) { -
2070 case Hour24Section: -
2071 case Hour12Section: return 23;
executed: return 23;
Execution Count:2705
2705
2072 -
2073 -
2074 case MinuteSection: -
2075 case SecondSection: return 59;
executed: return 59;
Execution Count:4210
4210
2076 case MSecSection: return 999;
executed: return 999;
Execution Count:241
241
2077 case YearSection2Digits: -
2078 case YearSection: return 9999;
executed: return 9999;
Execution Count:2220
2220
2079 -
2080 -
2081 -
2082 case MonthSection: return 12;
executed: return 12;
Execution Count:1065
1065
2083 case DaySection: -
2084 case DayOfWeekSectionShort: -
2085 case DayOfWeekSectionLong: return cur.isValid() ? cur.date().daysInMonth() : 31;
executed: return cur.isValid() ? cur.date().daysInMonth() : 31;
Execution Count:1834
1834
2086 case AmPmSection: return 1;
executed: return 1;
Execution Count:6
6
2087 default: break;
never executed: break;
0
2088 } -
2089 QMessageLogger("tools/qdatetime.cpp", 4321, __PRETTY_FUNCTION__).warning("QDateTimeParser::absoluteMax() Internal error (%s)", -
2090 QString(sectionName(sn.type)).toLocal8Bit().constData()); -
2091 return -1;
never executed: return -1;
0
2092} -
2093 -
2094 -
2095 -
2096 -
2097 -
2098 -
2099 -
2100int QDateTimeParser::absoluteMin(int s) const -
2101{ -
2102 const SectionNode &sn = sectionNode(s); -
2103 switch (sn.type) { -
2104 case Hour24Section: -
2105 case Hour12Section: -
2106 case MinuteSection: -
2107 case SecondSection: -
2108 case MSecSection: -
2109 case YearSection2Digits: -
2110 case YearSection: return 0;
executed: return 0;
Execution Count:9350
9350
2111 case MonthSection: -
2112 case DaySection: -
2113 case DayOfWeekSectionShort: -
2114 case DayOfWeekSectionLong: return 1;
executed: return 1;
Execution Count:2871
2871
2115 case AmPmSection: return 0;
executed: return 0;
Execution Count:6
6
2116 default: break;
never executed: break;
0
2117 } -
2118 QMessageLogger("tools/qdatetime.cpp", 4350, __PRETTY_FUNCTION__).warning("QDateTimeParser::absoluteMin() Internal error (%s, %0x)", -
2119 QString(sectionName(sn.type)).toLocal8Bit().constData(), sn.type); -
2120 return -1;
never executed: return -1;
0
2121} -
2122 -
2123 -
2124 -
2125 -
2126 -
2127 -
2128 -
2129const QDateTimeParser::SectionNode &QDateTimeParser::sectionNode(int sectionIndex) const -
2130{ -
2131 if (sectionIndex < 0) {
evaluated: sectionIndex < 0
TRUEFALSE
yes
Evaluation Count:237
yes
Evaluation Count:108525
237-108525
2132 switch (sectionIndex) { -
2133 case FirstSectionIndex: -
2134 return first;
executed: return first;
Execution Count:122
122
2135 case LastSectionIndex: -
2136 return last;
executed: return last;
Execution Count:4
4
2137 case NoSectionIndex: -
2138 return none;
executed: return none;
Execution Count:111
111
2139 } -
2140 } else if (sectionIndex < sectionNodes.size()) {
never executed: }
partially evaluated: sectionIndex < sectionNodes.size()
TRUEFALSE
yes
Evaluation Count:108525
no
Evaluation Count:0
0-108525
2141 return sectionNodes.at(sectionIndex);
executed: return sectionNodes.at(sectionIndex);
Execution Count:108525
108525
2142 } -
2143 -
2144 QMessageLogger("tools/qdatetime.cpp", 4376, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionNode() Internal error (%d)", -
2145 sectionIndex); -
2146 return none;
never executed: return none;
0
2147} -
2148 -
2149QDateTimeParser::Section QDateTimeParser::sectionType(int sectionIndex) const -
2150{ -
2151 return sectionNode(sectionIndex).type;
executed: return sectionNode(sectionIndex).type;
Execution Count:4768
4768
2152} -
2153int QDateTimeParser::sectionPos(int sectionIndex) const -
2154{ -
2155 return sectionPos(sectionNode(sectionIndex));
executed: return sectionPos(sectionNode(sectionIndex));
Execution Count:37116
37116
2156} -
2157 -
2158int QDateTimeParser::sectionPos(const SectionNode &sn) const -
2159{ -
2160 switch (sn.type) { -
2161 case FirstSection: return 0;
executed: return 0;
Execution Count:63
63
2162 case LastSection: return displayText().size() - 1;
never executed: return displayText().size() - 1;
0
2163 default: break;
executed: break;
Execution Count:38940
38940
2164 } -
2165 if (sn.pos == -1) {
partially evaluated: sn.pos == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:38940
0-38940
2166 QMessageLogger("tools/qdatetime.cpp", 4406, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionPos Internal error (%s)", QString(sectionName(sn.type)).toLocal8Bit().constData()); -
2167 return -1;
never executed: return -1;
0
2168 } -
2169 return sn.pos;
executed: return sn.pos;
Execution Count:38940
38940
2170} -
2171static QString unquote(const QString &str) -
2172{ -
2173 const QChar quote(QLatin1Char('\'')); -
2174 const QChar slash(QLatin1Char('\\')); -
2175 const QChar zero(QLatin1Char('0')); -
2176 QString ret; -
2177 QChar status(zero); -
2178 const int max = str.size(); -
2179 for (int i=0; i<max; ++i) {
evaluated: i<max
TRUEFALSE
yes
Evaluation Count:460
yes
Evaluation Count:417
417-460
2180 if (str.at(i) == quote) {
evaluated: str.at(i) == quote
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:413
47-413
2181 if (status != quote) {
evaluated: status != quote
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:23
23-24
2182 status = quote; -
2183 } else if (!ret.isEmpty() && str.at(i - 1) == slash) {
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
executed: }
Execution Count:24
0-24
2184 ret[ret.size() - 1] = quote; -
2185 } else {
never executed: }
0
2186 status = zero; -
2187 }
executed: }
Execution Count:23
23
2188 } else { -
2189 ret += str.at(i); -
2190 }
executed: }
Execution Count:413
413
2191 } -
2192 return ret;
executed: return ret;
Execution Count:417
417
2193} -
2194static inline int countRepeat(const QString &str, int index, int maxCount) -
2195{ -
2196 int count = 1; -
2197 const QChar ch(str.at(index)); -
2198 const int max = qMin(index + maxCount, str.size()); -
2199 while (index + count < max && str.at(index + count) == ch) {
evaluated: index + count < max
TRUEFALSE
yes
Evaluation Count:3496
yes
Evaluation Count:1198
evaluated: str.at(index + count) == ch
TRUEFALSE
yes
Evaluation Count:2662
yes
Evaluation Count:834
834-3496
2200 ++count; -
2201 }
executed: }
Execution Count:2662
2662
2202 return count;
executed: return count;
Execution Count:2032
2032
2203} -
2204 -
2205static inline void appendSeparator(QStringList *list, const QString &string, int from, int size, int lastQuote) -
2206{ -
2207 QString str(string.mid(from, size)); -
2208 if (lastQuote >= from)
evaluated: lastQuote >= from
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:1720
21-1720
2209 str = unquote(str);
executed: str = unquote(str);
Execution Count:21
21
2210 list->append(str); -
2211}
executed: }
Execution Count:1741
1741
2212 -
2213 -
2214bool QDateTimeParser::parseFormat(const QString &newFormat) -
2215{ -
2216 const QLatin1Char quote('\''); -
2217 const QLatin1Char slash('\\'); -
2218 const QLatin1Char zero('0'); -
2219 if (newFormat == displayFormat && !newFormat.isEmpty()) {
evaluated: newFormat == displayFormat
TRUEFALSE
yes
Evaluation Count:124
yes
Evaluation Count:561
evaluated: !newFormat.isEmpty()
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:2
2-561
2220 return true;
executed: return true;
Execution Count:122
122
2221 } -
2222 -
2223 if (false) QMessageLogger("tools/qdatetime.cpp", 4481, __PRETTY_FUNCTION__).debug("parseFormat: %s", newFormat.toLatin1().constData());
never executed: QMessageLogger("tools/qdatetime.cpp", 4481, __PRETTY_FUNCTION__).debug("parseFormat: %s", newFormat.toLatin1().constData());
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:563
0-563
2224 -
2225 QVector<SectionNode> newSectionNodes; -
2226 Sections newDisplay = 0; -
2227 QStringList newSeparators; -
2228 int i, index = 0; -
2229 int add = 0; -
2230 QChar status(zero); -
2231 const int max = newFormat.size(); -
2232 int lastQuote = -1; -
2233 for (i = 0; i<max; ++i) {
evaluated: i<max
TRUEFALSE
yes
Evaluation Count:3723
yes
Evaluation Count:563
563-3723
2234 if (newFormat.at(i) == quote) {
evaluated: newFormat.at(i) == quote
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:3676
47-3676
2235 lastQuote = i; -
2236 ++add; -
2237 if (status != quote) {
evaluated: status != quote
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:23
23-24
2238 status = quote; -
2239 } 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
2240 status = zero; -
2241 }
executed: }
Execution Count:23
23
2242 } else if (status != quote) {
evaluated: status != quote
TRUEFALSE
yes
Evaluation Count:3612
yes
Evaluation Count:64
64-3612
2243 const char sect = newFormat.at(i).toLatin1(); -
2244 switch (sect) { -
2245 case 'H': -
2246 case 'h': -
2247 if (parserType != QVariant::Date) {
evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:277
yes
Evaluation Count:3
3-277
2248 const Section hour = (sect == 'h') ? Hour12Section : Hour24Section;
evaluated: (sect == 'h')
TRUEFALSE
yes
Evaluation Count:206
yes
Evaluation Count:71
71-206
2249 const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 }; -
2250 newSectionNodes.append(sn); -
2251 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); -
2252 i += sn.count - 1; -
2253 index = i + 1; -
2254 newDisplay |= hour; -
2255 }
executed: }
Execution Count:277
277
2256 break;
executed: break;
Execution Count:280
280
2257 case 'm': -
2258 if (parserType != QVariant::Date) {
partially evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:257
no
Evaluation Count:0
0-257
2259 const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 }; -
2260 newSectionNodes.append(sn); -
2261 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); -
2262 i += sn.count - 1; -
2263 index = i + 1; -
2264 newDisplay |= MinuteSection; -
2265 }
executed: }
Execution Count:257
257
2266 break;
executed: break;
Execution Count:257
257
2267 case 's': -
2268 if (parserType != QVariant::Date) {
partially evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:236
no
Evaluation Count:0
0-236
2269 const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 }; -
2270 newSectionNodes.append(sn); -
2271 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); -
2272 i += sn.count - 1; -
2273 index = i + 1; -
2274 newDisplay |= SecondSection; -
2275 }
executed: }
Execution Count:236
236
2276 break;
executed: break;
Execution Count:236
236
2277 -
2278 case 'z': -
2279 if (parserType != QVariant::Date) {
partially evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:51
no
Evaluation Count:0
0-51
2280 const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 }; -
2281 newSectionNodes.append(sn); -
2282 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); -
2283 i += sn.count - 1; -
2284 index = i + 1; -
2285 newDisplay |= MSecSection; -
2286 }
executed: }
Execution Count:51
51
2287 break;
executed: break;
Execution Count:51
51
2288 case 'A': -
2289 case 'a': -
2290 if (parserType != QVariant::Date) {
evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:94
yes
Evaluation Count:2
2-94
2291 const bool cap = (sect == 'A'); -
2292 const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 }; -
2293 newSectionNodes.append(sn); -
2294 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); -
2295 newDisplay |= AmPmSection; -
2296 if (i + 1 < newFormat.size()
evaluated: i + 1 < newFormat.size()
TRUEFALSE
yes
Evaluation Count:93
yes
Evaluation Count:1
1-93
2297 && newFormat.at(i+1) == (cap ? QLatin1Char('P') : QLatin1Char('p'))) {
partially evaluated: newFormat.at(i+1) == (cap ? QLatin1Char('P') : QLatin1Char('p'))
TRUEFALSE
yes
Evaluation Count:93
no
Evaluation Count:0
evaluated: cap
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:76
0-93
2298 ++i; -
2299 }
executed: }
Execution Count:93
93
2300 index = i + 1; -
2301 }
executed: }
Execution Count:94
94
2302 break;
executed: break;
Execution Count:96
96
2303 case 'y': -
2304 if (parserType != QVariant::Time) {
evaluated: parserType != QVariant::Time
TRUEFALSE
yes
Evaluation Count:397
yes
Evaluation Count:4
4-397
2305 const int repeat = countRepeat(newFormat, i, 4); -
2306 if (repeat >= 2) {
evaluated: repeat >= 2
TRUEFALSE
yes
Evaluation Count:390
yes
Evaluation Count:7
7-390
2307 const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits, -
2308 i - add, repeat == 4 ? 4 : 2, 0 }; -
2309 newSectionNodes.append(sn); -
2310 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); -
2311 i += sn.count - 1; -
2312 index = i + 1; -
2313 newDisplay |= sn.type; -
2314 }
executed: }
Execution Count:390
390
2315 }
executed: }
Execution Count:397
397
2316 break;
executed: break;
Execution Count:401
401
2317 case 'M': -
2318 if (parserType != QVariant::Time) {
partially evaluated: parserType != QVariant::Time
TRUEFALSE
yes
Evaluation Count:396
no
Evaluation Count:0
0-396
2319 const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 }; -
2320 newSectionNodes.append(sn); -
2321 newSeparators.append(unquote(newFormat.mid(index, i - index))); -
2322 i += sn.count - 1; -
2323 index = i + 1; -
2324 newDisplay |= MonthSection; -
2325 }
executed: }
Execution Count:396
396
2326 break;
executed: break;
Execution Count:396
396
2327 case 'd': -
2328 if (parserType != QVariant::Time) {
partially evaluated: parserType != QVariant::Time
TRUEFALSE
yes
Evaluation Count:418
no
Evaluation Count:0
0-418
2329 const int repeat = countRepeat(newFormat, i, 4); -
2330 const Section sectionType = (repeat == 4 ? DayOfWeekSectionLong
evaluated: repeat == 4
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:397
21-397
2331 : (repeat == 3 ? DayOfWeekSectionShort : DaySection)); -
2332 const SectionNode sn = { sectionType, i - add, repeat, 0 }; -
2333 newSectionNodes.append(sn); -
2334 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); -
2335 i += sn.count - 1; -
2336 index = i + 1; -
2337 newDisplay |= sn.type; -
2338 }
executed: }
Execution Count:418
418
2339 break;
executed: break;
Execution Count:418
418
2340 -
2341 default: -
2342 break;
executed: break;
Execution Count:1477
1477
2343 } -
2344 }
executed: }
Execution Count:3612
3612
2345 } -
2346 if (newSectionNodes.isEmpty() && context == DateTimeEdit) {
evaluated: newSectionNodes.isEmpty()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:552
evaluated: context == DateTimeEdit
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:9
2-552
2347 return false;
executed: return false;
Execution Count:2
2
2348 } -
2349 -
2350 if ((newDisplay & (AmPmSection|Hour12Section)) == Hour12Section) {
evaluated: (newDisplay & (AmPmSection|Hour12Section)) == Hour12Section
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:456
105-456
2351 const int max = newSectionNodes.size(); -
2352 for (int i=0; i<max; ++i) {
evaluated: i<max
TRUEFALSE
yes
Evaluation Count:435
yes
Evaluation Count:105
105-435
2353 SectionNode &node = newSectionNodes[i]; -
2354 if (node.type == Hour12Section)
evaluated: node.type == Hour12Section
TRUEFALSE
yes
Evaluation Count:118
yes
Evaluation Count:317
118-317
2355 node.type = Hour24Section;
executed: node.type = Hour24Section;
Execution Count:118
118
2356 }
executed: }
Execution Count:435
435
2357 }
executed: }
Execution Count:105
105
2358 -
2359 if (index < newFormat.size()) {
evaluated: index < newFormat.size()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:543
18-543
2360 appendSeparator(&newSeparators, newFormat, index, index - max, lastQuote); -
2361 } else {
executed: }
Execution Count:18
18
2362 newSeparators.append(QString()); -
2363 }
executed: }
Execution Count:543
543
2364 -
2365 displayFormat = newFormat; -
2366 separators = newSeparators; -
2367 sectionNodes = newSectionNodes; -
2368 display = newDisplay; -
2369 last.pos = -1; -
2370 -
2371 -
2372 -
2373 -
2374 -
2375 if (false) QMessageLogger("tools/qdatetime.cpp", 4633, __PRETTY_FUNCTION__).debug() << newFormat << displayFormat;
never executed: QMessageLogger("tools/qdatetime.cpp", 4633, __PRETTY_FUNCTION__).debug() << newFormat << displayFormat;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:561
0-561
2376 if (false) QMessageLogger("tools/qdatetime.cpp", 4634, __PRETTY_FUNCTION__).debug("separators:\n'%s'", separators.join(QLatin1String("\n")).toLatin1().constData());
never executed: QMessageLogger("tools/qdatetime.cpp", 4634, __PRETTY_FUNCTION__).debug("separators:\n'%s'", separators.join(QLatin1String("\n")).toLatin1().constData());
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:561
0-561
2377 -
2378 return true;
executed: return true;
Execution Count:561
561
2379} -
2380 -
2381 -
2382 -
2383 -
2384 -
2385 -
2386 -
2387int QDateTimeParser::sectionSize(int sectionIndex) const -
2388{ -
2389 if (sectionIndex < 0)
partially evaluated: sectionIndex < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14087
0-14087
2390 return 0;
never executed: return 0;
0
2391 -
2392 if (sectionIndex >= sectionNodes.size()) {
partially evaluated: sectionIndex >= sectionNodes.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14087
0-14087
2393 QMessageLogger("tools/qdatetime.cpp", 4651, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionSize Internal error (%d)", sectionIndex); -
2394 return -1;
never executed: return -1;
0
2395 } -
2396 -
2397 if (sectionIndex == sectionNodes.size() - 1) {
evaluated: sectionIndex == sectionNodes.size() - 1
TRUEFALSE
yes
Evaluation Count:3539
yes
Evaluation Count:10548
3539-10548
2398 -
2399 -
2400 -
2401 -
2402 int sizeAdjustment = 0; -
2403 if (displayText().size() != text.size()) {
evaluated: displayText().size() != text.size()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:3524
15-3524
2404 -
2405 int preceedingZeroesAdded = 0; -
2406 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
2407 for (QVector<SectionNode>::ConstIterator sectionIt = sectionNodes.constBegin(); -
2408 sectionIt != sectionNodes.constBegin() + sectionIndex; ++sectionIt) {
evaluated: sectionIt != sectionNodes.constBegin() + sectionIndex
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:15
15-24
2409 preceedingZeroesAdded += sectionIt->zeroesAdded; -
2410 }
executed: }
Execution Count:24
24
2411 }
executed: }
Execution Count:15
15
2412 sizeAdjustment = preceedingZeroesAdded; -
2413 }
executed: }
Execution Count:15
15
2414 -
2415 return displayText().size() + sizeAdjustment - sectionPos(sectionIndex) - separators.last().size();
executed: return displayText().size() + sizeAdjustment - sectionPos(sectionIndex) - separators.last().size();
Execution Count:3539
3539
2416 } else { -
2417 return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex) 10548
2418 - separators.at(sectionIndex + 1).size();
executed: return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex) - separators.at(sectionIndex + 1).size();
Execution Count:10548
10548
2419 } -
2420} -
2421 -
2422 -
2423int QDateTimeParser::sectionMaxSize(Section s, int count) const -
2424{ -
2425 -
2426 int mcount = 12; -
2427 -
2428 -
2429 switch (s) { -
2430 case FirstSection: -
2431 case NoSection: -
2432 case LastSection: return 0;
never executed: return 0;
0
2433 -
2434 case AmPmSection: { -
2435 const int lowerMax = qMin(getAmPmText(AmText, LowerCase).size(), -
2436 getAmPmText(PmText, LowerCase).size()); -
2437 const int upperMax = qMin(getAmPmText(AmText, UpperCase).size(), -
2438 getAmPmText(PmText, UpperCase).size()); -
2439 return qMin(4, qMin(lowerMax, upperMax));
executed: return qMin(4, qMin(lowerMax, upperMax));
Execution Count:1728
1728
2440 } -
2441 -
2442 case Hour24Section: -
2443 case Hour12Section: -
2444 case MinuteSection: -
2445 case SecondSection: -
2446 case DaySection: return 2;
executed: return 2;
Execution Count:7925
7925
2447 case DayOfWeekSectionShort: -
2448 case DayOfWeekSectionLong: -
2449 -
2450 -
2451 -
2452 mcount = 7; -
2453 -
2454 -
2455 case MonthSection:
code before this statement executed: case MonthSection:
Execution Count:29
29
2456 if (count <= 2)
evaluated: count <= 2
TRUEFALSE
yes
Evaluation Count:1061
yes
Evaluation Count:816
816-1061
2457 return 2;
executed: return 2;
Execution Count:1061
1061
2458 -
2459 -
2460 -
2461 -
2462 { -
2463 int ret = 0; -
2464 const QLocale l = locale(); -
2465 for (int i=1; i<=mcount; ++i) {
evaluated: i<=mcount
TRUEFALSE
yes
Evaluation Count:9647
yes
Evaluation Count:816
816-9647
2466 const QString str = (s == MonthSection
evaluated: s == MonthSection
TRUEFALSE
yes
Evaluation Count:9444
yes
Evaluation Count:203
203-9444
2467 ? l.monthName(i, count == 4 ? QLocale::LongFormat : QLocale::ShortFormat) -
2468 : l.dayName(i, count == 4 ? QLocale::LongFormat : QLocale::ShortFormat)); -
2469 ret = qMax(str.size(), ret); -
2470 }
executed: }
Execution Count:9647
9647
2471 return ret;
executed: return ret;
Execution Count:816
816
2472 } -
2473 -
2474 case MSecSection: return 3;
executed: return 3;
Execution Count:269
269
2475 case YearSection: return 4;
executed: return 4;
Execution Count:1200
1200
2476 case YearSection2Digits: return 2;
executed: return 2;
Execution Count:670
670
2477 -
2478 case CalendarPopupSection: -
2479 case Internal: -
2480 case TimeSectionMask: -
2481 case DateSectionMask: -
2482 QMessageLogger("tools/qdatetime.cpp", 4740, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionMaxSize: Invalid section %s", -
2483 sectionName(s).toLatin1().constData()); -
2484 -
2485 case NoSectionIndex: -
2486 case FirstSectionIndex: -
2487 case LastSectionIndex: -
2488 case CalendarPopupIndex: -
2489 -
2490 break;
never executed: break;
0
2491 } -
2492 return -1;
never executed: return -1;
0
2493} -
2494 -
2495 -
2496int QDateTimeParser::sectionMaxSize(int index) const -
2497{ -
2498 const SectionNode &sn = sectionNode(index); -
2499 return sectionMaxSize(sn.type, sn.count);
executed: return sectionMaxSize(sn.type, sn.count);
Execution Count:13669
13669
2500} -
2501QString QDateTimeParser::sectionText(const QString &text, int sectionIndex, int index) const -
2502{ -
2503 const SectionNode &sn = sectionNode(sectionIndex); -
2504 switch (sn.type) { -
2505 case NoSectionIndex: -
2506 case FirstSectionIndex: -
2507 case LastSectionIndex: -
2508 return QString();
never executed: return QString();
0
2509 default: break;
executed: break;
Execution Count:129
129
2510 } -
2511 -
2512 return text.mid(index, sectionSize(sectionIndex));
executed: return text.mid(index, sectionSize(sectionIndex));
Execution Count:129
129
2513} -
2514 -
2515QString QDateTimeParser::sectionText(int sectionIndex) const -
2516{ -
2517 const SectionNode &sn = sectionNode(sectionIndex); -
2518 switch (sn.type) { -
2519 case NoSectionIndex: -
2520 case FirstSectionIndex: -
2521 case LastSectionIndex: -
2522 return QString();
never executed: return QString();
0
2523 default: break;
executed: break;
Execution Count:24
24
2524 } -
2525 -
2526 return displayText().mid(sn.pos, sectionSize(sectionIndex));
executed: return displayText().mid(sn.pos, sectionSize(sectionIndex));
Execution Count:24
24
2527} -
2528int QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionIndex, -
2529 QString &text, int &cursorPosition, int index, -
2530 State &state, int *usedptr) const -
2531{ -
2532 state = Invalid; -
2533 int num = 0; -
2534 const SectionNode &sn = sectionNode(sectionIndex); -
2535 if ((sn.type & Internal) == Internal) {
partially evaluated: (sn.type & Internal) == Internal
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11678
0-11678
2536 QMessageLogger("tools/qdatetime.cpp", 4814, __PRETTY_FUNCTION__).warning("QDateTimeParser::parseSection Internal error (%s %d)", -
2537 QString(sectionName(sn.type)).toLocal8Bit().constData(), sectionIndex); -
2538 return -1;
never executed: return -1;
0
2539 } -
2540 -
2541 const int sectionmaxsize = sectionMaxSize(sectionIndex); -
2542 QString sectiontext = text.mid(index, sectionmaxsize); -
2543 int sectiontextSize = sectiontext.size(); -
2544 -
2545 if (false) QMessageLogger("tools/qdatetime.cpp", 4823, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sectionName(sn.type)
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11678
0-11678
2546 << "with text" << text << "and st" << sectiontext 0
2547 << text.mid(index, sectionmaxsize) 0
2548 << index;
never executed: QMessageLogger("tools/qdatetime.cpp", 4823, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sectionName(sn.type) << "with text" << text << "and st" << sectiontext << text.mid(index, sectionmaxsize) << index;
0
2549 -
2550 int used = 0; -
2551 switch (sn.type) { -
2552 case AmPmSection: { -
2553 const int ampm = findAmPm(sectiontext, sectionIndex, &used); -
2554 switch (ampm) { -
2555 case AM: -
2556 case PM: -
2557 num = ampm; -
2558 state = Acceptable; -
2559 break;
executed: break;
Execution Count:862
862
2560 case PossibleAM: -
2561 case PossiblePM: -
2562 num = ampm - 2; -
2563 state = Intermediate; -
2564 break;
never executed: break;
0
2565 case PossibleBoth: -
2566 num = 0; -
2567 state = Intermediate; -
2568 break;
never executed: break;
0
2569 case Neither: -
2570 state = Invalid; -
2571 if (false) QMessageLogger("tools/qdatetime.cpp", 4849, __PRETTY_FUNCTION__).debug() << "invalid because findAmPm(" << sectiontext << ") returned -1";
never executed: QMessageLogger("tools/qdatetime.cpp", 4849, __PRETTY_FUNCTION__).debug() << "invalid because findAmPm(" << sectiontext << ") returned -1";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2572 break;
executed: break;
Execution Count:2
2
2573 default: -
2574 if (false) QMessageLogger("tools/qdatetime.cpp", 4852, __PRETTY_FUNCTION__).debug("This should never happen (findAmPm returned %d)", ampm);
never executed: QMessageLogger("tools/qdatetime.cpp", 4852, __PRETTY_FUNCTION__).debug("This should never happen (findAmPm returned %d)", ampm);
never evaluated: false
0
2575 break;
never executed: break;
0
2576 } -
2577 if (state != Invalid) {
evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:862
yes
Evaluation Count:2
2-862
2578 QString str = text; -
2579 text.replace(index, used, sectiontext.left(used)); -
2580 }
executed: }
Execution Count:862
862
2581 break; }
executed: break;
Execution Count:864
864
2582 case MonthSection: -
2583 case DayOfWeekSectionShort: -
2584 case DayOfWeekSectionLong: -
2585 if (sn.count >= 3) {
evaluated: sn.count >= 3
TRUEFALSE
yes
Evaluation Count:813
yes
Evaluation Count:1009
813-1009
2586 if (sn.type == MonthSection) {
evaluated: sn.type == MonthSection
TRUEFALSE
yes
Evaluation Count:784
yes
Evaluation Count:29
29-784
2587 int min = 1; -
2588 const QDate minDate = getMinimum().date(); -
2589 if (currentValue.date().year() == minDate.year()) {
evaluated: currentValue.date().year() == minDate.year()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:767
17-767
2590 min = minDate.month(); -
2591 }
executed: }
Execution Count:17
17
2592 num = findMonth(sectiontext.toLower(), min, sectionIndex, &sectiontext, &used); -
2593 } else {
executed: }
Execution Count:784
784
2594 num = findDay(sectiontext.toLower(), 1, sectionIndex, &sectiontext, &used); -
2595 }
executed: }
Execution Count:29
29
2596 -
2597 if (num != -1) {
evaluated: num != -1
TRUEFALSE
yes
Evaluation Count:807
yes
Evaluation Count:6
6-807
2598 state = (used == sectiontext.size() ? Acceptable : Intermediate);
evaluated: used == sectiontext.size()
TRUEFALSE
yes
Evaluation Count:700
yes
Evaluation Count:107
107-700
2599 QString str = text; -
2600 text.replace(index, used, sectiontext.left(used)); -
2601 } else {
executed: }
Execution Count:807
807
2602 state = Intermediate; -
2603 }
executed: }
Execution Count:6
6
2604 break; }
executed: break;
Execution Count:813
813
2605 -
2606 case DaySection: -
2607 case YearSection: -
2608 case YearSection2Digits: -
2609 case Hour12Section: -
2610 case Hour24Section: -
2611 case MinuteSection: -
2612 case SecondSection: -
2613 case MSecSection: { -
2614 if (sectiontextSize == 0) {
evaluated: sectiontextSize == 0
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:9984
17-9984
2615 num = 0; -
2616 used = 0; -
2617 state = Intermediate; -
2618 } else {
executed: }
Execution Count:17
17
2619 const int absMax = absoluteMax(sectionIndex); -
2620 QLocale loc; -
2621 bool ok = true; -
2622 int last = -1; -
2623 used = -1; -
2624 -
2625 QString digitsStr(sectiontext); -
2626 for (int i = 0; i < sectiontextSize; ++i) {
evaluated: i < sectiontextSize
TRUEFALSE
yes
Evaluation Count:21916
yes
Evaluation Count:9850
9850-21916
2627 if (digitsStr.at(i).isSpace()) {
evaluated: digitsStr.at(i).isSpace()
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:21782
134-21782
2628 sectiontextSize = i; -
2629 break;
executed: break;
Execution Count:134
134
2630 } -
2631 }
executed: }
Execution Count:21782
21782
2632 -
2633 const int max = qMin(sectionmaxsize, sectiontextSize); -
2634 for (int digits = max; digits >= 1; --digits) {
evaluated: digits >= 1
TRUEFALSE
yes
Evaluation Count:10640
yes
Evaluation Count:40
40-10640
2635 digitsStr.truncate(digits); -
2636 int tmp = (int)loc.toUInt(digitsStr, &ok); -
2637 if (ok && sn.type == Hour12Section) {
evaluated: ok
TRUEFALSE
yes
Evaluation Count:9952
yes
Evaluation Count:688
evaluated: sn.type == Hour12Section
TRUEFALSE
yes
Evaluation Count:823
yes
Evaluation Count:9129
688-9952
2638 if (tmp > 12) {
evaluated: tmp > 12
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:821
2-821
2639 tmp = -1; -
2640 ok = false; -
2641 } else if (tmp == 12) {
executed: }
Execution Count:2
evaluated: tmp == 12
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:721
2-721
2642 tmp = 0; -
2643 }
executed: }
Execution Count:100
100
2644 } -
2645 if (ok && tmp <= absMax) {
evaluated: ok
TRUEFALSE
yes
Evaluation Count:9950
yes
Evaluation Count:690
evaluated: tmp <= absMax
TRUEFALSE
yes
Evaluation Count:9944
yes
Evaluation Count:6
6-9950
2646 if (false) QMessageLogger("tools/qdatetime.cpp", 4924, __PRETTY_FUNCTION__).debug() << sectiontext.left(digits) << tmp << digits;
never executed: QMessageLogger("tools/qdatetime.cpp", 4924, __PRETTY_FUNCTION__).debug() << sectiontext.left(digits) << tmp << digits;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9944
0-9944
2647 last = tmp; -
2648 used = digits; -
2649 break;
executed: break;
Execution Count:9944
9944
2650 } -
2651 }
executed: }
Execution Count:696
696
2652 -
2653 if (last == -1) {
evaluated: last == -1
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:9944
40-9944
2654 QChar first(sectiontext.at(0)); -
2655 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
2656 used = 0; -
2657 state = Intermediate; -
2658 } else {
executed: }
Execution Count:38
38
2659 state = Invalid; -
2660 if (false) QMessageLogger("tools/qdatetime.cpp", 4938, __PRETTY_FUNCTION__).debug() << "invalid because" << sectiontext << "can't become a uint" << last << ok;
never executed: QMessageLogger("tools/qdatetime.cpp", 4938, __PRETTY_FUNCTION__).debug() << "invalid because" << sectiontext << "can't become a uint" << last << ok;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2661 }
executed: }
Execution Count:2
2
2662 } else { -
2663 num += last; -
2664 const FieldInfo fi = fieldInfo(sectionIndex); -
2665 const bool done = (used == sectionmaxsize); -
2666 if (!done && fi & Fraction) {
evaluated: !done
TRUEFALSE
yes
Evaluation Count:907
yes
Evaluation Count:9037
evaluated: fi & Fraction
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:827
80-9037
2667 for (int i=used; i<sectionmaxsize; ++i) {
evaluated: i<sectionmaxsize
TRUEFALSE
yes
Evaluation Count:152
yes
Evaluation Count:80
80-152
2668 num *= 10; -
2669 }
executed: }
Execution Count:152
152
2670 }
executed: }
Execution Count:80
80
2671 const int absMin = absoluteMin(sectionIndex); -
2672 if (num < absMin) {
evaluated: num < absMin
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:9919
25-9919
2673 state = done ? Invalid : Intermediate;
evaluated: done
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:22
3-22
2674 if (done)
evaluated: done
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:22
3-22
2675 if (false) QMessageLogger("tools/qdatetime.cpp", 4953, __PRETTY_FUNCTION__).debug() << "invalid because" << num << "is less than absoluteMin" << absMin;
never executed: QMessageLogger("tools/qdatetime.cpp", 4953, __PRETTY_FUNCTION__).debug() << "invalid because" << num << "is less than absoluteMin" << absMin;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
2676 } else if (num > absMax) {
partially evaluated: num > absMax
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9919
executed: }
Execution Count:25
0-9919
2677 state = Intermediate; -
2678 } else if (!done && (fi & (FixedWidth|Numeric)) == (FixedWidth|Numeric)) {
evaluated: !done
TRUEFALSE
yes
Evaluation Count:885
yes
Evaluation Count:9034
evaluated: (fi & (FixedWidth|Numeric)) == (FixedWidth|Numeric)
TRUEFALSE
yes
Evaluation Count:322
yes
Evaluation Count:563
never executed: }
0-9034
2679 if (skipToNextSection(sectionIndex, currentValue, digitsStr)) {
evaluated: skipToNextSection(sectionIndex, currentValue, digitsStr)
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:313
9-313
2680 state = Acceptable; -
2681 const int missingZeroes = sectionmaxsize - digitsStr.size(); -
2682 text.insert(index, QString().fill(QLatin1Char('0'), missingZeroes)); -
2683 used = sectionmaxsize; -
2684 cursorPosition += missingZeroes; -
2685 ++(const_cast<QDateTimeParser*>(this)->sectionNodes[sectionIndex].zeroesAdded); -
2686 } else {
executed: }
Execution Count:9
9
2687 state = Intermediate;; -
2688 }
executed: }
Execution Count:313
313
2689 } else { -
2690 state = Acceptable; -
2691 }
executed: }
Execution Count:9597
9597
2692 } -
2693 } -
2694 break; }
executed: break;
Execution Count:10001
10001
2695 default: -
2696 QMessageLogger("tools/qdatetime.cpp", 4974, __PRETTY_FUNCTION__).warning("QDateTimeParser::parseSection Internal error (%s %d)", -
2697 QString(sectionName(sn.type)).toLocal8Bit().constData(), sectionIndex); -
2698 return -1;
never executed: return -1;
0
2699 } -
2700 -
2701 if (usedptr)
partially evaluated: usedptr
TRUEFALSE
yes
Evaluation Count:11678
no
Evaluation Count:0
0-11678
2702 *usedptr = used;
executed: *usedptr = used;
Execution Count:11678
11678
2703 -
2704 return (state != Invalid ? num : -1);
executed: return (state != Invalid ? num : -1);
Execution Count:11678
11678
2705} -
2706 -
2707 -
2708 -
2709 -
2710 -
2711 -
2712 -
2713QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPosition, -
2714 const QDateTime &currentValue, bool fixup) const -
2715{ -
2716 const QDateTime minimum = getMinimum(); -
2717 const QDateTime maximum = getMaximum(); -
2718 -
2719 State state = Acceptable; -
2720 -
2721 QDateTime newCurrentValue; -
2722 int pos = 0; -
2723 bool conflicts = false; -
2724 const int sectionNodesCount = sectionNodes.size(); -
2725 -
2726 if (false) QMessageLogger("tools/qdatetime.cpp", 5004, __PRETTY_FUNCTION__).debug() << "parse" << input;
never executed: QMessageLogger("tools/qdatetime.cpp", 5004, __PRETTY_FUNCTION__).debug() << "parse" << input;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3353
0-3353
2727 { -
2728 int year, month, day, hour12, hour, minute, second, msec, ampm, dayofweek, year2digits; -
2729 getDateFromJulianDay(currentValue.date().toJulianDay(), &year, &month, &day); -
2730 year2digits = year % 100; -
2731 hour = currentValue.time().hour(); -
2732 hour12 = -1; -
2733 minute = currentValue.time().minute(); -
2734 second = currentValue.time().second(); -
2735 msec = currentValue.time().msec(); -
2736 dayofweek = currentValue.date().dayOfWeek(); -
2737 -
2738 ampm = -1; -
2739 Sections isSet = NoSection; -
2740 int num; -
2741 State tmpstate; -
2742 -
2743 for (int index=0; state != Invalid && index<sectionNodesCount; ++index) {
evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:15019
yes
Evaluation Count:7
evaluated: index<sectionNodesCount
TRUEFALSE
yes
Evaluation Count:11684
yes
Evaluation Count:3335
7-15019
2744 if (QStringRef(&input, pos, separators.at(index).size()) != separators.at(index)) {
evaluated: QStringRef(&input, pos, separators.at(index).size()) != separators.at(index)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:11678
6-11678
2745 if (false) QMessageLogger("tools/qdatetime.cpp", 5023, __PRETTY_FUNCTION__).debug() << "invalid because" << input.mid(pos, separators.at(index).size())
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2746 << "!=" << separators.at(index) 0
2747 << index << pos << currentSectionIndex;
never executed: QMessageLogger("tools/qdatetime.cpp", 5023, __PRETTY_FUNCTION__).debug() << "invalid because" << input.mid(pos, separators.at(index).size()) << "!=" << separators.at(index) << index << pos << currentSectionIndex;
0
2748 state = Invalid; -
2749 goto end;
executed: goto end;
Execution Count:6
6
2750 } -
2751 pos += separators.at(index).size(); -
2752 sectionNodes[index].pos = pos; -
2753 int *current = 0; -
2754 const SectionNode sn = sectionNodes.at(index); -
2755 int used; -
2756 -
2757 num = parseSection(currentValue, index, input, cursorPosition, pos, tmpstate, &used); -
2758 if (false) QMessageLogger("tools/qdatetime.cpp", 5036, __PRETTY_FUNCTION__).debug() << "sectionValue" << sectionName(sectionType(index)) << input
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11678
0-11678
2759 << "pos" << pos << "used" << used << stateName(tmpstate);
never executed: QMessageLogger("tools/qdatetime.cpp", 5036, __PRETTY_FUNCTION__).debug() << "sectionValue" << sectionName(sectionType(index)) << input << "pos" << pos << "used" << used << stateName(tmpstate);
0
2760 if (fixup && tmpstate == Intermediate && used < sn.count) {
evaluated: fixup
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:11608
evaluated: tmpstate == Intermediate
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:50
evaluated: used < sn.count
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:1
1-11608
2761 const FieldInfo fi = fieldInfo(index); -
2762 if ((fi & (Numeric|FixedWidth)) == (Numeric|FixedWidth)) {
evaluated: (fi & (Numeric|FixedWidth)) == (Numeric|FixedWidth)
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:3
3-16
2763 const QString newText = QString::fromLatin1("%1").arg(num, sn.count, 10, QLatin1Char('0')); -
2764 input.replace(pos, used, newText); -
2765 used = sn.count; -
2766 }
executed: }
Execution Count:16
16
2767 }
executed: }
Execution Count:19
19
2768 pos += qMax(0, used); -
2769 -
2770 state = qMin<State>(state, tmpstate); -
2771 if (state == Intermediate && context == FromString) {
evaluated: state == Intermediate
TRUEFALSE
yes
Evaluation Count:1088
yes
Evaluation Count:10590
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1083
5-10590
2772 state = Invalid; -
2773 break;
executed: break;
Execution Count:5
5
2774 } -
2775 -
2776 if (false) QMessageLogger("tools/qdatetime.cpp", 5054, __PRETTY_FUNCTION__).debug() << index << sectionName(sectionType(index)) << "is set to"
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11673
0-11673
2777 << pos << "state is" << stateName(state);
never executed: QMessageLogger("tools/qdatetime.cpp", 5054, __PRETTY_FUNCTION__).debug() << index << sectionName(sectionType(index)) << "is set to" << pos << "state is" << stateName(state);
0
2778 -
2779 -
2780 if (state != Invalid) {
evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:11666
yes
Evaluation Count:7
7-11666
2781 switch (sn.type) { -
2782 case Hour24Section: current = &hour; break;
executed: break;
Execution Count:1127
1127
2783 case Hour12Section: current = &hour12; break;
executed: break;
Execution Count:821
821
2784 case MinuteSection: current = &minute; break;
executed: break;
Execution Count:1766
1766
2785 case SecondSection: current = &second; break;
executed: break;
Execution Count:1702
1702
2786 case MSecSection: current = &msec; break;
executed: break;
Execution Count:223
223
2787 case YearSection: current = &year; break;
executed: break;
Execution Count:1000
1000
2788 case YearSection2Digits: current = &year2digits; break;
executed: break;
Execution Count:646
646
2789 case MonthSection: current = &month; break;
executed: break;
Execution Count:1790
1790
2790 case DayOfWeekSectionShort: -
2791 case DayOfWeekSectionLong: current = &dayofweek; break;
executed: break;
Execution Count:28
28
2792 case DaySection: current = &day; num = qMax<int>(1, num); break;
executed: break;
Execution Count:1701
1701
2793 case AmPmSection: current = &ampm; break;
executed: break;
Execution Count:862
862
2794 default: -
2795 QMessageLogger("tools/qdatetime.cpp", 5073, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error (%s)", -
2796 QString(sectionName(sn.type)).toLocal8Bit().constData()); -
2797 break;
never executed: break;
0
2798 } -
2799 if (!current) {
partially evaluated: !current
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11666
0-11666
2800 QMessageLogger("tools/qdatetime.cpp", 5078, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 2"); -
2801 return StateNode();
never executed: return StateNode();
0
2802 } -
2803 if (isSet & sn.type && *current != num) {
evaluated: isSet & sn.type
TRUEFALSE
yes
Evaluation Count:531
yes
Evaluation Count:11135
evaluated: *current != num
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:430
101-11135
2804 if (false) QMessageLogger("tools/qdatetime.cpp", 5082, __PRETTY_FUNCTION__).debug() << "CONFLICT " << sectionName(sn.type) << *current << num;
never executed: QMessageLogger("tools/qdatetime.cpp", 5082, __PRETTY_FUNCTION__).debug() << "CONFLICT " << sectionName(sn.type) << *current << num;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:101
0-101
2805 conflicts = true; -
2806 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
2807 continue;
executed: continue;
Execution Count:96
96
2808 } -
2809 }
executed: }
Execution Count:5
5
2810 if (num != -1)
evaluated: num != -1
TRUEFALSE
yes
Evaluation Count:11565
yes
Evaluation Count:5
5-11565
2811 *current = num;
executed: *current = num;
Execution Count:11565
11565
2812 isSet |= sn.type; -
2813 }
executed: }
Execution Count:11570
11570
2814 }
executed: }
Execution Count:11577
11577
2815 -
2816 if (state != Invalid && QStringRef(&input, pos, input.size() - pos) != separators.last()) {
evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:3335
yes
Evaluation Count:12
evaluated: QStringRef(&input, pos, input.size() - pos) != separators.last()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:3321
12-3335
2817 if (false) QMessageLogger("tools/qdatetime.cpp", 5095, __PRETTY_FUNCTION__).debug() << "invalid because" << input.mid(pos)
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
2818 << "!=" << separators.last() << pos;
never executed: QMessageLogger("tools/qdatetime.cpp", 5095, __PRETTY_FUNCTION__).debug() << "invalid because" << input.mid(pos) << "!=" << separators.last() << pos;
0
2819 state = Invalid; -
2820 }
executed: }
Execution Count:14
14
2821 -
2822 if (state != Invalid) {
evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:3321
yes
Evaluation Count:26
26-3321
2823 if (parserType != QVariant::Time) {
evaluated: parserType != QVariant::Time
TRUEFALSE
yes
Evaluation Count:3299
yes
Evaluation Count:22
22-3299
2824 if (year % 100 != year2digits) {
evaluated: year % 100 != year2digits
TRUEFALSE
yes
Evaluation Count:115
yes
Evaluation Count:3184
115-3184
2825 switch (isSet & (YearSection2Digits|YearSection)) { -
2826 case YearSection2Digits: -
2827 year = (year / 100) * 100; -
2828 year += year2digits; -
2829 break;
executed: break;
Execution Count:31
31
2830 case ((uint)YearSection2Digits|(uint)YearSection): { -
2831 conflicts = true; -
2832 const SectionNode &sn = sectionNode(currentSectionIndex); -
2833 if (sn.type == YearSection2Digits) {
never evaluated: sn.type == YearSection2Digits
0
2834 year = (year / 100) * 100; -
2835 year += year2digits; -
2836 }
never executed: }
0
2837 break; }
never executed: break;
0
2838 default: -
2839 break;
executed: break;
Execution Count:84
84
2840 } -
2841 }
executed: }
Execution Count:115
115
2842 -
2843 const QDate date(year, month, day); -
2844 const int diff = dayofweek - date.dayOfWeek(); -
2845 if (diff != 0 && state == Acceptable && isSet & (DayOfWeekSectionShort|DayOfWeekSectionLong)) {
evaluated: diff != 0
TRUEFALSE
yes
Evaluation Count:150
yes
Evaluation Count:3149
evaluated: state == Acceptable
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:91
evaluated: isSet & (DayOfWeekSectionShort|DayOfWeekSectionLong)
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:46
13-3149
2846 conflicts = isSet & DaySection; -
2847 const SectionNode &sn = sectionNode(currentSectionIndex); -
2848 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
2849 -
2850 day += diff; -
2851 if (day <= 0) {
evaluated: day <= 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:6
6-7
2852 day += 7; -
2853 } 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
2854 day -= 7; -
2855 }
never executed: }
0
2856 if (false) QMessageLogger("tools/qdatetime.cpp", 5134, __PRETTY_FUNCTION__).debug() << year << month << day << dayofweek
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
2857 << diff << QDate(year, month, day).dayOfWeek();
never executed: QMessageLogger("tools/qdatetime.cpp", 5134, __PRETTY_FUNCTION__).debug() << year << month << day << dayofweek << diff << QDate(year, month, day).dayOfWeek();
0
2858 }
executed: }
Execution Count:13
13
2859 }
executed: }
Execution Count:13
13
2860 bool needfixday = false; -
2861 if (sectionType(currentSectionIndex) & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) {
evaluated: sectionType(currentSectionIndex) & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)
TRUEFALSE
yes
Evaluation Count:562
yes
Evaluation Count:2737
562-2737
2862 cachedDay = day; -
2863 } else if (cachedDay > day) {
executed: }
Execution Count:562
evaluated: cachedDay > day
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2734
3-2734
2864 day = cachedDay; -
2865 needfixday = true; -
2866 }
executed: }
Execution Count:3
3
2867 -
2868 if (!QDate::isValid(year, month, day)) {
evaluated: !QDate::isValid(year, month, day)
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:3258
41-3258
2869 if (day < 32) {
partially evaluated: day < 32
TRUEFALSE
yes
Evaluation Count:41
no
Evaluation Count:0
0-41
2870 cachedDay = day; -
2871 }
executed: }
Execution Count:41
41
2872 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
2873 needfixday = true; -
2874 }
executed: }
Execution Count:4
4
2875 }
executed: }
Execution Count:41
41
2876 if (needfixday) {
evaluated: needfixday
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3295
4-3295
2877 if (context == FromString) {
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
2878 state = Invalid; -
2879 goto end;
executed: goto end;
Execution Count:1
1
2880 } -
2881 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
2882 day = qMin<int>(day, QDate(year, month, 1).daysInMonth()); -
2883 -
2884 const QLocale loc = locale(); -
2885 for (int i=0; i<sectionNodesCount; ++i) {
evaluated: i<sectionNodesCount
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
3-6
2886 const Section thisSectionType = sectionType(i); -
2887 if (thisSectionType & (DaySection)) {
evaluated: thisSectionType & (DaySection)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
2888 input.replace(sectionPos(i), sectionSize(i), loc.toString(day)); -
2889 } 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
2890 const int dayOfWeek = QDate(year, month, day).dayOfWeek(); -
2891 const QLocale::FormatType dayFormat = (thisSectionType == DayOfWeekSectionShort
never evaluated: thisSectionType == DayOfWeekSectionShort
0
2892 ? QLocale::ShortFormat : QLocale::LongFormat); -
2893 const QString dayName(loc.dayName(dayOfWeek, dayFormat)); -
2894 input.replace(sectionPos(i), sectionSize(i), dayName); -
2895 }
never executed: }
0
2896 } -
2897 } else {
executed: }
Execution Count:3
3
2898 state = qMin(Intermediate, state); -
2899 }
never executed: }
0
2900 } -
2901 }
executed: }
Execution Count:3298
3298
2902 -
2903 if (parserType != QVariant::Date) {
evaluated: parserType != QVariant::Date
TRUEFALSE
yes
Evaluation Count:3268
yes
Evaluation Count:52
52-3268
2904 if (isSet & Hour12Section) {
evaluated: isSet & Hour12Section
TRUEFALSE
yes
Evaluation Count:809
yes
Evaluation Count:2459
809-2459
2905 const bool hasHour = isSet & Hour24Section; -
2906 if (ampm == -1) {
partially evaluated: ampm == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:809
0-809
2907 if (hasHour) {
never evaluated: hasHour
0
2908 ampm = (hour < 12 ? 0 : 1);
never evaluated: hour < 12
0
2909 } else {
never executed: }
0
2910 ampm = 0; -
2911 }
never executed: }
0
2912 } -
2913 hour12 = (ampm == 0 ? hour12 % 12 : (hour12 % 12) + 12);
evaluated: ampm == 0
TRUEFALSE
yes
Evaluation Count:731
yes
Evaluation Count:78
78-731
2914 if (!hasHour) {
evaluated: !hasHour
TRUEFALSE
yes
Evaluation Count:807
yes
Evaluation Count:2
2-807
2915 hour = hour12; -
2916 } else if (hour != hour12) {
executed: }
Execution Count:807
partially evaluated: hour != hour12
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-807
2917 conflicts = true; -
2918 }
never executed: }
0
2919 } else if (ampm != -1) {
evaluated: ampm != -1
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:2408
51-2408
2920 if (!(isSet & (Hour24Section))) {
evaluated: !(isSet & (Hour24Section))
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:48
3-48
2921 hour = (12 * ampm); -
2922 } else if ((ampm == 0) != (hour < 12)) {
partially evaluated: (ampm == 0) != (hour < 12)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:48
executed: }
Execution Count:3
0-48
2923 conflicts = true; -
2924 }
never executed: }
0
2925 } -
2926 -
2927 } -
2928 -
2929 newCurrentValue = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), spec); -
2930 if (false) QMessageLogger("tools/qdatetime.cpp", 5208, __PRETTY_FUNCTION__).debug() << year << month << day << hour << minute << second << msec;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3320
never executed: QMessageLogger("tools/qdatetime.cpp", 5208, __PRETTY_FUNCTION__).debug() << year << month << day << hour << minute << second << msec;
0-3320
2931 }
executed: }
Execution Count:3320
3320
2932 if (false) QMessageLogger("tools/qdatetime.cpp", 5210, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(),
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3346
0-3346
2933 newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), 0
2934 stateName(state).toLatin1().constData());
never executed: QMessageLogger("tools/qdatetime.cpp", 5210, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), stateName(state).toLatin1().constData());
0
2935 } -
2936end:
code before this statement executed: end:
Execution Count:3346
3346
2937 if (newCurrentValue.isValid()) {
evaluated: newCurrentValue.isValid()
TRUEFALSE
yes
Evaluation Count:3283
yes
Evaluation Count:70
70-3283
2938 if (context != FromString && state != Invalid && newCurrentValue < minimum) {
evaluated: context != FromString
TRUEFALSE
yes
Evaluation Count:3178
yes
Evaluation Count:105
partially evaluated: state != Invalid
TRUEFALSE
yes
Evaluation Count:3178
no
Evaluation Count:0
evaluated: newCurrentValue < minimum
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:3125
0-3178
2939 const QLatin1Char space(' '); -
2940 if (newCurrentValue >= minimum)
partially evaluated: newCurrentValue >= minimum
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:53
0-53
2941 QMessageLogger("tools/qdatetime.cpp", 5219, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 3 (%s %s)", 0
2942 QString(newCurrentValue.toString()).toLocal8Bit().constData(), QString(minimum.toString()).toLocal8Bit().constData());
never executed: QMessageLogger("tools/qdatetime.cpp", 5219, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 3 (%s %s)", QString(newCurrentValue.toString()).toLocal8Bit().constData(), QString(minimum.toString()).toLocal8Bit().constData());
0
2943 -
2944 bool done = false; -
2945 state = Invalid; -
2946 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
2947 const SectionNode &sn = sectionNodes.at(i); -
2948 QString t = sectionText(input, i, sn.pos).toLower(); -
2949 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
2950 || t.contains(space)) {
partially evaluated: t.contains(space)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:74
0-74
2951 switch (sn.type) { -
2952 case AmPmSection: -
2953 switch (findAmPm(t, i)) { -
2954 case AM: -
2955 case PM: -
2956 state = Acceptable; -
2957 done = true; -
2958 break;
never executed: break;
0
2959 case Neither: -
2960 state = Invalid; -
2961 done = true; -
2962 break;
never executed: break;
0
2963 case PossibleAM: -
2964 case PossiblePM: -
2965 case PossibleBoth: { -
2966 const QDateTime copy(newCurrentValue.addSecs(12 * 60 * 60)); -
2967 if (copy >= minimum && copy <= maximum) {
never evaluated: copy >= minimum
never evaluated: copy <= maximum
0
2968 state = Intermediate; -
2969 done = true; -
2970 }
never executed: }
0
2971 break; }
never executed: break;
0
2972 } -
2973 case MonthSection:
code before this statement never executed: case MonthSection:
0
2974 if (sn.count >= 3) {
partially evaluated: sn.count >= 3
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2975 int tmp = newCurrentValue.date().month(); -
2976 -
2977 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
2978 const QDateTime copy(newCurrentValue.addMonths(tmp - newCurrentValue.date().month())); -
2979 if (copy >= minimum && copy <= maximum)
partially evaluated: copy >= minimum
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
never evaluated: copy <= maximum
0-6
2980 break;
never executed: break;
0
2981 }
executed: }
Execution Count:6
6
2982 if (tmp == -1) {
partially evaluated: tmp == -1
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2983 break;
executed: break;
Execution Count:3
3
2984 } -
2985 state = Intermediate; -
2986 done = true; -
2987 break;
never executed: break;
0
2988 } -
2989 -
2990 default: { -
2991 int toMin; -
2992 int toMax; -
2993 -
2994 if (sn.type & TimeSectionMask) {
evaluated: sn.type & TimeSectionMask
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:32
20-32
2995 if (newCurrentValue.daysTo(minimum) != 0) {
partially evaluated: newCurrentValue.daysTo(minimum) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
2996 break;
never executed: break;
0
2997 } -
2998 toMin = newCurrentValue.time().msecsTo(minimum.time()); -
2999 if (newCurrentValue.daysTo(maximum) > 0) {
partially evaluated: newCurrentValue.daysTo(maximum) > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
3000 toMax = -1; -
3001 } else {
never executed: }
0
3002 toMax = newCurrentValue.time().msecsTo(maximum.time()); -
3003 }
executed: }
Execution Count:20
20
3004 } else { -
3005 toMin = newCurrentValue.daysTo(minimum); -
3006 toMax = newCurrentValue.daysTo(maximum); -
3007 }
executed: }
Execution Count:32
32
3008 const int maxChange = QDateTimeParser::maxChange(i); -
3009 if (toMin > maxChange) {
partially evaluated: toMin > maxChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:52
0-52
3010 if (false) QMessageLogger("tools/qdatetime.cpp", 5288, __PRETTY_FUNCTION__).debug() << "invalid because toMin > maxChange" << toMin
never evaluated: false
0
3011 << maxChange << t << newCurrentValue << minimum;
never executed: QMessageLogger("tools/qdatetime.cpp", 5288, __PRETTY_FUNCTION__).debug() << "invalid because toMin > maxChange" << toMin << maxChange << t << newCurrentValue << minimum;
0
3012 state = Invalid; -
3013 done = true; -
3014 break;
never executed: break;
0
3015 } else if (toMax > maxChange) {
evaluated: toMax > maxChange
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:38
14-38
3016 toMax = -1; -
3017 }
executed: }
Execution Count:14
14
3018 -
3019 const int min = getDigit(minimum, i); -
3020 if (min == -1) {
partially evaluated: min == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:52
0-52
3021 QMessageLogger("tools/qdatetime.cpp", 5299, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 4 (%s)", -
3022 QString(sectionName(sn.type)).toLocal8Bit().constData()); -
3023 state = Invalid; -
3024 done = true; -
3025 break;
never executed: break;
0
3026 } -
3027 -
3028 int max = toMax != -1 ? getDigit(maximum, i) : absoluteMax(i, newCurrentValue);
evaluated: toMax != -1
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:14
14-38
3029 int pos = cursorPosition - sn.pos; -
3030 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
3031 pos = -1;
executed: pos = -1;
Execution Count:45
45
3032 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
3033 if (false) QMessageLogger("tools/qdatetime.cpp", 5311, __PRETTY_FUNCTION__).debug() << "invalid because potentialValue(" << t.simplified() << min << max
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
3034 << sectionName(sn.type) << "returned" << toMax << toMin << pos;
never executed: QMessageLogger("tools/qdatetime.cpp", 5311, __PRETTY_FUNCTION__).debug() << "invalid because potentialValue(" << t.simplified() << min << max << sectionName(sn.type) << "returned" << toMax << toMin << pos;
0
3035 state = Invalid; -
3036 done = true; -
3037 break;
executed: break;
Execution Count:2
2
3038 } -
3039 state = Intermediate; -
3040 done = true; -
3041 break; }
executed: break;
Execution Count:50
50
3042 } -
3043 }
executed: }
Execution Count:55
55
3044 }
executed: }
Execution Count:129
129
3045 } else {
executed: }
Execution Count:53
53
3046 if (context == FromString) {
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:3125
105-3125
3047 -
3048 qt_noop(); -
3049 if (newCurrentValue.date().toJulianDay() > 4642999)
partially evaluated: newCurrentValue.date().toJulianDay() > 4642999
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:105
0-105
3050 state = Invalid;
never executed: state = Invalid;
0
3051 } else {
executed: }
Execution Count:105
105
3052 if (newCurrentValue > getMaximum())
evaluated: newCurrentValue > getMaximum()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3124
1-3124
3053 state = Invalid;
executed: state = Invalid;
Execution Count:1
1
3054 }
executed: }
Execution Count:3125
3125
3055 -
3056 if (false) QMessageLogger("tools/qdatetime.cpp", 5334, __PRETTY_FUNCTION__).debug() << "not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum();
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3230
never executed: QMessageLogger("tools/qdatetime.cpp", 5334, __PRETTY_FUNCTION__).debug() << "not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum();
0-3230
3057 }
executed: }
Execution Count:3230
3230
3058 } -
3059 StateNode node; -
3060 node.input = input; -
3061 node.state = state; -
3062 node.conflicts = conflicts; -
3063 node.value = newCurrentValue.toTimeSpec(spec); -
3064 text = input; -
3065 return node;
executed: return node;
Execution Count:3353
3353
3066} -
3067int QDateTimeParser::findMonth(const QString &str1, int startMonth, int sectionIndex, -
3068 QString *usedMonth, int *used) const -
3069{ -
3070 int bestMatch = -1; -
3071 int bestCount = 0; -
3072 if (!str1.isEmpty()) {
partially evaluated: !str1.isEmpty()
TRUEFALSE
yes
Evaluation Count:793
no
Evaluation Count:0
0-793
3073 const SectionNode &sn = sectionNode(sectionIndex); -
3074 if (sn.type != MonthSection) {
partially evaluated: sn.type != MonthSection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:793
0-793
3075 QMessageLogger("tools/qdatetime.cpp", 5362, __PRETTY_FUNCTION__).warning("QDateTimeParser::findMonth Internal error"); -
3076 return -1;
never executed: return -1;
0
3077 } -
3078 -
3079 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
3080 QLocale l = locale(); -
3081 -
3082 for (int month=startMonth; month<=12; ++month) {
evaluated: month<=12
TRUEFALSE
yes
Evaluation Count:2410
yes
Evaluation Count:118
118-2410
3083 QString str2 = l.monthName(month, type).toLower(); -
3084 -
3085 if (str1.startsWith(str2)) {
evaluated: str1.startsWith(str2)
TRUEFALSE
yes
Evaluation Count:672
yes
Evaluation Count:1738
672-1738
3086 if (used) {
partially evaluated: used
TRUEFALSE
yes
Evaluation Count:672
no
Evaluation Count:0
0-672
3087 if (false) QMessageLogger("tools/qdatetime.cpp", 5374, __PRETTY_FUNCTION__).debug() << "used is set to" << str2.size();
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:672
never executed: QMessageLogger("tools/qdatetime.cpp", 5374, __PRETTY_FUNCTION__).debug() << "used is set to" << str2.size();
0-672
3088 *used = str2.size(); -
3089 }
executed: }
Execution Count:672
672
3090 if (usedMonth)
partially evaluated: usedMonth
TRUEFALSE
yes
Evaluation Count:672
no
Evaluation Count:0
0-672
3091 *usedMonth = l.monthName(month, type);
executed: *usedMonth = l.monthName(month, type);
Execution Count:672
672
3092 -
3093 return month;
executed: return month;
Execution Count:672
672
3094 } -
3095 if (context == FromString)
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:148
yes
Evaluation Count:1590
148-1590
3096 continue;
executed: continue;
Execution Count:148
148
3097 -
3098 const int limit = qMin(str1.size(), str2.size()); -
3099 -
3100 if (false) QMessageLogger("tools/qdatetime.cpp", 5387, __PRETTY_FUNCTION__).debug() << "limit is" << limit << str1 << str2;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1590
never executed: QMessageLogger("tools/qdatetime.cpp", 5387, __PRETTY_FUNCTION__).debug() << "limit is" << limit << str1 << str2;
0-1590
3101 bool equal = true; -
3102 for (int i=0; i<limit; ++i) {
evaluated: i<limit
TRUEFALSE
yes
Evaluation Count:2254
yes
Evaluation Count:3
3-2254
3103 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
3104 equal = false; -
3105 if (i > bestCount) {
evaluated: i > bestCount
TRUEFALSE
yes
Evaluation Count:177
yes
Evaluation Count:1410
177-1410
3106 bestCount = i; -
3107 bestMatch = month; -
3108 }
executed: }
Execution Count:177
177
3109 break;
executed: break;
Execution Count:1587
1587
3110 } -
3111 }
executed: }
Execution Count:667
667
3112 if (equal) {
evaluated: equal
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1587
3-1587
3113 if (used)
partially evaluated: used
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
3114 *used = limit;
executed: *used = limit;
Execution Count:3
3
3115 if (usedMonth)
partially evaluated: usedMonth
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
3116 *usedMonth = l.monthName(month, type);
executed: *usedMonth = l.monthName(month, type);
Execution Count:3
3
3117 return month;
executed: return month;
Execution Count:3
3
3118 } -
3119 }
executed: }
Execution Count:1587
1587
3120 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
3121 *usedMonth = l.monthName(bestMatch, type);
executed: *usedMonth = l.monthName(bestMatch, type);
Execution Count:104
104
3122 }
executed: }
Execution Count:118
118
3123 if (used) {
evaluated: used
TRUEFALSE
yes
Evaluation Count:109
yes
Evaluation Count:9
9-109
3124 if (false) QMessageLogger("tools/qdatetime.cpp", 5411, __PRETTY_FUNCTION__).debug() << "used is set to" << bestCount;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:109
never executed: QMessageLogger("tools/qdatetime.cpp", 5411, __PRETTY_FUNCTION__).debug() << "used is set to" << bestCount;
0-109
3125 *used = bestCount; -
3126 }
executed: }
Execution Count:109
109
3127 return bestMatch;
executed: return bestMatch;
Execution Count:118
118
3128} -
3129 -
3130int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex, QString *usedDay, int *used) const -
3131{ -
3132 int bestMatch = -1; -
3133 int bestCount = 0; -
3134 if (!str1.isEmpty()) {
partially evaluated: !str1.isEmpty()
TRUEFALSE
yes
Evaluation Count:29
no
Evaluation Count:0
0-29
3135 const SectionNode &sn = sectionNode(sectionIndex); -
3136 if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) {
partially evaluated: !(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29
0-29
3137 QMessageLogger("tools/qdatetime.cpp", 5424, __PRETTY_FUNCTION__).warning("QDateTimeParser::findDay Internal error"); -
3138 return -1;
never executed: return -1;
0
3139 } -
3140 const QLocale l = locale(); -
3141 for (int day=startDay; day<=7; ++day) {
evaluated: day<=7
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:1
1-97
3142 const QString str2 = l.dayName(day, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat); -
3143 -
3144 if (str1.startsWith(str2.toLower())) {
evaluated: str1.startsWith(str2.toLower())
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:69
28-69
3145 if (used)
partially evaluated: used
TRUEFALSE
yes
Evaluation Count:28
no
Evaluation Count:0
0-28
3146 *used = str2.size();
executed: *used = str2.size();
Execution Count:28
28
3147 if (usedDay) {
partially evaluated: usedDay
TRUEFALSE
yes
Evaluation Count:28
no
Evaluation Count:0
0-28
3148 *usedDay = str2; -
3149 }
executed: }
Execution Count:28
28
3150 return day;
executed: return day;
Execution Count:28
28
3151 } -
3152 if (context == FromString)
evaluated: context == FromString
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:9
9-60
3153 continue;
executed: continue;
Execution Count:60
60
3154 -
3155 const int limit = qMin(str1.size(), str2.size()); -
3156 bool found = true; -
3157 for (int i=0; i<limit; ++i) {
partially evaluated: i<limit
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
3158 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
3159 if (i > bestCount) {
partially evaluated: i > bestCount
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
3160 bestCount = i; -
3161 bestMatch = day; -
3162 }
never executed: }
0
3163 found = false; -
3164 break;
executed: break;
Execution Count:9
9
3165 } -
3166 -
3167 }
never executed: }
0
3168 if (found) {
partially evaluated: found
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
3169 if (used)
never evaluated: used
0
3170 *used = limit;
never executed: *used = limit;
0
3171 if (usedDay)
never evaluated: usedDay
0
3172 *usedDay = str2;
never executed: *usedDay = str2;
0
3173 -
3174 return day;
never executed: return day;
0
3175 } -
3176 }
executed: }
Execution Count:9
9
3177 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
3178 *usedDay = l.dayName(bestMatch, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat); -
3179 }
never executed: }
0
3180 }
executed: }
Execution Count:1
1
3181 if (used)
partially evaluated: used
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
3182 *used = bestCount;
executed: *used = bestCount;
Execution Count:1
1
3183 -
3184 return bestMatch;
executed: return bestMatch;
Execution Count:1
1
3185} -
3186int QDateTimeParser::findAmPm(QString &str, int index, int *used) const -
3187{ -
3188 const SectionNode &s = sectionNode(index); -
3189 if (s.type != AmPmSection) {
partially evaluated: s.type != AmPmSection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:864
0-864
3190 QMessageLogger("tools/qdatetime.cpp", 5492, __PRETTY_FUNCTION__).warning("QDateTimeParser::findAmPm Internal error"); -
3191 return -1;
never executed: return -1;
0
3192 } -
3193 if (used)
partially evaluated: used
TRUEFALSE
yes
Evaluation Count:864
no
Evaluation Count:0
0-864
3194 *used = str.size();
executed: *used = str.size();
Execution Count:864
864
3195 if (str.trimmed().isEmpty()) {
partially evaluated: str.trimmed().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:864
0-864
3196 return PossibleBoth;
never executed: return PossibleBoth;
0
3197 } -
3198 const QLatin1Char space(' '); -
3199 int size = sectionMaxSize(index); -
3200 -
3201 enum { -
3202 amindex = 0, -
3203 pmindex = 1 -
3204 }; -
3205 QString ampm[2]; -
3206 ampm[amindex] = getAmPmText(AmText, s.count == 1 ? UpperCase : LowerCase); -
3207 ampm[pmindex] = getAmPmText(PmText, s.count == 1 ? UpperCase : LowerCase); -
3208 for (int i=0; i<2; ++i)
evaluated: i<2
TRUEFALSE
yes
Evaluation Count:1728
yes
Evaluation Count:864
864-1728
3209 ampm[i].truncate(size);
executed: ampm[i].truncate(size);
Execution Count:1728
1728
3210 -
3211 if (false) QMessageLogger("tools/qdatetime.cpp", 5513, __PRETTY_FUNCTION__).debug() << "findAmPm" << str << ampm[0] << ampm[1];
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:864
never executed: QMessageLogger("tools/qdatetime.cpp", 5513, __PRETTY_FUNCTION__).debug() << "findAmPm" << str << ampm[0] << ampm[1];
0-864
3212 -
3213 if (str.indexOf(ampm[amindex], 0, Qt::CaseInsensitive) == 0) {
evaluated: str.indexOf(ampm[amindex], 0, Qt::CaseInsensitive) == 0
TRUEFALSE
yes
Evaluation Count:759
yes
Evaluation Count:105
105-759
3214 str = ampm[amindex]; -
3215 return AM;
executed: return AM;
Execution Count:759
759
3216 } 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
3217 str = ampm[pmindex]; -
3218 return PM;
executed: return PM;
Execution Count:103
103
3219 } 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
3220 return Neither;
executed: return Neither;
Execution Count:1
1
3221 } -
3222 size = qMin(size, str.size()); -
3223 -
3224 bool broken[2] = {false, false}; -
3225 for (int i=0; i<size; ++i) {
partially evaluated: i<size
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
3226 if (str.at(i) != space) {
partially evaluated: str.at(i) != space
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
3227 for (int j=0; j<2; ++j) {
partially evaluated: j<2
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
3228 if (!broken[j]) {
partially evaluated: !broken[j]
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
3229 int index = ampm[j].indexOf(str.at(i)); -
3230 if (false) QMessageLogger("tools/qdatetime.cpp", 5532, __PRETTY_FUNCTION__).debug() << "looking for" << str.at(i)
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
3231 << "in" << ampm[j] << "and got" << index;
never executed: QMessageLogger("tools/qdatetime.cpp", 5532, __PRETTY_FUNCTION__).debug() << "looking for" << str.at(i) << "in" << ampm[j] << "and got" << index;
0
3232 if (index == -1) {
partially evaluated: index == -1
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
3233 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
3234 index = ampm[j].indexOf(str.at(i).toLower()); -
3235 if (false) QMessageLogger("tools/qdatetime.cpp", 5537, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toLower()
never evaluated: false
0
3236 << "in" << ampm[j] << "and got" << index;
never executed: QMessageLogger("tools/qdatetime.cpp", 5537, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toLower() << "in" << ampm[j] << "and got" << index;
0
3237 } else if (str.at(i).category() == QChar::Letter_Lowercase) {
partially evaluated: str.at(i).category() == QChar::Letter_Lowercase
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never executed: }
0-2
3238 index = ampm[j].indexOf(str.at(i).toUpper()); -
3239 if (false) QMessageLogger("tools/qdatetime.cpp", 5541, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toUpper()
never evaluated: false
0
3240 << "in" << ampm[j] << "and got" << index;
never executed: QMessageLogger("tools/qdatetime.cpp", 5541, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toUpper() << "in" << ampm[j] << "and got" << index;
0
3241 }
never executed: }
0
3242 if (index == -1) {
partially evaluated: index == -1
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
3243 broken[j] = true; -
3244 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
3245 if (false) QMessageLogger("tools/qdatetime.cpp", 5547, __PRETTY_FUNCTION__).debug() << str << "didn't make it";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never executed: QMessageLogger("tools/qdatetime.cpp", 5547, __PRETTY_FUNCTION__).debug() << str << "didn't make it";
0-1
3246 return Neither;
executed: return Neither;
Execution Count:1
1
3247 } -
3248 continue;
executed: continue;
Execution Count:1
1
3249 } else { -
3250 str[i] = ampm[j].at(index); -
3251 }
never executed: }
0
3252 } -
3253 ampm[j].remove(index, 1); -
3254 }
never executed: }
0
3255 }
never executed: }
0
3256 }
never executed: }
0
3257 }
never executed: }
0
3258 if (!broken[pmindex] && !broken[amindex])
never evaluated: !broken[pmindex]
never evaluated: !broken[amindex]
0
3259 return PossibleBoth;
never executed: return PossibleBoth;
0
3260 return (!broken[amindex] ? PossibleAM : PossiblePM);
never executed: return (!broken[amindex] ? PossibleAM : PossiblePM);
0
3261} -
3262 -
3263 -
3264 -
3265 -
3266 -
3267 -
3268int QDateTimeParser::maxChange(int index) const -
3269{ -
3270 const SectionNode &sn = sectionNode(index); -
3271 switch (sn.type) { -
3272 -
3273 case MSecSection: return 999;
never executed: return 999;
0
3274 case SecondSection: return 59 * 1000;
never executed: return 59 * 1000;
0
3275 case MinuteSection: return 59 * 60 * 1000;
executed: return 59 * 60 * 1000;
Execution Count:11
11
3276 case Hour24Section: case Hour12Section: return 59 * 60 * 60 * 1000;
executed: return 59 * 60 * 60 * 1000;
Execution Count:9
9
3277 -
3278 -
3279 case DayOfWeekSectionShort: -
3280 case DayOfWeekSectionLong: return 7;
never executed: return 7;
0
3281 case DaySection: return 30;
never executed: return 30;
0
3282 case MonthSection: return 365 - 31;
never executed: return 365 - 31;
0
3283 case YearSection: return 9999 * 365;
executed: return 9999 * 365;
Execution Count:29
29
3284 case YearSection2Digits: return 100 * 365;
executed: return 100 * 365;
Execution Count:3
3
3285 default: -
3286 QMessageLogger("tools/qdatetime.cpp", 5588, __PRETTY_FUNCTION__).warning("QDateTimeParser::maxChange() Internal error (%s)", -
3287 QString(sectionName(sectionType(index))).toLocal8Bit().constData()); -
3288 }
never executed: }
0
3289 -
3290 return -1;
never executed: return -1;
0
3291} -
3292 -
3293QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const -
3294{ -
3295 FieldInfo ret = 0; -
3296 const SectionNode &sn = sectionNode(index); -
3297 const Section s = sn.type; -
3298 switch (s) { -
3299 case MSecSection: -
3300 ret |= Fraction; -
3301 -
3302 case SecondSection:
code before this statement executed: case SecondSection:
Execution Count:225
225
3303 case MinuteSection: -
3304 case Hour24Section: -
3305 case Hour12Section: -
3306 case YearSection: -
3307 case YearSection2Digits: -
3308 ret |= Numeric; -
3309 if (s != YearSection) {
evaluated: s != YearSection
TRUEFALSE
yes
Evaluation Count:6372
yes
Evaluation Count:1019
1019-6372
3310 ret |= AllowPartial; -
3311 }
executed: }
Execution Count:6372
6372
3312 if (sn.count != 1) {
evaluated: sn.count != 1
TRUEFALSE
yes
Evaluation Count:7058
yes
Evaluation Count:333
333-7058
3313 ret |= FixedWidth; -
3314 }
executed: }
Execution Count:7058
7058
3315 break;
executed: break;
Execution Count:7391
7391
3316 case MonthSection: -
3317 case DaySection: -
3318 switch (sn.count) { -
3319 case 2: -
3320 ret |= FixedWidth; -
3321 -
3322 case 1:
code before this statement executed: case 1:
Execution Count:2281
2281
3323 ret |= (Numeric|AllowPartial); -
3324 break;
executed: break;
Execution Count:2723
2723
3325 } -
3326 break;
executed: break;
Execution Count:2743
2743
3327 case DayOfWeekSectionShort: -
3328 case DayOfWeekSectionLong: -
3329 if (sn.count == 3)
never evaluated: sn.count == 3
0
3330 ret |= FixedWidth;
never executed: ret |= FixedWidth;
0
3331 break;
never executed: break;
0
3332 case AmPmSection: -
3333 ret |= FixedWidth; -
3334 break;
never executed: break;
0
3335 default: -
3336 QMessageLogger("tools/qdatetime.cpp", 5638, __PRETTY_FUNCTION__).warning("QDateTimeParser::fieldInfo Internal error 2 (%d %s %d)", -
3337 index, QString(sectionName(sn.type)).toLocal8Bit().constData(), sn.count); -
3338 break;
never executed: break;
0
3339 } -
3340 return ret;
executed: return ret;
Execution Count:10134
10134
3341} -
3342QString QDateTimeParser::sectionFormat(int index) const -
3343{ -
3344 const SectionNode &sn = sectionNode(index); -
3345 return sectionFormat(sn.type, sn.count);
executed: return sectionFormat(sn.type, sn.count);
Execution Count:6
6
3346} -
3347 -
3348QString QDateTimeParser::sectionFormat(Section s, int count) const -
3349{ -
3350 QChar fillChar; -
3351 switch (s) { -
3352 case AmPmSection: return count == 1 ? QLatin1String("AP") : QLatin1String("ap");
never executed: return count == 1 ? QLatin1String("AP") : QLatin1String("ap");
0
3353 case MSecSection: fillChar = QLatin1Char('z'); break;
never executed: break;
0
3354 case SecondSection: fillChar = QLatin1Char('s'); break;
never executed: break;
0
3355 case MinuteSection: fillChar = QLatin1Char('m'); break;
never executed: break;
0
3356 case Hour24Section: fillChar = QLatin1Char('H'); break;
never executed: break;
0
3357 case Hour12Section: fillChar = QLatin1Char('h'); break;
never executed: break;
0
3358 case DayOfWeekSectionShort: -
3359 case DayOfWeekSectionLong: -
3360 case DaySection: fillChar = QLatin1Char('d'); break;
executed: break;
Execution Count:2
2
3361 case MonthSection: fillChar = QLatin1Char('M'); break;
executed: break;
Execution Count:2
2
3362 case YearSection2Digits: -
3363 case YearSection: fillChar = QLatin1Char('y'); break;
executed: break;
Execution Count:2
2
3364 default: -
3365 QMessageLogger("tools/qdatetime.cpp", 5676, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionFormat Internal error (%s)", -
3366 QString(sectionName(s)).toLocal8Bit().constData()); -
3367 return QString();
never executed: return QString();
0
3368 } -
3369 if (fillChar.isNull()) {
partially evaluated: fillChar.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
3370 QMessageLogger("tools/qdatetime.cpp", 5681, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionFormat Internal error 2"); -
3371 return QString();
never executed: return QString();
0
3372 } -
3373 -
3374 QString str; -
3375 str.fill(fillChar, count); -
3376 return str;
executed: return str;
Execution Count:6
6
3377} -
3378bool QDateTimeParser::potentialValue(const QString &str, int min, int max, int index, -
3379 const QDateTime &currentValue, int insert) const -
3380{ -
3381 if (str.isEmpty()) {
evaluated: str.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:992
3-992
3382 return true;
executed: return true;
Execution Count:3
3
3383 } -
3384 const int size = sectionMaxSize(index); -
3385 int val = (int)locale().toUInt(str); -
3386 const SectionNode &sn = sectionNode(index); -
3387 if (sn.type == YearSection2Digits) {
evaluated: sn.type == YearSection2Digits
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:972
20-972
3388 val += currentValue.date().year() - (currentValue.date().year() % 100); -
3389 }
executed: }
Execution Count:20
20
3390 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
3391 return true;
executed: return true;
Execution Count:362
362
3392 } else if (val > max) {
evaluated: val > max
TRUEFALSE
yes
Evaluation Count:90
yes
Evaluation Count:540
90-540
3393 return false;
executed: return false;
Execution Count:90
90
3394 } 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
3395 return false;
executed: return false;
Execution Count:115
115
3396 } -
3397 -
3398 const int len = size - str.size(); -
3399 for (int i=0; i<len; ++i) {
evaluated: i<len
TRUEFALSE
yes
Evaluation Count:425
yes
Evaluation Count:13
13-425
3400 for (int j=0; j<10; ++j) {
evaluated: j<10
TRUEFALSE
yes
Evaluation Count:608
yes
Evaluation Count:13
13-608
3401 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
3402 return true;
executed: return true;
Execution Count:409
409
3403 } else if (insert >= 0) {
evaluated: insert >= 0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:190
9-190
3404 QString tmp = str; -
3405 tmp.insert(insert, QLatin1Char('0' + j)); -
3406 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
3407 return true;
executed: return true;
Execution Count:3
3
3408 }
executed: }
Execution Count:6
6
3409 } -
3410 }
executed: }
Execution Count:13
13
3411 -
3412 return false;
executed: return false;
Execution Count:13
13
3413} -
3414 -
3415bool QDateTimeParser::skipToNextSection(int index, const QDateTime &current, const QString &text) const -
3416{ -
3417 qt_noop(); -
3418 -
3419 const SectionNode &node = sectionNode(index); -
3420 qt_noop(); -
3421 -
3422 const QDateTime maximum = getMaximum(); -
3423 const QDateTime minimum = getMinimum(); -
3424 QDateTime tmp = current; -
3425 int min = absoluteMin(index); -
3426 setDigit(tmp, index, min); -
3427 if (tmp < minimum) {
evaluated: tmp < minimum
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:309
17-309
3428 min = getDigit(minimum, index); -
3429 }
executed: }
Execution Count:17
17
3430 -
3431 int max = absoluteMax(index, current); -
3432 setDigit(tmp, index, max); -
3433 if (tmp > maximum) {
evaluated: tmp > maximum
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:293
33-293
3434 max = getDigit(maximum, index); -
3435 }
executed: }
Execution Count:33
33
3436 int pos = cursorPosition() - node.pos; -
3437 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
3438 pos = -1;
executed: pos = -1;
Execution Count:319
319
3439 -
3440 const bool potential = potentialValue(text, min, max, index, current, pos); -
3441 return !potential;
executed: return !potential;
Execution Count:326
326
3442 -
3443 -
3444 -
3445 -
3446 -
3447 -
3448} -
3449 -
3450 -
3451 -
3452 -
3453 -
3454 -
3455QString QDateTimeParser::sectionName(int s) const -
3456{ -
3457 switch (s) { -
3458 case QDateTimeParser::AmPmSection: return QLatin1String("AmPmSection");
never executed: return QLatin1String("AmPmSection");
0
3459 case QDateTimeParser::DaySection: return QLatin1String("DaySection");
never executed: return QLatin1String("DaySection");
0
3460 case QDateTimeParser::DayOfWeekSectionShort: return QLatin1String("DayOfWeekSectionShort");
never executed: return QLatin1String("DayOfWeekSectionShort");
0
3461 case QDateTimeParser::DayOfWeekSectionLong: return QLatin1String("DayOfWeekSectionLong");
never executed: return QLatin1String("DayOfWeekSectionLong");
0
3462 case QDateTimeParser::Hour24Section: return QLatin1String("Hour24Section");
never executed: return QLatin1String("Hour24Section");
0
3463 case QDateTimeParser::Hour12Section: return QLatin1String("Hour12Section");
never executed: return QLatin1String("Hour12Section");
0
3464 case QDateTimeParser::MSecSection: return QLatin1String("MSecSection");
never executed: return QLatin1String("MSecSection");
0
3465 case QDateTimeParser::MinuteSection: return QLatin1String("MinuteSection");
never executed: return QLatin1String("MinuteSection");
0
3466 case QDateTimeParser::MonthSection: return QLatin1String("MonthSection");
never executed: return QLatin1String("MonthSection");
0
3467 case QDateTimeParser::SecondSection: return QLatin1String("SecondSection");
never executed: return QLatin1String("SecondSection");
0
3468 case QDateTimeParser::YearSection: return QLatin1String("YearSection");
never executed: return QLatin1String("YearSection");
0
3469 case QDateTimeParser::YearSection2Digits: return QLatin1String("YearSection2Digits");
never executed: return QLatin1String("YearSection2Digits");
0
3470 case QDateTimeParser::NoSection: return QLatin1String("NoSection");
never executed: return QLatin1String("NoSection");
0
3471 case QDateTimeParser::FirstSection: return QLatin1String("FirstSection");
never executed: return QLatin1String("FirstSection");
0
3472 case QDateTimeParser::LastSection: return QLatin1String("LastSection");
never executed: return QLatin1String("LastSection");
0
3473 default: return QLatin1String("Unknown section ") + QString::number(s);
never executed: return QLatin1String("Unknown section ") + QString::number(s);
0
3474 } -
3475}
never executed: }
0
3476 -
3477 -
3478 -
3479 -
3480 -
3481 -
3482QString QDateTimeParser::stateName(int s) const -
3483{ -
3484 switch (s) { -
3485 case Invalid: return QLatin1String("Invalid");
never executed: return QLatin1String("Invalid");
0
3486 case Intermediate: return QLatin1String("Intermediate");
never executed: return QLatin1String("Intermediate");
0
3487 case Acceptable: return QLatin1String("Acceptable");
never executed: return QLatin1String("Acceptable");
0
3488 default: return QLatin1String("Unknown state ") + QString::number(s);
never executed: return QLatin1String("Unknown state ") + QString::number(s);
0
3489 } -
3490}
never executed: }
0
3491 -
3492 -
3493bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) const -
3494{ -
3495 QDateTime val(QDate(1900, 1, 1), QTime(0, 0, 0, 0)); -
3496 QString text = t; -
3497 int copy = -1; -
3498 const StateNode tmp = parse(text, copy, val, false); -
3499 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
3500 return false;
executed: return false;
Execution Count:23
23
3501 } -
3502 if (time) {
evaluated: time
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:36
36-65
3503 const QTime t = tmp.value.time(); -
3504 if (!t.isValid()) {
partially evaluated: !t.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:65
0-65
3505 return false;
never executed: return false;
0
3506 } -
3507 *time = t; -
3508 }
executed: }
Execution Count:65
65
3509 -
3510 if (date) {
evaluated: date
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:6
6-95
3511 const QDate d = tmp.value.date(); -
3512 if (!d.isValid()) {
partially evaluated: !d.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:95
0-95
3513 return false;
never executed: return false;
0
3514 } -
3515 *date = d; -
3516 }
executed: }
Execution Count:95
95
3517 return true;
executed: return true;
Execution Count:101
101
3518} -
3519 -
3520 -
3521QDateTime QDateTimeParser::getMinimum() const -
3522{ -
3523 return QDateTime(QDate(100, 1, 1), QTime(0, 0, 0, 0), spec);
executed: return QDateTime(QDate(100, 1, 1), QTime(0, 0, 0, 0), spec);
Execution Count:147
147
3524} -
3525 -
3526QDateTime QDateTimeParser::getMaximum() const -
3527{ -
3528 return QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999), spec);
executed: return QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999), spec);
Execution Count:127
127
3529} -
3530 -
3531QString QDateTimeParser::getAmPmText(AmPm ap, Case cs) const -
3532{ -
3533 if (ap == AmText) {
evaluated: ap == AmText
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:65
65
3534 return (cs == UpperCase ? QLatin1String("AM") : QLatin1String("am"));
executed: return (cs == UpperCase ? QLatin1String("AM") : QLatin1String("am"));
Execution Count:65
65
3535 } else { -
3536 return (cs == UpperCase ? QLatin1String("PM") : QLatin1String("pm"));
executed: return (cs == UpperCase ? QLatin1String("PM") : QLatin1String("pm"));
Execution Count:65
65
3537 } -
3538} -
3539 -
3540 -
3541 -
3542 -
3543 -
3544 -
3545 -
3546bool operator==(const QDateTimeParser::SectionNode &s1, const QDateTimeParser::SectionNode &s2) -
3547{ -
3548 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
3549} -
3550 -
3551 -
3552 -
3553 -
3554 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial