diff options
-rw-r--r-- | src/corelib/configure.cmake | 1 | ||||
-rw-r--r-- | src/corelib/configure.json | 1 | ||||
-rw-r--r-- | src/corelib/time/qdatetimeparser.cpp | 20 | ||||
-rw-r--r-- | src/corelib/time/qdatetimeparser_p.h | 6 | ||||
-rw-r--r-- | src/network/access/qftp.cpp | 6 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessftpbackend.cpp | 4 | ||||
-rw-r--r-- | src/widgets/configure.cmake | 2 | ||||
-rw-r--r-- | src/widgets/configure.json | 2 | ||||
-rw-r--r-- | tests/auto/corelib/time/qdate/tst_qdate.cpp | 16 | ||||
-rw-r--r-- | tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp | 60 | ||||
-rw-r--r-- | tests/auto/corelib/time/qtime/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/corelib/time/qtime/qtime.pro | 2 | ||||
-rw-r--r-- | tests/auto/corelib/time/qtime/tst_qtime.cpp | 9 |
13 files changed, 70 insertions, 61 deletions
diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index 2637e2abfc..7f565437cd 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -911,6 +911,7 @@ qt_feature("datetimeparser" PRIVATE SECTION "Utilities" LABEL "QDateTimeParser" PURPOSE "Provides support for parsing date-time texts." + CONDITION QT_FEATURE_datestring ) qt_feature("commandlineparser" PUBLIC SECTION "Utilities" diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 7aa0e0b177..2610392ad1 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -981,6 +981,7 @@ "label": "QDateTimeParser", "purpose": "Provides support for parsing date-time texts.", "section": "Utilities", + "condition": "features.datestring", "output": [ "privateFeature" ] }, "commandlineparser": { diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index dd9e1507e4..ba26398772 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -79,12 +79,8 @@ QDateTimeParser::~QDateTimeParser() int QDateTimeParser::getDigit(const QDateTime &t, int index) const { if (index < 0 || index >= sectionNodes.size()) { -#if QT_CONFIG(datestring) qWarning("QDateTimeParser::getDigit() Internal error (%ls %d)", qUtf16Printable(t.toString()), index); -#else - qWarning("QDateTimeParser::getDigit() Internal error (%d)", index); -#endif return -1; } const SectionNode &node = sectionNodes.at(index); @@ -105,12 +101,8 @@ int QDateTimeParser::getDigit(const QDateTime &t, int index) const default: break; } -#if QT_CONFIG(datestring) qWarning("QDateTimeParser::getDigit() Internal error 2 (%ls %d)", qUtf16Printable(t.toString()), index); -#else - qWarning("QDateTimeParser::getDigit() Internal error 2 (%d)", index); -#endif return -1; } @@ -129,12 +121,8 @@ int QDateTimeParser::getDigit(const QDateTime &t, int index) const bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const { if (index < 0 || index >= sectionNodes.size()) { -#if QT_CONFIG(datestring) qWarning("QDateTimeParser::setDigit() Internal error (%ls %d %d)", qUtf16Printable(v.toString()), index, newVal); -#else - qWarning("QDateTimeParser::setDigit() Internal error (%d %d)", index, newVal); -#endif return false; } @@ -743,9 +731,6 @@ QString QDateTimeParser::sectionText(int sectionIndex) const return sectionText(displayText(), sectionIndex, sn.pos); } - -#if QT_CONFIG(datestring) - QDateTimeParser::ParsedSection QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionIndex, int offset, QString *text) const @@ -1867,7 +1852,6 @@ QDateTimeParser::AmPmFinder QDateTimeParser::findAmPm(QString &str, int sectionI return PossibleBoth; return (!broken[amindex] ? PossibleAM : PossiblePM); } -#endif // datestring /*! \internal @@ -2098,7 +2082,6 @@ QString QDateTimeParser::stateName(State s) const } } -#if QT_CONFIG(datestring) bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) const { QDateTime datetime; @@ -2137,7 +2120,6 @@ bool QDateTimeParser::fromString(const QString &t, QDateTime* datetime) const return true; } -#endif // datestring QDateTime QDateTimeParser::getMinimum() const { diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h index 43fe4f261e..94358b092d 100644 --- a/src/corelib/time/qdatetimeparser_p.h +++ b/src/corelib/time/qdatetimeparser_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -177,11 +177,9 @@ public: LowerCase }; -#if QT_CONFIG(datestring) StateNode parse(QString input, int position, const QDateTime &defaultValue, bool fixup) const; bool fromString(const QString &text, QDate *date, QTime *time) const; bool fromString(const QString &text, QDateTime* datetime) const; -#endif bool parseFormat(const QString &format); enum FieldInfoFlag { @@ -201,7 +199,6 @@ public: private: int sectionMaxSize(Section s, int count) const; QString sectionText(const QString &text, int sectionIndex, int index) const; -#if QT_CONFIG(datestring) StateNode scanString(const QDateTime &defaultValue, bool fixup, QString *input) const; struct ParsedSection { @@ -236,7 +233,6 @@ private: PossibleBoth = 4 }; AmPmFinder findAmPm(QString &str, int index, int *used = nullptr) const; -#endif // datestring bool potentialValue(QStringView str, int min, int max, int index, const QDateTime ¤tValue, int insert) const; diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index ffe0ae7b6b..878f55f604 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtNetwork module of the Qt Toolkit. @@ -517,7 +517,7 @@ static void _q_parseUnixDir(const QStringList &tokens, const QString &userName, // Resolve the modification date by parsing all possible formats QDateTime dateTime; int n = 0; -#if QT_CONFIG(datestring) +#if QT_CONFIG(datetimeparser) do { dateTime = QLocale::c().toDateTime(dateString, formats.at(n++)); } while (n < formats.size() && (!dateTime.isValid())); @@ -592,7 +592,7 @@ static void _q_parseDosDir(const QStringList &tokens, const QString &userName, Q info->setWritable(info->isFile()); QDateTime dateTime; -#if QT_CONFIG(datestring) +#if QT_CONFIG(datetimeparser) dateTime = QLocale::c().toDateTime(tokens.at(1), QLatin1String("MM-dd-yy hh:mmAP")); if (dateTime.date().year() < 1971) { dateTime.setDate(QDate(dateTime.date().year() + 100, diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index 7f5439a16e..7c353b5c47 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtNetwork module of the Qt Toolkit. @@ -424,7 +424,7 @@ void QNetworkAccessFtpBackend::ftpRawCommandReply(int code, const QString &text) if (id == sizeId) { // reply to the size command setHeader(QNetworkRequest::ContentLengthHeader, text.toLongLong()); -#if QT_CONFIG(datestring) +#if QT_CONFIG(datetimeparser) } else if (id == mdtmId) { QDateTime dt = QDateTime::fromString(text, QLatin1String("yyyyMMddHHmmss")); setHeader(QNetworkRequest::LastModifiedHeader, dt); diff --git a/src/widgets/configure.cmake b/src/widgets/configure.cmake index a250a3f888..02fbb7137b 100644 --- a/src/widgets/configure.cmake +++ b/src/widgets/configure.cmake @@ -100,7 +100,7 @@ qt_feature("datetimeedit" PUBLIC SECTION "Widgets" LABEL "QDateTimeEdit" PURPOSE "Supports editing dates and times." - CONDITION QT_FEATURE_calendarwidget AND QT_FEATURE_datestring AND QT_FEATURE_textdate AND QT_FEATURE_datetimeparser + CONDITION QT_FEATURE_calendarwidget AND QT_FEATURE_datetimeparser ) qt_feature_definition("datetimeedit" "QT_NO_DATETIMEEDIT" NEGATE VALUE "1") qt_feature("stackedwidget" PUBLIC diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 89a319e897..5b984c3bf2 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -121,7 +121,7 @@ "label": "QDateTimeEdit", "purpose": "Supports editing dates and times.", "section": "Widgets", - "condition": "features.calendarwidget && features.datestring && features.textdate && features.datetimeparser", + "condition": "features.calendarwidget && features.datetimeparser", "output": [ "publicFeature", "feature" ] }, "stackedwidget": { diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 743cac4d3c..6c7283709c 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -78,19 +78,25 @@ private Q_SLOTS: void operator_gt_eq(); void operator_insert_extract_data(); void operator_insert_extract(); +#if QT_CONFIG(datestring) void fromStringDateFormat_data(); void fromStringDateFormat(); +# if QT_CONFIG(datetimeparser) void fromStringFormat_data(); void fromStringFormat(); +# endif void toStringFormat_data(); void toStringFormat(); void toStringDateFormat_data(); void toStringDateFormat(); +#endif void isLeapYear(); void yearsZeroToNinetyNine(); void printNegativeYear_data() const; void printNegativeYear() const; - void roundtripGermanLocale() const; +#if QT_CONFIG(datestring) + void roundtripString() const; +#endif void roundtrip() const; void qdebug() const; private: @@ -1089,6 +1095,7 @@ void tst_QDate::operator_insert_extract() QCOMPARE(deserialised, date); } +#if QT_CONFIG(datetimeparser) void tst_QDate::fromStringDateFormat_data() { QTest::addColumn<QString>("dateStr"); @@ -1295,7 +1302,9 @@ void tst_QDate::fromStringFormat() QDate dt = QDate::fromString(string, format); QCOMPARE(dt, expected); } +#endif // datetimeparser +#if QT_CONFIG(datestring) void tst_QDate::toStringFormat_data() { QTest::addColumn<QDate>("t"); @@ -1342,6 +1351,7 @@ void tst_QDate::toStringDateFormat() QCOMPARE(date.toString(format), expectedStr); } +#endif // datestring void tst_QDate::isLeapYear() { @@ -1448,7 +1458,8 @@ void tst_QDate::printNegativeYear() const QCOMPARE(date.toString(QLatin1String("yyyy")), expect); } -void tst_QDate::roundtripGermanLocale() const +#if QT_CONFIG(datestring) +void tst_QDate::roundtripString() const { /* This code path should not result in warnings. */ const QDate theDate(QDate::currentDate()); @@ -1457,6 +1468,7 @@ void tst_QDate::roundtripGermanLocale() const const QDateTime theDateTime(QDateTime::currentDateTime()); theDateTime.fromString(theDateTime.toString(Qt::TextDate), Qt::TextDate); } +#endif void tst_QDate::roundtrip() const { diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index 32d3b08376..877f29a094 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -72,18 +72,18 @@ private Q_SLOTS: void fromSecsSinceEpoch(); void fromMSecsSinceEpoch_data(); void fromMSecsSinceEpoch(); +#if QT_CONFIG(datestring) void toString_isoDate_data(); void toString_isoDate(); void toString_isoDate_extra(); -#if QT_CONFIG(datestring) void toString_textDate_data(); void toString_textDate(); void toString_textDate_extra(); -#endif void toString_rfcDate_data(); void toString_rfcDate(); void toString_enumformat(); void toString_strformat(); +#endif void addDays(); void addMonths(); void addMonths_data(); @@ -111,12 +111,16 @@ private Q_SLOTS: void currentDateTime(); void currentDateTimeUtc(); void currentDateTimeUtc2(); +#if QT_CONFIG(datestring) void fromStringDateFormat_data(); void fromStringDateFormat(); +# if QT_CONFIG(datetimeparser) void fromStringStringFormat_data(); void fromStringStringFormat(); void fromStringStringFormat_localTimeZone_data(); void fromStringStringFormat_localTimeZone(); +# endif +#endif void offsetFromUtc(); void setOffsetFromUtc(); @@ -130,7 +134,7 @@ private Q_SLOTS: void fewDigitsInYear() const; void printNegativeYear() const; -#if QT_CONFIG(textdate) +#if QT_CONFIG(datetimeparser) void roundtripTextDate() const; #endif void utcOffsetLessThan() const; @@ -280,13 +284,13 @@ QString tst_QDateTime::str( int y, int month, int d, int h, int min, int s ) return QDateTime( QDate(y, month, d), QTime(h, min, s) ).toString( Qt::ISODate ); } -QDateTime tst_QDateTime::dt( const QString& str ) +QDateTime tst_QDateTime::dt(const QString &text) { - if ( str == "INVALID" ) { - return QDateTime(); - } else { - return QDateTime::fromString( str, Qt::ISODate ); - } +#if QT_CONFIG(datestring) + if (text != "INVALID") + return QDateTime::fromString(text, Qt::ISODate); +#endif + return QDateTime(); } void tst_QDateTime::ctor() @@ -801,6 +805,7 @@ void tst_QDateTime::fromSecsSinceEpoch() #endif // timezone } +#if QT_CONFIG(datestring) // depends on, so implies, textdate void tst_QDateTime::toString_isoDate_data() { QTest::addColumn<QDateTime>("datetime"); @@ -883,7 +888,6 @@ void tst_QDateTime::toString_isoDate_extra() #endif // timezone } -#if QT_CONFIG(datestring) // depends on textdate void tst_QDateTime::toString_textDate_data() { QTest::addColumn<QDateTime>("datetime"); @@ -914,12 +918,14 @@ void tst_QDateTime::toString_textDate() QString result = datetime.toString(Qt::TextDate); QCOMPARE(result, expected); +#if QT_CONFIG(datetimeparser) QDateTime resultDatetime = QDateTime::fromString(result, Qt::TextDate); QCOMPARE(resultDatetime, datetime); QCOMPARE(resultDatetime.date(), datetime.date()); QCOMPARE(resultDatetime.time(), datetime.time()); QCOMPARE(resultDatetime.timeSpec(), datetime.timeSpec()); QCOMPARE(resultDatetime.offsetFromUtc(), datetime.offsetFromUtc()); +#endif } void tst_QDateTime::toString_textDate_extra() @@ -976,7 +982,6 @@ void tst_QDateTime::toString_textDate_extra() dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC); QVERIFY(endsWithGmt(dt)); } -#endif // datestring void tst_QDateTime::toString_rfcDate_data() { @@ -1025,15 +1030,25 @@ void tst_QDateTime::toString_enumformat() { QDateTime dt1(QDate(1995, 5, 20), QTime(12, 34, 56)); -#if QT_CONFIG(textdate) QString str1 = dt1.toString(Qt::TextDate); QVERIFY(!str1.isEmpty()); // It's locale-dependent everywhere -#endif QString str2 = dt1.toString(Qt::ISODate); QCOMPARE(str2, QString("1995-05-20T12:34:56")); } +void tst_QDateTime::toString_strformat() +{ + // Most tests are in QLocale, just test that the api works. + QDate testDate(2013, 1, 1); + QTime testTime(1, 2, 3); + QDateTime testDateTime(testDate, testTime, Qt::UTC); + QCOMPARE(testDate.toString("yyyy-MM-dd"), QString("2013-01-01")); + QCOMPARE(testTime.toString("hh:mm:ss"), QString("01:02:03")); + QCOMPARE(testDateTime.toString("yyyy-MM-dd hh:mm:ss t"), QString("2013-01-01 01:02:03 UTC")); +} +#endif // datestring + void tst_QDateTime::addDays() { for (int pass = 0; pass < 2; ++pass) { @@ -2089,24 +2104,13 @@ void tst_QDateTime::operator_insert_extract() } } -void tst_QDateTime::toString_strformat() -{ - // Most tests are in QLocale, just test that the api works. - QDate testDate(2013, 1, 1); - QTime testTime(1, 2, 3); - QDateTime testDateTime(testDate, testTime, Qt::UTC); - QCOMPARE(testDate.toString("yyyy-MM-dd"), QString("2013-01-01")); - QCOMPARE(testTime.toString("hh:mm:ss"), QString("01:02:03")); - QCOMPARE(testDateTime.toString("yyyy-MM-dd hh:mm:ss t"), QString("2013-01-01 01:02:03 UTC")); -} - +#if QT_CONFIG(datestring) void tst_QDateTime::fromStringDateFormat_data() { QTest::addColumn<QString>("dateTimeStr"); QTest::addColumn<Qt::DateFormat>("dateFormat"); QTest::addColumn<QDateTime>("expected"); -#if QT_CONFIG(textdate) // Test Qt::TextDate format. QTest::newRow("text date") << QString::fromLatin1("Tue Jun 17 08:00:10 2003") << Qt::TextDate << QDateTime(QDate(2003, 6, 17), QTime(8, 0, 10, 0), Qt::LocalTime); @@ -2186,7 +2190,6 @@ void tst_QDateTime::fromStringDateFormat_data() << QStringLiteral("Sun 1. Dec 13:02:00 1974") << Qt::TextDate << ref; QTest::newRow("month:day") << QStringLiteral("Sun Dec 1 13:02:00 1974") << Qt::TextDate << ref; -#endif // textdate // Test Qt::ISODate format. QTest::newRow("trailing space") // QTBUG-80445 @@ -2453,6 +2456,7 @@ void tst_QDateTime::fromStringDateFormat() QCOMPARE(dateTime, expected); } +# if QT_CONFIG(datetimeparser) void tst_QDateTime::fromStringStringFormat_data() { QTest::addColumn<QString>("string"); @@ -2688,6 +2692,8 @@ void tst_QDateTime::fromStringStringFormat_localTimeZone() TimeZoneRollback useZone(localTimeZone); // enforce test's time zone fromStringStringFormat(); // call basic fromStringStringFormat test } +# endif // datetimeparser +#endif // datestring void tst_QDateTime::offsetFromUtc() { @@ -2999,7 +3005,7 @@ void tst_QDateTime::printNegativeYear() const } } -#if QT_CONFIG(textdate) +#if QT_CONFIG(datetimeparser) void tst_QDateTime::roundtripTextDate() const { /* This code path should not result in warnings. */ diff --git a/tests/auto/corelib/time/qtime/CMakeLists.txt b/tests/auto/corelib/time/qtime/CMakeLists.txt index d62858b6d0..0bd4b611e0 100644 --- a/tests/auto/corelib/time/qtime/CMakeLists.txt +++ b/tests/auto/corelib/time/qtime/CMakeLists.txt @@ -10,4 +10,6 @@ add_qt_test(tst_qtime DEFINES QT_NO_FOREACH QT_NO_KEYWORDS + PUBLIC_LIBRARIES + Qt::CorePrivate ) diff --git a/tests/auto/corelib/time/qtime/qtime.pro b/tests/auto/corelib/time/qtime/qtime.pro index 7d2df93cb0..f9daacf5d1 100644 --- a/tests/auto/corelib/time/qtime/qtime.pro +++ b/tests/auto/corelib/time/qtime/qtime.pro @@ -1,5 +1,5 @@ CONFIG += testcase TARGET = tst_qtime -QT = core testlib +QT = core-private testlib SOURCES = tst_qtime.cpp DEFINES += QT_NO_KEYWORDS QT_NO_FOREACH diff --git a/tests/auto/corelib/time/qtime/tst_qtime.cpp b/tests/auto/corelib/time/qtime/tst_qtime.cpp index 764b2b8351..eaa90971f2 100644 --- a/tests/auto/corelib/time/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/time/qtime/tst_qtime.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ +#include <private/qglobal_p.h> #include <QtTest/QtTest> #include "qdatetime.h" #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -57,14 +58,18 @@ private Q_SLOTS: void operator_gt(); void operator_lt_eq(); void operator_gt_eq(); +#if QT_CONFIG(datestring) +# if QT_CONFIG(datetimeparser) void fromStringFormat_data(); void fromStringFormat(); +# endif void fromStringDateFormat_data(); void fromStringDateFormat(); void toStringDateFormat_data(); void toStringDateFormat(); void toStringFormat_data(); void toStringFormat(); +#endif void msecsSinceStartOfDay_data(); void msecsSinceStartOfDay(); @@ -530,6 +535,8 @@ void tst_QTime::operator_gt_eq() QVERIFY( t1 >= t2 ); } +#if QT_CONFIG(datestring) +# if QT_CONFIG(datetimeparser) void tst_QTime::fromStringFormat_data() { QTest::addColumn<QString>("string"); @@ -562,6 +569,7 @@ void tst_QTime::fromStringFormat() QTime dt = QTime::fromString(string, format); QCOMPARE(dt, expected); } +# endif // datetimeparser void tst_QTime::fromStringDateFormat_data() { @@ -750,6 +758,7 @@ void tst_QTime::toStringFormat() QCOMPARE( t.toString( format ), str ); } +#endif // datestring void tst_QTime::msecsSinceStartOfDay_data() { |