Simplify textdate/datestring #if-ery
Since datestring implies textdate, we don't need to check the latter inside the #if-ery of the former. Change-Id: I01e648245bc7707db024eac925092ed816173781 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
6bac3552ac
commit
45967dfbd8
@ -1098,9 +1098,8 @@ QString QDate::longDayName(int weekday, MonthNameType type)
|
||||
}
|
||||
#endif // textdate && deprecated
|
||||
|
||||
#if QT_CONFIG(datestring)
|
||||
#if QT_CONFIG(datestring) // depends on, so implies, textdate
|
||||
|
||||
#if QT_CONFIG(textdate)
|
||||
static QString toStringTextDate(QDate date, QCalendar cal)
|
||||
{
|
||||
if (date.isValid()) {
|
||||
@ -1119,7 +1118,6 @@ static QString toStringTextDate(QDate date)
|
||||
{
|
||||
return toStringTextDate(date, QCalendar());
|
||||
}
|
||||
#endif // textdate
|
||||
|
||||
static QString toStringIsoDate(const QDate &date)
|
||||
{
|
||||
@ -1193,10 +1191,8 @@ QString QDate::toString(Qt::DateFormat format) const
|
||||
case Qt::RFC2822Date:
|
||||
return QLocale::c().toString(*this, u"dd MMM yyyy");
|
||||
default:
|
||||
#if QT_CONFIG(textdate)
|
||||
case Qt::TextDate:
|
||||
return toStringTextDate(*this);
|
||||
#endif
|
||||
case Qt::ISODate:
|
||||
case Qt::ISODateWithMs:
|
||||
return toStringIsoDate(*this);
|
||||
@ -1292,10 +1288,8 @@ QString QDate::toString(Qt::DateFormat format, QCalendar cal) const
|
||||
case Qt::RFC2822Date:
|
||||
return QLocale::c().toString(*this, QStringView(u"dd MMM yyyy"), cal);
|
||||
default:
|
||||
#ifndef QT_NO_TEXTDATE
|
||||
case Qt::TextDate:
|
||||
return toStringTextDate(*this, cal);
|
||||
#endif
|
||||
case Qt::ISODate:
|
||||
case Qt::ISODateWithMs:
|
||||
return toStringIsoDate(*this);
|
||||
@ -1625,7 +1619,7 @@ qint64 QDate::daysTo(const QDate &d) const
|
||||
\sa QTime::currentTime(), QDateTime::currentDateTime()
|
||||
*/
|
||||
|
||||
#if QT_CONFIG(datestring)
|
||||
#if QT_CONFIG(datestring) // depends on, so implies, textdate
|
||||
namespace {
|
||||
|
||||
struct ParsedInt { int value = 0; bool ok = false; };
|
||||
@ -1680,7 +1674,6 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format)
|
||||
case Qt::RFC2822Date:
|
||||
return rfcDateImpl(string).date;
|
||||
default:
|
||||
#if QT_CONFIG(textdate)
|
||||
case Qt::TextDate: {
|
||||
QVector<QStringRef> parts = string.splitRef(QLatin1Char(' '), QString::SkipEmptyParts);
|
||||
|
||||
@ -1699,7 +1692,6 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format)
|
||||
|
||||
return QDate(year, month, day);
|
||||
}
|
||||
#endif // textdate
|
||||
case Qt::ISODate:
|
||||
// Semi-strict parsing, must be long enough and have punctuators as separators
|
||||
if (string.size() >= 10 && string.at(4).isPunct() && string.at(7).isPunct()
|
||||
@ -2014,7 +2006,7 @@ int QTime::msec() const
|
||||
return ds() % 1000;
|
||||
}
|
||||
|
||||
#if QT_CONFIG(datestring)
|
||||
#if QT_CONFIG(datestring) // depends on, so implies, textdate
|
||||
/*!
|
||||
\overload
|
||||
|
||||
@ -2347,7 +2339,7 @@ int QTime::msecsTo(const QTime &t) const
|
||||
\sa QDateTime::currentDateTime(), QDateTime::currentDateTimeUtc()
|
||||
*/
|
||||
|
||||
#if QT_CONFIG(datestring)
|
||||
#if QT_CONFIG(datestring) // depends on, so implies, textdate
|
||||
|
||||
static QTime fromIsoTimeString(QStringView string, Qt::DateFormat format, bool *isMidnight24)
|
||||
{
|
||||
@ -4292,7 +4284,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if QT_CONFIG(datestring)
|
||||
#if QT_CONFIG(datestring) // depends on, so implies, textdate
|
||||
/*!
|
||||
\fn QString QDateTime::toString(Qt::DateFormat format) const
|
||||
|
||||
@ -4365,7 +4357,6 @@ QString QDateTime::toString(Qt::DateFormat format) const
|
||||
return buf;
|
||||
}
|
||||
default:
|
||||
#if QT_CONFIG(textdate)
|
||||
case Qt::TextDate: {
|
||||
const QPair<QDate, QTime> p = getDateTime(d);
|
||||
buf = p.first.toString(Qt::TextDate);
|
||||
@ -4376,11 +4367,11 @@ QString QDateTime::toString(Qt::DateFormat format) const
|
||||
switch (timeSpec()) {
|
||||
case Qt::LocalTime:
|
||||
break;
|
||||
# if QT_CONFIG(timezone)
|
||||
#if QT_CONFIG(timezone)
|
||||
case Qt::TimeZone:
|
||||
buf += QLatin1Char(' ') + d->m_timeZone.abbreviation(*this);
|
||||
break;
|
||||
# endif
|
||||
#endif
|
||||
default:
|
||||
buf += QLatin1String(" GMT");
|
||||
if (getSpec(d) == Qt::OffsetFromUTC)
|
||||
@ -4388,7 +4379,6 @@ QString QDateTime::toString(Qt::DateFormat format) const
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
case Qt::ISODate:
|
||||
case Qt::ISODateWithMs: {
|
||||
const QPair<QDate, QTime> p = getDateTime(d);
|
||||
@ -5202,7 +5192,7 @@ int QDateTime::utcOffset() const
|
||||
}
|
||||
#endif // QT_DEPRECATED_SINCE
|
||||
|
||||
#if QT_CONFIG(datestring)
|
||||
#if QT_CONFIG(datestring) // depends on, so implies, textdate
|
||||
|
||||
/*!
|
||||
Returns the QDateTime represented by the \a string, using the
|
||||
@ -5306,7 +5296,6 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)
|
||||
date = date.addDays(1);
|
||||
return QDateTime(date, time, spec, offset);
|
||||
}
|
||||
#if QT_CONFIG(textdate)
|
||||
case Qt::TextDate: {
|
||||
QVector<QStringRef> parts = string.splitRef(QLatin1Char(' '), QString::SkipEmptyParts);
|
||||
|
||||
@ -5412,7 +5401,6 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)
|
||||
return QDateTime(date, time, Qt::UTC);
|
||||
}
|
||||
}
|
||||
#endif // textdate
|
||||
}
|
||||
|
||||
return QDateTime();
|
||||
|
Loading…
Reference in New Issue
Block a user