summaryrefslogtreecommitdiffstats
path: root/src/corelib/time/qdatetimeparser.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-06-23 12:40:55 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2020-07-02 15:35:18 +0200
commit057329c24c00047c8c3e1502a9a8dfa9a4169481 (patch)
tree307ed9e68e004dad434aa7c5a140f56ae0391bcc /src/corelib/time/qdatetimeparser.cpp
parentc30e0c656f34815f7ba5fac33ce58baa421c4289 (diff)
Make feature datetimeparser depend on feature datestring
No client of QDateTimeParser actually uses it unless datestring was enabled, nor is it any use without datestring. Various methods conditioned on datestring are broken unless datetimeparser is enabled. We can't condition public API on datetimeparser, as it's a private feature, but client code can condition use of it on the private feature. All string-to-date/time conversions that use a string format (this includes all locale-specific formats) depend on feature datetimeparser. Change #if-ery (or add it) in all client (including test) code to test the right feature. Tidied up some code in the process. Killed some already-redundant textdate #if-ery. Renamed a test whose name claimed it involved locale, which it doesn't, in the course of #if-ing it. This simplifies the condition for feature datetimeedit (which overtly depended on textdate, redundantly since it depends on datestring which depends on textdate; its dependence on datetimeparser now makes its dependency on datestring also redundant). It also removes the need for assorted datestring checks in QDateTimeParser itself. Change-Id: I5dfe3a977042134b2cfb16cbcc795070634e7adf Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/time/qdatetimeparser.cpp')
-rw-r--r--src/corelib/time/qdatetimeparser.cpp20
1 files changed, 1 insertions, 19 deletions
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 &currentValue, 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
{