42 #include "qplatformdefs.h" 43 #include "private/qdatetime_p.h" 51 #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) 59 #if defined(Q_OS_WINCE) 64 #if defined (QDATETIMEPARSER_DEBUG) && !defined(QT_NO_DEBUG_STREAM) 65 # define QDTPDEBUG qDebug() << QString("%1:%2").arg(__FILE__).arg(__LINE__) 66 # define QDTPDEBUGN qDebug 68 # define QDTPDEBUG if (false) qDebug() 69 # define QDTPDEBUGN if (false) qDebug 73 #include <private/qcore_mac_p.h> 76 #if defined(Q_OS_SYMBIAN) 98 QDate result(y, m, 1);
107 return (1461 * (year + 4800 + (month - 14) / 12)) / 4
108 + (367 * (month - 2 - 12 * ((month - 14) / 12))) / 12
109 - (3 * ((year + 4900 + (month - 14) / 12) / 100)) / 4
118 if (year > 1582 || (year == 1582 && (month > 10 || (month == 10 && day >= 15)))) {
120 }
else if (year < 1582 || (year == 1582 && (month < 10 || (month == 10 && day <= 4)))) {
123 int a = (14 - month) / 12;
124 return (153 * (month + (12 * a) - 3) + 2) / 5
125 + (1461 * (year + 4800 - a)) / 4
137 if (julianDay >= 2299161) {
142 n = (4 * ell) / 146097;
143 ell = ell - (146097 * n + 3) / 4;
144 i = (4000 * (ell + 1)) / 1461001;
145 ell = ell - (1461 * i) / 4 + 31;
146 j = (80 * ell) / 2447;
147 d = ell - (2447 * j) / 80;
149 m = j + 2 - (12 * ell);
150 y = 100 * (n - 49) + i + ell;
155 int dd = (4 * julianDay + 3) / 1461;
156 int ee = julianDay - (1461 * dd) / 4;
157 int mm = ((5 * ee) + 2) / 153;
158 d = ee - (153 * mm + 2) / 5 + 1;
159 m = mm + 3 - 12 * (mm / 10);
160 y = dd - 4800 + (mm / 10);
173 static const char monthDays[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
175 #ifndef QT_NO_TEXTDATE 177 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
178 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec" };
180 #ifndef QT_NO_DATESTRING 509 bot = ((yday + 11 - wday) % 7) - 3;
514 top = bot - (len % 7);
524 w = 1 + ((yday - bot) / 7);
535 #ifndef QT_NO_TEXTDATE 570 if (month < 1 || month > 12) {
630 if (month < 1 || month > 12) {
653 if (month < 1 || month > 12) {
688 if (weekday < 1 || weekday > 7) {
711 if (weekday < 1 || weekday > 7) {
746 if (weekday < 1 || weekday > 7) {
769 if (weekday < 1 || weekday > 7) {
774 #endif //QT_NO_TEXTDATE 776 #ifndef QT_NO_DATESTRING 839 : QLocale::ShortFormat);
841 #ifndef QT_NO_TEXTDATE 921 #endif //QT_NO_DATESTRING 961 if (!
isValid(year, month, day)) {
994 d.
jd = (
jd + ndays >=
jd) ?
jd + ndays : 0;
996 d.
jd = (
jd + ndays <
jd) ?
jd + ndays : 0;
1027 bool increasing = nmonths > 0;
1029 while (nmonths != 0) {
1030 if (nmonths < 0 && nmonths + 12 <= 0) {
1033 }
else if (nmonths < 0) {
1040 }
else if (nmonths - 12 >= 0) {
1043 }
else if (m == 12) {
1057 if ((old_y > 0 && y <= 0) ||
1058 (old_y < 0 && y >= 0))
1060 y += increasing ? +1 : -1;
1063 if (y == 1582 && m == 10 && d > 4 && d < 15)
1064 d = increasing ? 15 : 4;
1093 if ((old_y > 0 && y <= 0) ||
1094 (old_y < 0 && y >= 0))
1096 y += nyears > 0 ? +1 : -1;
1188 #ifndef QT_NO_DATESTRING 1227 : QLocale::ShortFormat));
1229 #ifndef QT_NO_TEXTDATE 1233 if (parts.
count() != 4) {
1240 for (
int i = 0; i < 12; ++i) {
1248 for (
int i = 1; i <= 12; ++i) {
1255 if (month < 1 || month > 12) {
1270 return QDate(year, month, day);
1350 #ifndef QT_BOOTSTRAPPED 1360 #endif // QT_NO_DATESTRING 1387 if (year == 1582 && month == 10 && day > 4 && day < 15)
1390 return (day > 0 && month > 0 && month <= 12) &&
1412 return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
1542 setHMS(h, m, s, ms);
1616 #ifndef QT_NO_DATESTRING 1668 : QLocale::ShortFormat);
1732 #endif //QT_NO_DATESTRING 1746 #if defined(Q_OS_WINCE) 1747 startTick = NullTime;
1772 return addMSecs(s * 1000);
1790 return (t.
ds() - ds()) / 1000;
1813 #if defined(Q_OS_WINCE) 1814 if (startTick > NullTime)
1834 #if defined(Q_OS_WINCE) 1836 if (t.
startTick > NullTime && startTick > NullTime)
1840 return t.
ds() - ds();
1912 #ifndef QT_NO_DATESTRING 1946 : QLocale::ShortFormat));
1950 const int hour(s.
mid(0, 2).
toInt(&ok));
1953 const int minute(s.
mid(3, 2).
toInt(&ok));
1956 const int second(s.
mid(6, 2).
toInt(&ok));
1960 const float msec(msec_s.toFloat(&ok));
1962 return QTime(hour, minute, second, 0);
2025 #ifndef QT_BOOTSTRAPPED 2036 #endif // QT_NO_DATESTRING 2072 *
this = currentTime();
2097 QTime t = currentTime();
2125 int n = msecsTo(currentTime());
2510 return uint(retval);
2580 #ifndef QT_NO_DATESTRING 2656 #ifndef QT_NO_TEXTDATE 2666 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILDATE, out, 255);
2668 switch (winstr.
toInt()) {
2773 #endif //QT_NO_DATESTRING 2818 dt.
d->
getUTC(utcDate, utcTime);
2835 int tt = utcTime.
ds();
2920 other.
d->
getUTC(date2, time2);
2949 d->
getUTC(selfDate, selfTime);
2950 other.
d->
getUTC(otherDate, otherTime);
2952 return (static_cast<qint64>(selfDate.
daysTo(otherDate)) * static_cast<qint64>(
MSECS_PER_DAY))
2953 + static_cast<qint64>(selfTime.
msecsTo(otherTime));
3000 other.
d->
getUTC(date2, time2);
3001 return time1 == time2 && date1 == date2;
3035 other.
d->
getUTC(date2, time2);
3037 return date1 < date2;
3038 return time1 < time2;
3114 #if defined(Q_OS_WIN) 3119 memset(&st, 0,
sizeof(SYSTEMTIME));
3129 memset(&st, 0,
sizeof(SYSTEMTIME));
3132 #if defined(Q_OS_WINCE) 3143 memset(&st, 0,
sizeof(SYSTEMTIME));
3155 memset(&st, 0,
sizeof(SYSTEMTIME));
3167 memset(&st, 0,
sizeof(SYSTEMTIME));
3175 #elif defined(Q_OS_SYMBIAN) 3180 localTime.HomeTime();
3181 TDateTime localDateTime = localTime.DateTime();
3183 d.
jd =
julianDayFromDate(localDateTime.Year(), localDateTime.Month() + 1, localDateTime.Day() + 1 );
3191 localTime.HomeTime();
3192 TDateTime localDateTime = localTime.DateTime();
3194 localDateTime.Second(), localDateTime.MicroSecond() / 1000);
3203 localTime.HomeTime();
3204 TDateTime localDateTime = localTime.DateTime();
3206 d.
jd =
julianDayFromDate(localDateTime.Year(), localDateTime.Month() + 1, localDateTime.Day() + 1);
3208 localDateTime.Second(), localDateTime.MicroSecond() / 1000);
3217 gmTime.UniversalTime();
3218 TDateTime gmtDateTime = gmTime.DateTime();
3220 d.
jd =
julianDayFromDate(gmtDateTime.Year(), gmtDateTime.Month() + 1, gmtDateTime.Day() + 1);
3222 gmtDateTime.Second(), gmtDateTime.MicroSecond() / 1000);
3231 gmTime.UniversalTime();
3232 TDateTime gmtDateTime = gmTime.DateTime();
3236 qint64 value = gmTime.Int64();
3242 return (value - unixEpoch) / 1000;
3245 #elif defined(Q_OS_UNIX) 3254 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) 3258 t = localtime_r(<ime, &res);
3260 t = localtime(<ime);
3261 #endif // !QT_NO_THREAD && _POSIX_THREAD_SAFE_FUNCTIONS 3272 gettimeofday(&tv, 0);
3273 time_t ltime = tv.tv_sec;
3276 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) 3280 t = localtime_r(<ime, &res);
3282 t = localtime(<ime);
3295 gettimeofday(&tv, 0);
3296 time_t ltime = tv.tv_sec;
3299 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) 3303 t = localtime_r(<ime, &res);
3305 t = localtime(<ime);
3323 gettimeofday(&tv, 0);
3324 time_t ltime = tv.tv_sec;
3327 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) 3330 t = gmtime_r(<ime, &res);
3348 gettimeofday(&tv, 0);
3353 #error "What system is this?" 3457 #ifndef QT_NO_DATESTRING 3462 for (
int i = 0; i < 12; ++i) {
3467 for (
int i = 1; i <= 12; ++i) {
3498 if (tmp.
size() == 10)
3514 tmp = tmp.
left(idx);
3520 const int tzhour(tmp2.
mid(ntzhour, 2).
toInt(&ok));
3521 const int tzminute(tmp2.
mid(ntzminute, 2).
toInt(&ok));
3522 QTime tzt(tzhour, tzminute);
3523 int utcOffset = (tzt.hour() * 60 + tzt.minute()) * 60;
3524 if ( utcOffset != 0 ) {
3542 : QLocale::ShortFormat));
3543 #if !defined(QT_NO_TEXTDATE) 3547 if ((parts.
count() < 5) || (parts.
count() > 6)) {
3552 int month = -1, day = -1;
3562 if (month == -1 || day == -1) {
3569 day = dayStr.
toInt(&ok);
3578 if (month == -1 || day == -1) {
3585 if ((timeParts.
count() == 3) || (timeParts.
count() == 2)) {
3586 year = parts.
at(4).
toInt(&ok);
3591 if ((timeParts.
count() != 3) && (timeParts.
count() != 2))
3593 year = parts.
at(3).
toInt(&ok);
3598 int hour = timeParts.
at(0).
toInt(&ok);
3603 int minute = timeParts.
at(1).
toInt(&ok);
3608 int second = (timeParts.
count() > 2) ? timeParts.
at(2).
toInt(&ok) : 0;
3616 if (parts.
count() == 5)
3630 int tzhour = tz.
mid(4, 2).
toInt(&ok);
3633 int tzminute = tz.
mid(6).
toInt(&ok);
3636 tzoffset = (tzhour*60 + tzminute) * 60;
3638 tzoffset = -tzoffset;
3643 #endif //QT_NO_TEXTDATE 3750 #ifndef QT_BOOTSTRAPPED 3764 #endif // QT_NO_DATESTRING 3800 #ifndef QT_NO_DATASTREAM 3911 #endif // QT_NO_DATASTREAM 4008 bool inquote =
false;
4009 const int max = f.
size();
4010 for (
int i=0; i<max; ++i) {
4011 if (f.
at(i) == quote) {
4020 #ifndef QT_NO_DATESTRING 4037 if (hour12 && dt->hour() > 12)
4039 else if (hour12 && dt->hour() == 0)
4046 if (hour12 && dt->hour() > 12)
4048 else if (hour12 && dt->hour() == 0)
4086 buf = dd->longDayName(dd->dayOfWeek());
4089 buf = dd->shortDayName(dd->dayOfWeek());
4098 buf = dd->longMonthName(dd->month());
4101 buf = dd->shortMonthName(dd->month());
4110 const int year = dd->year();
4125 if (removed == 0 || removed >= f.
size()) {
4149 for (
int i = 0; i < (int)f.
length(); ++i) {
4150 if (f.
at(i) == quote) {
4151 if (status == quote) {
4152 if (i > 0 && f.
at(i - 1) == quote)
4162 }
else if (status == quote) {
4196 #endif // QT_NO_DATESTRING 4210 if (date > lowerLimit && date < upperLimit)
4213 int month = date.
month();
4214 int day = date.
day();
4217 if (month == 2 && day == 29)
4220 if (date < lowerLimit)
4236 #if defined(Q_OS_WINCE) 4238 FILETIME utcTime =
time_tToFt(secsSince1Jan1970UTC);
4239 FILETIME resultTime;
4240 FileTimeToLocalFileTime(&utcTime , &resultTime);
4242 FileTimeToSystemTime(&resultTime , &sysTime);
4244 res.
tm_sec = sysTime.wSecond;
4245 res.
tm_min = sysTime.wMinute;
4248 res.
tm_mon = sysTime.wMonth - 1;
4249 res.
tm_year = sysTime.wYear - 1900;
4251 #elif defined(Q_OS_SYMBIAN) 4253 _LIT(KUnixEpoch,
"19700000:000000.000000");
4254 TTimeIntervalSeconds tTimeIntervalSecsSince1Jan1970UTC(secsSince1Jan1970UTC);
4256 TInt err = epochTTime.Set(KUnixEpoch);
4258 if(err == KErrNone) {
4259 TTime utcTTime = epochTTime + tTimeIntervalSecsSince1Jan1970UTC;
4260 CTrapCleanup *
cleanup = CTrapCleanup::New();
4263 User::LeaveIfError(tz.Connect());
4264 CleanupClosePushL(tz);
4265 CTzId *tzId = tz.GetTimeZoneIdL();
4266 CleanupStack::PushL(tzId);
4267 res.
tm_isdst = tz.IsDaylightSavingOnL(*tzId,utcTTime);
4268 User::LeaveIfError(tz.ConvertToLocalTime(utcTTime));
4269 CleanupStack::PopAndDestroy(tzId);
4270 CleanupStack::PopAndDestroy(&tz));
4272 if (KErrNone == err) {
4273 TDateTime localDateTime = utcTTime.DateTime();
4274 res.
tm_sec = localDateTime.Second();
4275 res.
tm_min = localDateTime.Minute();
4276 res.
tm_hour = localDateTime.Hour();
4277 res.
tm_mday = localDateTime.Day() + 1;
4278 res.
tm_mon = localDateTime.Month();
4279 res.
tm_year = localDateTime.Year() - 1900;
4286 #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) 4290 brokenDown = localtime_r(&secsSince1Jan1970UTC, &res);
4291 #elif defined(_MSC_VER) && _MSC_VER >= 1400 4293 if (!_localtime64_s(&res, &secsSince1Jan1970UTC))
4296 brokenDown = localtime(&secsSince1Jan1970UTC);
4299 date =
QDate(1970, 1, 1);
4303 int deltaDays = fakeDate.
daysTo(date);
4304 date =
QDate(brokenDown->tm_year + 1900, brokenDown->tm_mon + 1, brokenDown->tm_mday);
4305 time =
QTime(brokenDown->tm_hour, brokenDown->tm_min, brokenDown->tm_sec, time.
msec());
4306 date = date.addDays(deltaDays);
4307 if (brokenDown->tm_isdst > 0)
4309 else if (brokenDown->tm_isdst < 0)
4331 #if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) 4334 #if defined(Q_OS_WIN) 4337 time_t secsSince1Jan1970UTC = mktime(&localTM);
4340 if (secsSince1Jan1970UTC == (
time_t)-1) {
4342 tempTime = tempTime.
addMSecs(timezone * 1000);
4343 date = tempTime.
date();
4344 time = tempTime.
time();
4350 #if defined(Q_OS_WINCE) 4352 FILETIME localTime =
time_tToFt(secsSince1Jan1970UTC);
4354 FileTimeToSystemTime(&localTime, &sysTime);
4355 FILETIME resultTime;
4356 LocalFileTimeToFileTime(&localTime , &resultTime);
4357 FileTimeToSystemTime(&resultTime , &sysTime);
4358 res.
tm_sec = sysTime.wSecond;
4359 res.
tm_min = sysTime.wMinute;
4362 res.
tm_mon = sysTime.wMonth - 1;
4363 res.
tm_year = sysTime.wYear - 1900;
4366 #elif defined(Q_OS_SYMBIAN) 4368 _LIT(KUnixEpoch,
"19700000:000000.000000");
4369 TTimeIntervalSeconds tTimeIntervalSecsSince1Jan1970UTC(secsSince1Jan1970UTC);
4371 TInt err = epochTTime.Set(KUnixEpoch);
4373 if(err == KErrNone) {
4374 TTime localTTime = epochTTime + tTimeIntervalSecsSince1Jan1970UTC;
4376 if (KErrNone == tz.Connect()) {
4377 if (KErrNone == tz.ConvertToUniversalTime(localTTime)) {
4378 TDateTime utcDateTime = localTTime.DateTime();
4379 res.
tm_sec = utcDateTime.Second();
4380 res.
tm_min = utcDateTime.Minute();
4381 res.
tm_hour = utcDateTime.Hour();
4382 res.
tm_mday = utcDateTime.Day() + 1;
4383 res.
tm_mon = utcDateTime.Month();
4384 res.
tm_year = utcDateTime.Year() - 1900;
4391 #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) 4394 brokenDown = gmtime_r(&secsSince1Jan1970UTC, &res);
4395 #elif defined(_MSC_VER) && _MSC_VER >= 1400 4397 if (!_gmtime64_s(&res, &secsSince1Jan1970UTC))
4400 brokenDown = gmtime(&secsSince1Jan1970UTC);
4401 #endif // !QT_NO_THREAD && _POSIX_THREAD_SAFE_FUNCTIONS 4403 date =
QDate(1970, 1, 1);
4406 int deltaDays = fakeDate.
daysTo(date);
4409 date = date.addDays(deltaDays);
4435 #if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING) 4455 #ifndef QT_BOOTSTRAPPED 4471 if (index < 0 || index >= sectionNodes.size()) {
4472 #ifndef QT_NO_DATESTRING 4473 qWarning(
"QDateTimeParser::getDigit() Internal error (%s %d)",
4476 qWarning(
"QDateTimeParser::getDigit() Internal error (%d)", index);
4481 switch (node.
type) {
4482 case Hour24Section:
case Hour12Section:
return t.
time().
hour();
4483 case MinuteSection:
return t.
time().
minute();
4484 case SecondSection:
return t.
time().
second();
4485 case MSecSection:
return t.
time().
msec();
4486 case YearSection2Digits:
4487 case YearSection:
return t.
date().
year();
4488 case MonthSection:
return t.
date().
month();
4489 case DaySection:
return t.
date().
day();
4490 case DayOfWeekSection:
return t.
date().
day();
4491 case AmPmSection:
return t.
time().
hour() > 11 ? 1 : 0;
4496 #ifndef QT_NO_DATESTRING 4497 qWarning(
"QDateTimeParser::getDigit() Internal error 2 (%s %d)",
4500 qWarning(
"QDateTimeParser::getDigit() Internal error 2 (%d)", index);
4522 if (index < 0 || index >= sectionNodes.size()) {
4523 #ifndef QT_NO_DATESTRING 4524 qWarning(
"QDateTimeParser::setDigit() Internal error (%s %d %d)",
4527 qWarning(
"QDateTimeParser::setDigit() Internal error (%d %d)", index, newVal);
4533 int year, month, day, hour, minute, second, msec;
4542 switch (node.
type) {
4543 case Hour24Section:
case Hour12Section: hour = newVal;
break;
4544 case MinuteSection: minute = newVal;
break;
4545 case SecondSection: second = newVal;
break;
4546 case MSecSection: msec = newVal;
break;
4547 case YearSection2Digits:
4548 case YearSection: year = newVal;
break;
4549 case MonthSection: month = newVal;
break;
4551 case DayOfWeekSection:
4560 case AmPmSection: hour = (newVal == 0 ? hour % 12 : (hour % 12) + 12);
break;
4562 qWarning(
"QDateTimeParser::setDigit() Internal error (%s)",
4567 if (!(node.
type & (DaySection|DayOfWeekSection))) {
4568 if (day < cachedDay)
4595 case Hour12Section:
return 23;
4599 case SecondSection:
return 59;
4600 case MSecSection:
return 999;
4601 case YearSection2Digits:
4602 case YearSection:
return 9999;
4606 case MonthSection:
return 12;
4609 case AmPmSection:
return 1;
4612 qWarning(
"QDateTimeParser::absoluteMax() Internal error (%s)",
4632 case YearSection2Digits:
4633 case YearSection:
return 0;
4636 case DayOfWeekSection:
return 1;
4637 case AmPmSection:
return 0;
4640 qWarning(
"QDateTimeParser::absoluteMin() Internal error (%s, %0x)",
4656 if (sectionIndex < 0) {
4657 switch (sectionIndex) {
4658 case FirstSectionIndex:
4660 case LastSectionIndex:
4662 case NoSectionIndex:
4665 }
else if (sectionIndex < sectionNodes.size()) {
4666 return sectionNodes.at(sectionIndex);
4669 qWarning(
"QDateTimeParser::sectionNode() Internal error (%d)",
4676 return sectionNode(sectionIndex).type;
4691 return sectionPos(sectionNode(sectionIndex));
4697 case FirstSection:
return 0;
4698 case LastSection:
return displayText().size() - 1;
4722 const int max = str.
size();
4723 for (
int i=0; i<max; ++i) {
4724 if (str.
at(i) == quote) {
4725 if (status != quote) {
4727 }
else if (!ret.
isEmpty() && str.
at(i - 1) == slash) {
4728 ret[ret.
size() - 1] = quote;
4752 const QChar ch(str.
at(index));
4753 const int max =
qMin(index + maxCount, str.
size());
4754 while (index + count < max && str.
at(index + count) == ch) {
4762 QString str(
string.mid(from, size));
4763 if (lastQuote >= from)
4774 if (newFormat == displayFormat && !newFormat.
isEmpty()) {
4781 Sections newDisplay = 0;
4786 const int max = newFormat.
size();
4788 for (i = 0; i<max; ++i) {
4789 if (newFormat.
at(i) == quote) {
4792 if (status != quote) {
4794 }
else if (newFormat.
at(i - 1) != slash) {
4797 }
else if (status != quote) {
4798 const char sect = newFormat.
at(i).
toLatin1();
4803 const Section hour = (sect ==
'h') ? Hour12Section : Hour24Section;
4805 newSectionNodes.append(sn);
4806 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
4815 newSectionNodes.append(sn);
4816 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
4819 newDisplay |= MinuteSection;
4825 newSectionNodes.append(sn);
4826 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
4829 newDisplay |= SecondSection;
4836 newSectionNodes.append(sn);
4837 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
4840 newDisplay |= MSecSection;
4846 const bool cap = (sect ==
'A');
4848 newSectionNodes.append(sn);
4849 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
4850 newDisplay |= AmPmSection;
4851 if (i + 1 < newFormat.
size()
4852 && newFormat.
at(i+1) == (cap ?
QLatin1Char(
'P') : QLatin1Char(
'p'))) {
4862 const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits,
4863 i -
add, repeat == 4 ? 4 : 2 };
4864 newSectionNodes.append(sn);
4865 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
4868 newDisplay |= sn.
type;
4875 newSectionNodes.append(sn);
4879 newDisplay |= MonthSection;
4885 const SectionNode sn = { repeat >= 3 ? DayOfWeekSection : DaySection, i -
add, repeat };
4886 newSectionNodes.append(sn);
4887 appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
4890 newDisplay |= sn.
type;
4899 if (newSectionNodes.isEmpty() && context == DateTimeEdit) {
4903 if ((newDisplay & (AmPmSection|Hour12Section)) == Hour12Section) {
4904 const int max = newSectionNodes.size();
4905 for (
int i=0; i<max; ++i) {
4907 if (node.
type == Hour12Section)
4908 node.
type = Hour24Section;
4912 if (index < newFormat.
size()) {
4913 appendSeparator(&newSeparators, newFormat, index, index - max, lastQuote);
4918 displayFormat = newFormat;
4919 separators = newSeparators;
4920 sectionNodes = newSectionNodes;
4928 QDTPDEBUG << newFormat << displayFormat;
4945 if (sectionIndex < 0)
4948 if (sectionIndex >= sectionNodes.size()) {
4949 qWarning(
"QDateTimeParser::sectionSize Internal error (%d)", sectionIndex);
4952 if (sectionIndex == sectionNodes.size() - 1) {
4953 return displayText().size() - sectionPos(sectionIndex) - separators.last().size();
4955 return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex)
4956 - separators.at(sectionIndex + 1).size();
4963 #ifndef QT_NO_TEXTDATE 4970 case LastSection:
return 0;
4973 const int lowerMax =
qMin(getAmPmText(AmText, LowerCase).size(),
4974 getAmPmText(PmText, LowerCase).size());
4975 const int upperMax =
qMin(getAmPmText(AmText, UpperCase).size(),
4976 getAmPmText(PmText, UpperCase).size());
4977 return qMin(4,
qMin(lowerMax, upperMax));
4984 case DaySection:
return 2;
4985 case DayOfWeekSection:
4986 #ifdef QT_NO_TEXTDATE 4996 #ifdef QT_NO_TEXTDATE 5002 for (
int i=1; i<=mcount; ++i) {
5003 const QString str = (s == MonthSection
5011 case MSecSection:
return 3;
5012 case YearSection:
return 4;
5013 case YearSection2Digits:
return 2;
5015 case CalendarPopupSection:
5017 case TimeSectionMask:
5018 case DateSectionMask:
5019 qWarning(
"QDateTimeParser::sectionMaxSize: Invalid section %s",
5020 sectionName(s).toLatin1().constData());
5022 case NoSectionIndex:
5023 case FirstSectionIndex:
5024 case LastSectionIndex:
5025 case CalendarPopupIndex:
5036 return sectionMaxSize(sn.
type, sn.
count);
5052 const SectionNode &sn = sectionNode(sectionIndex);
5054 case NoSectionIndex:
5055 case FirstSectionIndex:
5056 case LastSectionIndex:
5061 return text.
mid(index, sectionSize(sectionIndex));
5066 const SectionNode &sn = sectionNode(sectionIndex);
5068 case NoSectionIndex:
5069 case FirstSectionIndex:
5070 case LastSectionIndex:
5075 return displayText().mid(sn.
pos, sectionSize(sectionIndex));
5079 #ifndef QT_NO_TEXTDATE 5090 State &state,
int *usedptr)
const 5094 const SectionNode &sn = sectionNode(sectionIndex);
5095 if ((sn.
type & Internal) == Internal) {
5096 qWarning(
"QDateTimeParser::parseSection Internal error (%s %d)",
5101 const int sectionmaxsize = sectionMaxSize(sectionIndex);
5102 QString sectiontext = text.
mid(index, sectionmaxsize);
5103 int sectiontextSize = sectiontext.
size();
5106 <<
"with text" << text <<
"and st" << sectiontext
5107 << text.
mid(index, sectionmaxsize)
5113 const int ampm = findAmPm(sectiontext, sectionIndex, &used);
5123 state = Intermediate;
5127 state = Intermediate;
5131 QDTPDEBUG <<
"invalid because findAmPm(" << sectiontext <<
") returned -1";
5134 QDTPDEBUGN(
"This should never happen (findAmPm returned %d)", ampm);
5139 text.
replace(index, used, sectiontext.
left(used));
5143 case DayOfWeekSection:
5144 if (sn.
count >= 3) {
5145 if (sn.
type == MonthSection) {
5147 const QDate minDate = getMinimum().date();
5149 min = minDate.
month();
5151 num = findMonth(sectiontext.
toLower(), min, sectionIndex, §iontext, &used);
5153 num = findDay(sectiontext.
toLower(), 1, sectionIndex, §iontext, &used);
5157 state = (used == sectiontext.
size() ? Acceptable : Intermediate);
5159 text.
replace(index, used, sectiontext.
left(used));
5161 state = Intermediate;
5167 case YearSection2Digits:
5173 if (sectiontextSize == 0) {
5176 state = Intermediate;
5178 const int absMax = absoluteMax(sectionIndex);
5184 QString digitsStr(sectiontext);
5185 for (
int i = 0; i < sectiontextSize; ++i) {
5187 sectiontextSize = i;
5192 const int max =
qMin(sectionmaxsize, sectiontextSize);
5193 for (
int digits = max; digits >= 1; --digits) {
5195 int tmp = (int)loc.
toUInt(digitsStr, &ok, 10);
5196 if (ok && sn.
type == Hour12Section) {
5200 }
else if (tmp == 12) {
5204 if (ok && tmp <= absMax) {
5213 QChar first(sectiontext.
at(0));
5214 if (separators.at(sectionIndex + 1).startsWith(first)) {
5216 state = Intermediate;
5219 QDTPDEBUG <<
"invalid because" << sectiontext <<
"can't become a uint" << last << ok;
5223 const FieldInfo fi = fieldInfo(sectionIndex);
5224 const bool done = (used == sectionmaxsize);
5225 if (!done && fi & Fraction) {
5226 for (
int i=used; i<sectionmaxsize; ++i) {
5230 const int absMin = absoluteMin(sectionIndex);
5232 state = done ?
Invalid : Intermediate;
5234 QDTPDEBUG <<
"invalid because" << num <<
"is less than absoluteMin" << absMin;
5235 }
else if (num > absMax) {
5236 state = Intermediate;
5237 }
else if (!done && (fi & (FixedWidth|Numeric)) == (FixedWidth|Numeric)) {
5238 if (skipToNextSection(sectionIndex, currentValue, digitsStr)) {
5240 const int missingZeroes = sectionmaxsize - digitsStr.
size();
5242 used = sectionmaxsize;
5243 cursorPosition += missingZeroes;
5245 state = Intermediate;;
5254 qWarning(
"QDateTimeParser::parseSection Internal error (%s %d)",
5262 return (state !=
Invalid ? num : -1);
5264 #endif // QT_NO_TEXTDATE 5266 #ifndef QT_NO_DATESTRING 5272 const QDateTime ¤tValue,
bool fixup)
const 5277 State state = Acceptable;
5281 bool conflicts =
false;
5282 const int sectionNodesCount = sectionNodes.size();
5286 int year, month, day, hour12, hour, minute, second, msec, ampm, dayofweek, year2digits;
5288 year2digits = year % 100;
5303 QDTPDEBUG <<
"invalid because" << input.mid(pos, separators.at(
index).size())
5304 <<
"!=" << separators.at(
index)
5305 <<
index << pos << currentSectionIndex;
5309 pos += separators.at(
index).size();
5310 sectionNodes[
index].pos = pos;
5315 num = parseSection(currentValue,
index, input, cursorPosition, pos, tmpstate, &used);
5316 QDTPDEBUG <<
"sectionValue" << sectionName(sectionType(
index)) << input
5317 <<
"pos" << pos <<
"used" << used << stateName(tmpstate);
5318 if (fixup && tmpstate == Intermediate && used < sn.
count) {
5319 const FieldInfo fi = fieldInfo(
index);
5320 if ((fi & (Numeric|FixedWidth)) == (Numeric|FixedWidth)) {
5322 input.
replace(pos, used, newText);
5326 pos +=
qMax(0, used);
5328 state = qMin<State>(state, tmpstate);
5329 if (state == Intermediate && context == FromString) {
5335 << pos <<
"state is" << stateName(state);
5340 case Hour24Section: current = &hour;
break;
5341 case Hour12Section: current = &hour12;
break;
5342 case MinuteSection: current = &minute;
break;
5343 case SecondSection: current = &second;
break;
5344 case MSecSection: current = &msec;
break;
5345 case YearSection: current = &year;
break;
5346 case YearSection2Digits: current = &year2digits;
break;
5347 case MonthSection: current = &month;
break;
5348 case DayOfWeekSection: current = &dayofweek;
break;
5349 case DaySection: current = &day; num = qMax<int>(1, num);
break;
5350 case AmPmSection: current = &m;
break;
5352 qWarning(
"QDateTimeParser::parse Internal error (%s)",
5357 qWarning(
"QDateTimeParser::parse Internal error 2");
5360 if (isSet & sn.
type && *current != num) {
5361 QDTPDEBUG <<
"CONFLICT " << sectionName(sn.
type) << *current << num;
5363 if (
index != currentSectionIndex || num == -1) {
5373 if (state !=
Invalid &&
QStringRef(&input, pos, input.size() - pos) != separators.last()) {
5374 QDTPDEBUG <<
"invalid because" << input.mid(pos)
5375 <<
"!=" << separators.last() << pos;
5381 if (year % 100 != year2digits) {
5382 switch (isSet & (YearSection2Digits|YearSection)) {
5383 case YearSection2Digits:
5384 year = (year / 100) * 100;
5385 year += year2digits;
5387 case ((
uint)YearSection2Digits|(
uint)YearSection): {
5389 const SectionNode &sn = sectionNode(currentSectionIndex);
5390 if (sn.
type == YearSection2Digits) {
5391 year = (year / 100) * 100;
5392 year += year2digits;
5402 if (diff != 0 && state == Acceptable && isSet & DayOfWeekSection) {
5403 conflicts = isSet & DaySection;
5404 const SectionNode &sn = sectionNode(currentSectionIndex);
5405 if (sn.
type == DayOfWeekSection || currentSectionIndex == -1) {
5413 QDTPDEBUG << year << month << day << dayofweek
5417 bool needfixday =
false;
5418 if (sectionType(currentSectionIndex) & (DaySection|DayOfWeekSection)) {
5420 }
else if (cachedDay > day) {
5434 if (context == FromString) {
5438 if (state == Acceptable && fixday) {
5442 for (
int i=0; i<sectionNodesCount; ++i) {
5443 if (sectionType(i) & (DaySection|DayOfWeekSection)) {
5444 input.replace(sectionPos(i), sectionSize(i), loc.toString(day));
5448 state =
qMin(Intermediate, state);
5454 if (isSet & Hour12Section) {
5455 const bool hasHour = isSet & Hour24Section;
5458 ampm = (hour < 12 ? 0 : 1);
5463 hour12 = (ampm == 0 ? hour12 % 12 : (hour12 % 12) + 12);
5466 }
else if (hour != hour12) {
5469 }
else if (ampm != -1) {
5470 if (!(isSet & (Hour24Section))) {
5472 }
else if ((ampm == 0) != (hour < 12)) {
5479 newCurrentValue =
QDateTime(
QDate(year, month, day),
QTime(hour, minute, second, msec), spec);
5480 QDTPDEBUG << year << month << day << hour << minute << second << msec;
5482 QDTPDEBUGN(
"'%s' => '%s'(%s)", input.toLatin1().constData(),
5484 stateName(state).toLatin1().constData());
5487 if (newCurrentValue.
isValid()) {
5488 if (context != FromString && state !=
Invalid && newCurrentValue < minimum) {
5490 if (newCurrentValue >= minimum)
5491 qWarning(
"QDateTimeParser::parse Internal error 3 (%s %s)",
5496 for (
int i=0; i<sectionNodesCount && !
done; ++i) {
5499 if ((t.
size() < sectionMaxSize(i) && (((int)fieldInfo(i) & (FixedWidth|Numeric)) != Numeric))
5503 switch (findAmPm(t, i)) {
5515 case PossibleBoth: {
5517 if (copy >= minimum && copy <= maximum) {
5518 state = Intermediate;
5524 if (sn.
count >= 3) {
5525 int tmp = newCurrentValue.
date().
month();
5527 while ((tmp = findMonth(t, tmp + 1, i)) != -1) {
5529 if (copy >= minimum && copy <= maximum)
5535 state = Intermediate;
5544 if (sn.
type & TimeSectionMask) {
5545 if (newCurrentValue.
daysTo(minimum) != 0) {
5549 if (newCurrentValue.
daysTo(maximum) > 0) {
5555 toMin = newCurrentValue.
daysTo(minimum);
5556 toMax = newCurrentValue.
daysTo(maximum);
5559 if (toMin > maxChange) {
5560 QDTPDEBUG <<
"invalid because toMin > maxChange" << toMin
5561 << maxChange << t << newCurrentValue << minimum;
5565 }
else if (toMax > maxChange) {
5569 const int min = getDigit(minimum, i);
5571 qWarning(
"QDateTimeParser::parse Internal error 4 (%s)",
5578 int max = toMax != -1 ? getDigit(maximum, i) : absoluteMax(i, newCurrentValue);
5579 int pos = cursorPosition - sn.
pos;
5580 if (pos < 0 || pos >= t.
size())
5582 if (!potentialValue(t.
simplified(), min, max, i, newCurrentValue, pos)) {
5584 << sectionName(sn.
type) <<
"returned" << toMax << toMin << pos;
5589 state = Intermediate;
5596 if (context == FromString) {
5598 Q_ASSERT(getMaximum().
date().toJulianDay() == 4642999);
5602 if (newCurrentValue > getMaximum())
5606 QDTPDEBUG <<
"not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum();
5617 #endif // QT_NO_DATESTRING 5619 #ifndef QT_NO_TEXTDATE 5626 QString *usedMonth,
int *used)
const 5631 const SectionNode &sn = sectionNode(sectionIndex);
5632 if (sn.
type != MonthSection) {
5633 qWarning(
"QDateTimeParser::findMonth Internal error");
5640 for (
int month=startMonth; month<=12; ++month) {
5646 *used = str2.
size();
5653 if (context == FromString)
5658 QDTPDEBUG <<
"limit is" << limit << str1 << str2;
5660 for (
int i=0; i<limit; ++i) {
5661 if (str1.
at(i) != str2.at(i)) {
5663 if (i > bestCount) {
5678 if (usedMonth && bestMatch != -1)
5679 *usedMonth = l.
monthName(bestMatch, type);
5682 QDTPDEBUG <<
"used is set to" << bestCount;
5693 const SectionNode &sn = sectionNode(sectionIndex);
5694 if (!(sn.
type & (DaySection|DayOfWeekSection))) {
5695 qWarning(
"QDateTimeParser::findDay Internal error");
5699 for (
int day=startDay; day<=7; ++day) {
5704 *used = str2.
size();
5710 if (context == FromString)
5715 for (
int i=0; i<limit; ++i) {
5717 if (i > bestCount) {
5735 if (usedDay && bestMatch != -1) {
5744 #endif // QT_NO_TEXTDATE 5762 if (s.
type != AmPmSection) {
5763 qWarning(
"QDateTimeParser::findAmPm Internal error");
5769 return PossibleBoth;
5772 int size = sectionMaxSize(index);
5779 ampm[amindex] = getAmPmText(AmText, s.
count == 1 ? UpperCase : LowerCase);
5780 ampm[pmindex] = getAmPmText(PmText, s.
count == 1 ? UpperCase : LowerCase);
5781 for (
int i=0; i<2; ++i)
5782 ampm[i].truncate(size);
5784 QDTPDEBUG <<
"findAmPm" << str << ampm[0] << ampm[1];
5787 str = ampm[amindex];
5790 str = ampm[pmindex];
5792 }
else if (context == FromString || (str.
count(space) == 0 && str.
size() >= size)) {
5797 bool broken[2] = {
false,
false};
5798 for (
int i=0; i<size; ++i) {
5799 if (str.
at(i) != space) {
5800 for (
int j=0; j<2; ++j) {
5802 int index = ampm[j].indexOf(str.
at(i));
5804 <<
"in" << ampm[j] <<
"and got" <<
index;
5807 index = ampm[j].indexOf(str.
at(i).
toLower());
5809 <<
"in" << ampm[j] <<
"and got" <<
index;
5811 index = ampm[j].indexOf(str.
at(i).
toUpper());
5813 <<
"in" << ampm[j] <<
"and got" <<
index;
5817 if (broken[amindex] && broken[pmindex]) {
5823 str[i] = ampm[j].
at(index);
5826 ampm[j].remove(index, 1);
5831 if (!broken[pmindex] && !broken[amindex])
5832 return PossibleBoth;
5833 return (!broken[amindex] ? PossibleAM : PossiblePM);
5849 case MSecSection:
return 999;
5850 case SecondSection:
return 59 * 1000;
5851 case MinuteSection:
return 59 * 60 * 1000;
5852 case Hour24Section:
case Hour12Section:
return 59 * 60 * 60 * 1000;
5855 case DayOfWeekSection:
return 7;
5856 case DaySection:
return 30;
5857 case MonthSection:
return 365 - 31;
5858 case YearSection:
return 9999 * 365;
5859 case YearSection2Digits:
return 100 * 365;
5861 qWarning(
"QDateTimeParser::maxChange() Internal error (%s)",
5862 qPrintable(sectionName(sectionType(index))));
5882 case YearSection2Digits:
5884 if (s != YearSection) {
5885 ret |= AllowPartial;
5887 if (sn.
count != 1) {
5898 ret |= (Numeric|AllowPartial);
5902 case DayOfWeekSection:
5910 qWarning(
"QDateTimeParser::fieldInfo Internal error 2 (%d %s %d)",
5926 return sectionFormat(sn.
type, sn.
count);
5934 case MSecSection: fillChar =
QLatin1Char(
'z');
break;
5935 case SecondSection: fillChar =
QLatin1Char(
's');
break;
5936 case MinuteSection: fillChar =
QLatin1Char(
'm');
break;
5937 case Hour24Section: fillChar =
QLatin1Char(
'H');
break;
5938 case Hour12Section: fillChar =
QLatin1Char(
'h');
break;
5939 case DayOfWeekSection:
5940 case DaySection: fillChar =
QLatin1Char(
'd');
break;
5941 case MonthSection: fillChar =
QLatin1Char(
'M');
break;
5942 case YearSection2Digits:
5943 case YearSection: fillChar =
QLatin1Char(
'y');
break;
5945 qWarning(
"QDateTimeParser::sectionFormat Internal error (%s)",
5950 qWarning(
"QDateTimeParser::sectionFormat Internal error 2");
5955 str.
fill(fillChar, count);
5965 const QDateTime ¤tValue,
int insert)
const 5970 const int size = sectionMaxSize(index);
5971 int val = (int)locale().toUInt(str);
5973 if (sn.
type == YearSection2Digits) {
5976 if (val >= min && val <= max && str.
size() == size) {
5978 }
else if (val > max) {
5980 }
else if (str.
size() == size && val < min) {
5984 const int len = size - str.
size();
5985 for (
int i=0; i<len; ++i) {
5986 for (
int j=0; j<10; ++j) {
5987 if (potentialValue(str +
QLatin1Char(
'0' + j), min, max, index, currentValue, insert)) {
5989 }
else if (insert >= 0) {
5992 if (potentialValue(tmp, min, max, index, currentValue, insert))
6003 Q_ASSERT(current >= getMinimum() && current <= getMaximum());
6011 int min = absoluteMin(index);
6012 setDigit(tmp, index, min);
6013 if (tmp < minimum) {
6014 min = getDigit(minimum, index);
6017 int max = absoluteMax(index, current);
6018 setDigit(tmp, index, max);
6019 if (tmp > maximum) {
6020 max = getDigit(maximum, index);
6022 int pos = cursorPosition() - node.
pos;
6023 if (pos < 0 || pos >= text.
size())
6026 const bool potential = potentialValue(text, min, max, index, current, pos);
6083 #ifndef QT_NO_DATESTRING 6089 const StateNode tmp = parse(text, copy, val,
false);
6110 #endif // QT_NO_DATESTRING 6143 const static TTime UnixEpochOffset(I64LIT(0xdcddb30f2f8000));
6144 const static TInt64 MinimumMillisecondTime(KMinTInt64 / 1000);
6145 const static TInt64 MaximumMillisecondTime(KMaxTInt64 / 1000);
6148 TTimeIntervalMicroSeconds absolute = time.MicroSecondsFrom(UnixEpochOffset);
6153 TTime qt_symbian_QDateTime_To_TTime(
const QDateTime& datetime)
6156 if(absolute > MaximumMillisecondTime)
6157 return TTime(KMaxTInt64);
6158 if(absolute < MinimumMillisecondTime)
6159 return TTime(KMinTInt64);
6160 return TTime(absolute * 1000);
6163 time_t qt_symbian_TTime_To_time_t(
const TTime&
time)
6165 TTimeIntervalSeconds interval;
6166 TInt err = time.SecondsFrom(UnixEpochOffset, interval);
6167 if (err || interval.Int() < 0)
6169 return (
time_t) interval.Int();
6172 TTime qt_symbian_time_t_To_TTime(
time_t time)
6174 return UnixEpochOffset + TTimeIntervalSeconds(time);
6176 #endif //Q_OS_SYMBIAN 6178 #endif // QT_BOOTSTRAPPED static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
QDateTime addSecs(int secs) const
Returns a QDateTime object containing a datetime s seconds later than the datetime of this object (or...
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int dayOfWeek() const
Returns the weekday (1 = Monday to 7 = Sunday) for this date.
The QDebug class provides an output stream for debugging information.
int daysTo(const QDateTime &) const
Returns the number of days from this datetime to the other datetime.
#define QDATETIMEEDIT_DATE_MAX
static void appendSeparator(QStringList *list, const QString &string, int from, int size, int lastQuote)
int absoluteMin(int index) const
qint64 toMSecsSinceEpoch() const
Returns the datetime as the number of milliseconds that have passed since 1970-01-01T00:00:00.
bool isNull() const
Returns true if both the date and the time are null; otherwise returns false.
int daysTo(const QDate &) const
Returns the number of days from this date to d (which is negative if d is earlier than this date)...
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
int findAmPm(QString &str1, int index, int *used=0) const
#define QT_END_NAMESPACE
This macro expands to.
StateNode parse(QString &input, int &cursorPosition, const QDateTime ¤tValue, bool fixup) const
bool isNull() const
Returns true if the date is null; otherwise returns false.
const QChar at(int i) const
Returns the character at the given index position in the string.
The QRegExp class provides pattern matching using regular expressions.
bool isValid() const
Returns true if this date is valid; otherwise returns false.
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
bool isNull() const
Returns true if the character is the Unicode character 0x0000 ('\0'); otherwise returns false...
static QString fmtDateTime(const QString &f, const QTime *dt=0, const QDate *dd=0)
void start()
Sets this time to the current time.
bool isNull() const
Returns true if the time is null (i.
QDebug & nospace()
Clears the stream's internal flag that records whether the last character was a space and returns a r...
int msecsTo(const QTime &) const
Returns the number of milliseconds from this time to t.
qint64 toMSecsSinceEpoch_helper(qint64 jd, int msecs)
QString monthName(int, FormatType format=LongFormat) const
Returns the localized name of month, in the format specified by type.
QString & replace(int i, int len, QChar after)
uint toUInt(const QString &s, bool *ok=0, int base=0) const
Returns the unsigned int represented by the localized string s, using base base.
void chop(int n)
Removes n characters from the end of the string.
int length() const
Returns the number of characters in this string.
QString & prepend(QChar c)
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
int absoluteMax(int index, const QDateTime &value=QDateTime()) const
\
bool parseFormat(const QString &format)
uint toTime_t() const
Returns the datetime as the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC).
virtual QString getAmPmText(AmPm ap, Case cs) const
QDateTime()
Constructs a null datetime (i.e.
int weekNumber(int *yearNum=0) const
Returns the week number (1 to 53), and stores the year in {yearNumber} unless yearNumber is null (the...
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
int day() const
Returns the day of the month (1 to 31) of this date.
static LibLoadStatus status
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
The QDate class provides date functions.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static void getDateFromJulianDay(uint julianDay, int *year, int *month, int *day)
int msec() const
Returns the millisecond part (0 to 999) of the time.
static uint msecsFromDecomposed(int hour, int minute, int sec, int msec=0)
void getDate(int *year, int *month, int *day)
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
int secsTo(const QTime &) const
Returns the number of seconds from this time to t.
static void localToUtc(QDate &date, QTime &time, int isdst)
virtual QDateTime getMaximum() const
static QString shortDayName(int weekday)
Returns the short version of the name of the weekday.
int daysInYear() const
Returns the number of days in the year (365 or 366) for this date.
QDate()
Constructs a null date.
int sectionMaxSize(int index) const
The QString class provides a Unicode character string.
int maxChange(int s) const
Max number of units that can be changed by this section.
#define QDATETIMEEDIT_TIME_MIN
Q_DECL_CONSTEXPR T qAbs(const T &t)
QDate addYears(int years) const
Returns a QDate object containing a date nyears later than the date of this object (or earlier if nye...
The QVector class is a template class that provides a dynamic array.
QDate addMonths(int months) const
Returns a QDate object containing a date nmonths later than the date of this object (or earlier if nm...
bool operator<(const QDateTime &other) const
Returns true if this datetime is earlier than the other datetime; otherwise returns false...
static const char monthDays[]
static uint julianDayFromDate(int year, int month, int day)
MonthNameType
This enum describes the types of the string representation used for the month name.
The QChar class provides a 16-bit Unicode character.
QTime addSecs(int secs) const
Returns a QTime object containing a time s seconds later than the time of this object (or earlier if ...
QString toString(qlonglong i) const
Returns a localized string representation of i.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
static bool isLeapYear(int year)
Returns true if the specified year is a leap year; otherwise returns false.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Category category() const
Returns the character's category.
int restart()
Sets this time to the current time and returns the number of milliseconds that have elapsed since the...
static QLocale system()
Returns a QLocale object initialized to the system locale.
bool operator==(const QDateTime &other) const
Returns true if this datetime is equal to the other datetime; otherwise returns false.
static QString longMonthName(int month)
Returns the long version of the name of the month.
static QString getFmtString(const QString &f, const QTime *dt=0, const QDate *dd=0, bool am_pm=false)
QDateTime & operator=(const QDateTime &other)
Makes a copy of the other datetime and returns a reference to the copy.
QString sectionFormat(int index) const
static uint gregorianToJulian(int y, int m, int d)
This function has a confusing name and shouldn't be part of the API anyway, since we have toJulian() ...
QDateTime addYears(int years) const
Returns a QDateTime object containing a datetime nyears years later than the datetime of this object ...
QString rightJustified(int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
Returns a string of size() width that contains the fill character followed by the string...
static QDateTime fromString(const QString &s, Qt::DateFormat f=Qt::TextDate)
Returns the QDateTime represented by the string, using the format given, or an invalid datetime if th...
void append(const T &t)
Inserts value at the end of the list.
The QTime class provides clock time functions.
int dayOfYear() const
Returns the day of the year (1 to 365 or 366 on leap years) for this date.
bool skipToNextSection(int section, const QDateTime ¤t, const QString §ionText) const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Q_GUI_EXPORT EGLDisplay display()
static QDate fixedDate(int y, int m, int d)
static int countRepeat(const QString &str, int index, int maxCount)
Parses the format newFormat.
void setTime_t(uint secsSince1Jan1970UTC)
Sets the date and time given the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC).
static uint julianDayFromGregorianDate(int year, int month, int day)
QString sectionName(int s) const
For debugging.
void setDate(const QDate &date)
Sets the date part of this datetime to date.
void truncate(int pos)
Truncates the string at the given position index.
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
qint64 msecsTo(const QDateTime &) const
Returns the number of milliseconds from this datetime to the other datetime.
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
int size() const
Returns the number of characters in this string.
static QDate currentDate()
Returns the current date, as reported by the system clock.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
int sectionSize(int index) const
Returns the size of section s.
static const char *const qt_shortMonthNames[]
void setTime(const QTime &time)
Sets the time part of this datetime to time.
QDateTime toLocalTime() const
Returns a datetime containing the date and time information in this datetime, but specified using the...
QTime()
Constructs a null time object.
const T & at(int i) const
Returns the item at index position i in the list.
virtual QDateTime getMinimum() const
The QStringList class provides a list of strings.
int secsTo(const QDateTime &) const
Returns the number of seconds from this datetime to the other datetime.
static QDateTime currentDateTimeUtc()
Returns the current datetime, as reported by the system clock, in UTC.
const SectionNode & sectionNode(int index) const
Returns the sectionNode for the Section s.
int findDay(const QString &str1, int intDaystart, int sectionIndex, QString *dayName=0, int *used=0) const
Q_CORE_EXPORT void qWarning(const char *,...)
int second() const
Returns the second part (0 to 59) of the time.
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QString stateName(int s) const
For debugging.
static qint64 currentMSecsSinceEpoch()
Returns the number of milliseconds since 1970-01-01T00:00:00 Universal Coordinated Time...
void getUTC(QDate &outDate, QTime &outTime) const
QDateTime addMonths(int months) const
Returns a QDateTime object containing a datetime nmonths months later than the datetime of this objec...
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
void setTimeSpec(Qt::TimeSpec spec)
Sets the time specification used in this datetime to spec.
QDate addDays(int days) const
Returns a QDate object containing a date ndays later than the date of this object (or earlier if nday...
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
int getDigit(const QDateTime &dt, int index) const
Gets the digit from a datetime.
QDateTime addMSecs(qint64 msecs) const
Returns a QDateTime object containing a datetime msecs miliseconds later than the datetime of this ob...
int minute() const
Returns the minute part (0 to 59) of the time.
The State element defines configurations of objects and properties.
#define QDATETIMEEDIT_TIME_MAX
int parseSection(const QDateTime ¤tValue, int sectionIndex, QString &txt, int &cursorPosition, int index, QDateTimeParser::State &state, int *used=0) const
The QStringRef class provides a thin wrapper around QString substrings.
bool setDate(int year, int month, int day)
Sets the date's year, month, and day.
static const int UpperYear
static QTime fromString(const QString &s, Qt::DateFormat f=Qt::TextDate)
Returns the time represented in the string as a QTime using the format given, or an invalid time if t...
bool isUpper() const
Returns true if the character is an uppercase letter, i.
int version() const
Returns the version number of the data serialization format.
static QDateTime fromMSecsSinceEpoch(qint64 msecs)
Returns a datetime whose date and time are the number of milliseconds, msecs, that have passed since ...
static QDateTimePrivate::Spec utcToLocal(QDate &date, QTime &time)
#define QDATETIMEEDIT_DATE_MIN
const char * constData() const
Returns a pointer to the data stored in the byte array.
QDate date() const
Returns the date part of the datetime.
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the time as a string.
int toJulianDay() const
Converts the date to a Julian day.
int findMonth(const QString &str1, int monthstart, int sectionIndex, QString *monthName=0, int *used=0) const
static QString unquote(const QString &str)
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
int daysInMonth() const
Returns the number of days in the month (28 to 31) for this date.
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
static QDateTime addMSecs(const QDateTime &dt, qint64 msecs)
QDateTime addDays(int days) const
Returns a QDateTime object containing a datetime ndays days later than the datetime of this object (o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
static bool hasUnquotedAP(const QString &f)
The QDateTime class provides date and time functions.
int utcOffset
The offset in seconds.
~QDateTime()
Destroys the datetime.
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
void clear()
Clears the contents of the string and makes it empty.
static QTime currentTime()
Returns the current time as reported by the system clock.
static QDate adjustDate(QDate date)
Section sectionType(int index) const
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
bool setDigit(QDateTime &t, int index, int newval) const
Sets a digit in a datetime.
friend Q_CORE_EXPORT QDataStream & operator>>(QDataStream &, QDateTime &)
Reads a datetime from the stream in into dateTime.
#define st(var, type, card)
static int fromShortMonthName(const QString &monthName)
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
static QDate fromString(const QString &s, Qt::DateFormat f=Qt::TextDate)
Returns the QDate represented by the string, using the format given, or an invalid date if the string...
Qt::TimeSpec timeSpec() const
Returns the time specification of the datetime.
static QDateTime fromTime_t(uint secsSince1Jan1970UTC)
Returns a datetime whose date and time are the number of seconds that have passed since 1970-01-01T00...
Spec getLocal(QDate &outDate, QTime &outTime) const
QString standaloneMonthName(int, FormatType format=LongFormat) const
Returns the localized name of month that is used as a standalone text, in the format specified by typ...
QString & fill(QChar c, int size=-1)
Sets every character in the string to character ch.
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
static QDateTime currentDateTime()
Returns the current datetime, as reported by the system clock, in the local time zone.
bool setYMD(int y, int m, int d)
Sets the date's year y, month m, and day d.
bool potentialValue(const QString &str, int min, int max, int index, const QDateTime ¤tValue, int insert) const
char toLatin1() const
Returns the Latin-1 character equivalent to the QChar, or 0.
static void julianToGregorian(uint jd, int &y, int &m, int &d)
This function has a confusing name and shouldn't be part of the API anyway, since we have toJulian() ...
friend Q_CORE_EXPORT QDataStream & operator<<(QDataStream &, const QDateTime &)
Writes dateTime to the out stream.
QTime addMSecs(int ms) const
Returns a QTime object containing a time ms milliseconds later than the time of this object (or earli...
static QString shortMonthName(int month)
Returns the short version of the name of the month.
int year() const
Returns the year of this date.
QExplicitlySharedDataPointer< QDateTimePrivate > d
static const int LowerYear
QString dayName(int, FormatType format=LongFormat) const
Returns the localized name of the day (where 1 represents Monday, 2 represents Tuesday and so on)...
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
QTime time() const
Returns the time part of the datetime.
QDateTime toTimeSpec(Qt::TimeSpec spec) const
Returns a copy of this datetime configured to use the given time specification.
The QDataStream class provides serialization of binary data to a QIODevice.
QString sectionText(int sectionIndex) const
static QString longDayName(int weekday)
Returns the long version of the name of the weekday.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool fromString(const QString &text, QDate *date, QTime *time) const
FieldInfo fieldInfo(int index) const
static const KeyPair *const end
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
#define qPrintable(string)
int sectionPos(int index) const
Returns the starting position for section s.
QString & insert(int i, QChar c)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the date as a string.
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void setMSecsSinceEpoch(qint64 msecs)
Sets the date and time given the number of milliseconds,msecs, that have passed since 1970-01-01T00:0...
bool setHMS(int h, int m, int s, int ms=0)
Sets the time to hour h, minute m, seconds s and milliseconds ms.
const QChar at(int i) const
Returns the character at the given index position in the string reference.
Q_DECL_CONSTEXPR int qRound(qreal d)
static bool equal(const QChar *a, int l, const char *b)
bool isValid() const
Returns true if the time is valid; otherwise returns false.
int hour() const
Returns the hour part (0 to 23) of the time.
void setUtcOffset(int seconds)
QString standaloneDayName(int, FormatType format=LongFormat) const
Returns the localized name of the day (where 1 represents Monday, 2 represents Tuesday and so on) tha...