Modernize the "datestring" feature
Change-Id: I2236a456fe3758d9054b22e36fe6316f3522d533 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
e226b0f94a
commit
b26cd68bf6
@ -77,6 +77,7 @@
|
||||
#define QT_CRYPTOGRAPHICHASH_ONLY_SHA1
|
||||
#define QT_FEATURE_cxx11_random (QT_HAS_INCLUDE(<random>) ? 1 : -1)
|
||||
#define QT_NO_DATASTREAM
|
||||
#define QT_FEATURE_datestring 1
|
||||
#define QT_FEATURE_datetimeparser -1
|
||||
#define QT_FEATURE_etw -1
|
||||
#define QT_FEATURE_getauxval (QT_HAS_INCLUDE(<sys/auxv.h>) ? 1 : -1)
|
||||
|
@ -267,7 +267,7 @@ QLibraryInfo::licensedProducts()
|
||||
\deprecated
|
||||
This function used to return the installation date for this build of Qt, but now returns a constant date.
|
||||
*/
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
#if QT_DEPRECATED_SINCE(5, 5)
|
||||
QDate
|
||||
QLibraryInfo::buildDate()
|
||||
@ -275,7 +275,7 @@ QLibraryInfo::buildDate()
|
||||
return QDate::fromString(QString::fromLatin1(qt_configure_installation + 12), Qt::ISODate);
|
||||
}
|
||||
#endif
|
||||
#endif //QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
#if defined(Q_CC_INTEL) // must be before GNU, Clang and MSVC because ICC/ICL claim to be them
|
||||
# ifdef __INTEL_CLANG_COMPILER
|
||||
|
@ -56,11 +56,11 @@ public:
|
||||
static QT_DEPRECATED QString licensedProducts();
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
#if QT_DEPRECATED_SINCE(5, 5)
|
||||
static QT_DEPRECATED QDate buildDate();
|
||||
#endif // QT_DEPRECATED_SINCE(5, 5)
|
||||
#endif //QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
static const char * build() Q_DECL_NOTHROW;
|
||||
|
||||
|
@ -445,7 +445,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
|
||||
case QVariant::Double:
|
||||
*str = QString::number(d->data.d, 'g', QLocale::FloatingPointShortest);
|
||||
break;
|
||||
#if !defined(QT_NO_DATESTRING)
|
||||
#if QT_CONFIG(datestring)
|
||||
case QVariant::Date:
|
||||
*str = v_cast<QDate>(d)->toString(Qt::ISODate);
|
||||
break;
|
||||
@ -589,7 +589,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
|
||||
QDate *dt = static_cast<QDate *>(result);
|
||||
if (d->type == QVariant::DateTime)
|
||||
*dt = v_cast<QDateTime>(d)->date();
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
else if (d->type == QVariant::String)
|
||||
*dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate);
|
||||
#endif
|
||||
@ -604,7 +604,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
|
||||
case QVariant::DateTime:
|
||||
*t = v_cast<QDateTime>(d)->time();
|
||||
break;
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
case QVariant::String:
|
||||
*t = QTime::fromString(*v_cast<QString>(d), Qt::ISODate);
|
||||
break;
|
||||
@ -617,7 +617,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
|
||||
case QVariant::DateTime: {
|
||||
QDateTime *dt = static_cast<QDateTime *>(result);
|
||||
switch (d->type) {
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
case QVariant::String:
|
||||
*dt = QDateTime::fromString(*v_cast<QString>(d), Qt::ISODate);
|
||||
break;
|
||||
|
@ -202,7 +202,7 @@ static int fromShortMonthName(const QStringRef &monthName)
|
||||
}
|
||||
#endif // textdate
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
struct ParsedRfcDateTime {
|
||||
QDate date;
|
||||
QTime time;
|
||||
@ -241,7 +241,7 @@ static ParsedRfcDateTime rfcDateImpl(const QString &s)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif // QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
// Return offset in [+-]HH:mm format
|
||||
static QString toOffsetString(Qt::DateFormat format, int offset)
|
||||
@ -254,6 +254,7 @@ static QString toOffsetString(Qt::DateFormat format, int offset)
|
||||
(qAbs(offset) / 60) % 60);
|
||||
}
|
||||
|
||||
#if QT_CONFIG(datestring)
|
||||
// Parse offset in [+-]HH[[:]mm] format
|
||||
static int fromOffsetString(const QStringRef &offsetString, bool *valid) Q_DECL_NOTHROW
|
||||
{
|
||||
@ -298,6 +299,7 @@ static int fromOffsetString(const QStringRef &offsetString, bool *valid) Q_DECL_
|
||||
*valid = true;
|
||||
return sign * ((hour * 60) + minute) * 60;
|
||||
}
|
||||
#endif // datestring
|
||||
|
||||
/*****************************************************************************
|
||||
QDate member functions
|
||||
@ -777,7 +779,7 @@ QString QDate::longDayName(int weekday, MonthNameType type)
|
||||
}
|
||||
#endif // textdate && deprecated
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
|
||||
#if QT_CONFIG(textdate)
|
||||
static QString toStringTextDate(QDate date)
|
||||
@ -939,7 +941,7 @@ QString QDate::toString(const QString &format) const
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
/*!
|
||||
\fn bool QDate::setYMD(int y, int m, int d)
|
||||
@ -1201,7 +1203,7 @@ qint64 QDate::daysTo(const QDate &d) const
|
||||
\sa QTime::currentTime(), QDateTime::currentDateTime()
|
||||
*/
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
/*!
|
||||
\fn QDate QDate::fromString(const QString &string, Qt::DateFormat format)
|
||||
|
||||
@ -1350,7 +1352,7 @@ QDate QDate::fromString(const QString &string, const QString &format)
|
||||
#endif
|
||||
return date;
|
||||
}
|
||||
#endif // QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
/*!
|
||||
\overload
|
||||
@ -1566,7 +1568,7 @@ int QTime::msec() const
|
||||
return ds() % 1000;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
/*!
|
||||
\overload
|
||||
|
||||
@ -1702,7 +1704,7 @@ QString QTime::toString(const QString &format) const
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
/*!
|
||||
Sets the time to hour \a h, minute \a m, seconds \a s and
|
||||
@ -1887,7 +1889,7 @@ int QTime::msecsTo(const QTime &t) const
|
||||
operating system; not all systems provide 1-millisecond accuracy.
|
||||
*/
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
|
||||
static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, bool *isMidnight24)
|
||||
{
|
||||
@ -2069,7 +2071,7 @@ QTime QTime::fromString(const QString &string, const QString &format)
|
||||
return time;
|
||||
}
|
||||
|
||||
#endif // QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
|
||||
/*!
|
||||
@ -3773,7 +3775,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
/*!
|
||||
\fn QString QDateTime::toString(Qt::DateFormat format) const
|
||||
|
||||
@ -3993,7 +3995,7 @@ QString QDateTime::toString(const QString &format) const
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
static inline void massageAdjustedDateTime(const QDateTimeData &d, QDate *date, QTime *time)
|
||||
{
|
||||
@ -4722,7 +4724,7 @@ int QDateTime::utcOffset() const
|
||||
}
|
||||
#endif // QT_DEPRECATED_SINCE
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
|
||||
/*!
|
||||
\fn QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)
|
||||
@ -5071,7 +5073,7 @@ QDateTime QDateTime::fromString(const QString &string, const QString &format)
|
||||
return QDateTime();
|
||||
}
|
||||
|
||||
#endif // QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
/*!
|
||||
\fn QDateTime QDateTime::toLocalTime() const
|
||||
|
||||
@ -5330,7 +5332,7 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime)
|
||||
Date / Time Debug Streams
|
||||
*****************************************************************************/
|
||||
|
||||
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING)
|
||||
#if !defined(QT_NO_DEBUG_STREAM) && QT_CONFIG(datestring)
|
||||
QDebug operator<<(QDebug dbg, const QDate &date)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
@ -5382,7 +5384,7 @@ QDebug operator<<(QDebug dbg, const QDateTime &date)
|
||||
}
|
||||
return dbg.nospace() << ')';
|
||||
}
|
||||
#endif
|
||||
#endif // debug_stream && datestring
|
||||
|
||||
/*! \fn uint qHash(const QDateTime &key, uint seed = 0)
|
||||
\relates QHash
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
QT_DEPRECATED_X("Use QLocale::dayName or QLocale::standaloneDayName")
|
||||
static QString longDayName(int weekday, MonthNameType type = DateFormat);
|
||||
#endif // textdate && deprecated
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
QString toString(Qt::DateFormat f = Qt::TextDate) const;
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
QString toString(const QString &format) const;
|
||||
@ -123,7 +123,7 @@ QT_DEPRECATED inline bool setYMD(int y, int m, int d)
|
||||
Q_DECL_CONSTEXPR bool operator>=(const QDate &other) const { return jd >= other.jd; }
|
||||
|
||||
static QDate currentDate();
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
static QDate fromString(const QString &s, Qt::DateFormat f = Qt::TextDate);
|
||||
static QDate fromString(const QString &s, const QString &format);
|
||||
#endif
|
||||
@ -167,7 +167,7 @@ public:
|
||||
int minute() const;
|
||||
int second() const;
|
||||
int msec() const;
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
QString toString(Qt::DateFormat f = Qt::TextDate) const;
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
QString toString(const QString &format) const;
|
||||
@ -192,7 +192,7 @@ public:
|
||||
Q_DECL_CONSTEXPR inline int msecsSinceStartOfDay() const { return mds == NullTime ? 0 : mds; }
|
||||
|
||||
static QTime currentTime();
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
static QTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate);
|
||||
static QTime fromString(const QString &s, const QString &format);
|
||||
#endif
|
||||
@ -303,7 +303,7 @@ public:
|
||||
void setMSecsSinceEpoch(qint64 msecs);
|
||||
void setSecsSinceEpoch(qint64 secs);
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
QString toString(Qt::DateFormat f = Qt::TextDate) const;
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
QString toString(const QString &format) const;
|
||||
@ -342,7 +342,7 @@ public:
|
||||
|
||||
static QDateTime currentDateTime();
|
||||
static QDateTime currentDateTimeUtc();
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
static QDateTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate);
|
||||
static QDateTime fromString(const QString &s, const QString &format);
|
||||
#endif
|
||||
@ -386,7 +386,7 @@ private:
|
||||
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QDateTime &);
|
||||
#endif
|
||||
|
||||
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING)
|
||||
#if !defined(QT_NO_DEBUG_STREAM) && QT_CONFIG(datestring)
|
||||
friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &);
|
||||
#endif
|
||||
};
|
||||
@ -401,7 +401,7 @@ Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
|
||||
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QDateTime &);
|
||||
#endif // QT_NO_DATASTREAM
|
||||
|
||||
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING)
|
||||
#if !defined(QT_NO_DEBUG_STREAM) && QT_CONFIG(datestring)
|
||||
Q_CORE_EXPORT QDebug operator<<(QDebug, const QDate &);
|
||||
Q_CORE_EXPORT QDebug operator<<(QDebug, const QTime &);
|
||||
Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &);
|
||||
|
@ -77,7 +77,7 @@ QDateTimeParser::~QDateTimeParser()
|
||||
int QDateTimeParser::getDigit(const QDateTime &t, int index) const
|
||||
{
|
||||
if (index < 0 || index >= sectionNodes.size()) {
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
qWarning("QDateTimeParser::getDigit() Internal error (%s %d)",
|
||||
qPrintable(t.toString()), index);
|
||||
#else
|
||||
@ -103,7 +103,7 @@ int QDateTimeParser::getDigit(const QDateTime &t, int index) const
|
||||
default: break;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
qWarning("QDateTimeParser::getDigit() Internal error 2 (%s %d)",
|
||||
qPrintable(t.toString()), index);
|
||||
#else
|
||||
@ -127,7 +127,7 @@ 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()) {
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
qWarning("QDateTimeParser::setDigit() Internal error (%s %d %d)",
|
||||
qPrintable(v.toString()), index, newVal);
|
||||
#else
|
||||
@ -725,7 +725,7 @@ QString QDateTimeParser::sectionText(int sectionIndex) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
|
||||
QDateTimeParser::ParsedSection
|
||||
QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionIndex,
|
||||
@ -1727,7 +1727,7 @@ QDateTimeParser::AmPmFinder QDateTimeParser::findAmPm(QString &str, int sectionI
|
||||
return PossibleBoth;
|
||||
return (!broken[amindex] ? PossibleAM : PossiblePM);
|
||||
}
|
||||
#endif // QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
/*!
|
||||
\internal
|
||||
@ -1958,7 +1958,7 @@ QString QDateTimeParser::stateName(State s) const
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) const
|
||||
{
|
||||
QDateTime val(QDate(1900, 1, 1), QDATETIMEEDIT_TIME_MIN);
|
||||
@ -1983,7 +1983,7 @@ bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) con
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif // QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
QDateTime QDateTimeParser::getMinimum() const
|
||||
{
|
||||
|
@ -180,7 +180,7 @@ public:
|
||||
LowerCase
|
||||
};
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#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;
|
||||
#endif
|
||||
@ -202,7 +202,7 @@ public:
|
||||
private:
|
||||
int sectionMaxSize(Section s, int count) const;
|
||||
QString sectionText(const QString &text, int sectionIndex, int index) const;
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
StateNode scanString(const QDateTime &defaultValue,
|
||||
bool fixup, QString *input) const;
|
||||
struct ParsedSection {
|
||||
@ -237,7 +237,7 @@ private:
|
||||
PossibleBoth = 4
|
||||
};
|
||||
AmPmFinder findAmPm(QString &str, int index, int *used = 0) const;
|
||||
#endif // QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
bool potentialValue(const QStringRef &str, int min, int max, int index,
|
||||
const QDateTime ¤tValue, int insert) const;
|
||||
|
@ -2061,7 +2061,7 @@ QString QLocale::dateTimeFormat(FormatType format) const
|
||||
|
||||
\sa timeFormat(), toDate(), toDateTime(), QTime::fromString()
|
||||
*/
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
QTime QLocale::toTime(const QString &string, FormatType format) const
|
||||
{
|
||||
return toTime(string, timeFormat(format));
|
||||
@ -2079,7 +2079,7 @@ QTime QLocale::toTime(const QString &string, FormatType format) const
|
||||
|
||||
\sa dateFormat(), toTime(), toDateTime(), QDate::fromString()
|
||||
*/
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
QDate QLocale::toDate(const QString &string, FormatType format) const
|
||||
{
|
||||
return toDate(string, dateFormat(format));
|
||||
@ -2098,7 +2098,7 @@ QDate QLocale::toDate(const QString &string, FormatType format) const
|
||||
\sa dateTimeFormat(), toTime(), toDate(), QDateTime::fromString()
|
||||
*/
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
QDateTime QLocale::toDateTime(const QString &string, FormatType format) const
|
||||
{
|
||||
return toDateTime(string, dateTimeFormat(format));
|
||||
@ -2116,7 +2116,7 @@ QDateTime QLocale::toDateTime(const QString &string, FormatType format) const
|
||||
|
||||
\sa timeFormat(), toDate(), toDateTime(), QTime::fromString()
|
||||
*/
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
QTime QLocale::toTime(const QString &string, const QString &format) const
|
||||
{
|
||||
QTime time;
|
||||
@ -2147,7 +2147,7 @@ QTime QLocale::toTime(const QString &string, const QString &format) const
|
||||
|
||||
\sa dateFormat(), toTime(), toDateTime(), QDate::fromString()
|
||||
*/
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
QDate QLocale::toDate(const QString &string, const QString &format) const
|
||||
{
|
||||
QDate date;
|
||||
@ -2178,7 +2178,7 @@ QDate QLocale::toDate(const QString &string, const QString &format) const
|
||||
|
||||
\sa dateTimeFormat(), toTime(), toDate(), QDateTime::fromString()
|
||||
*/
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
QDateTime QLocale::toDateTime(const QString &string, const QString &format) const
|
||||
{
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
|
@ -1001,7 +1001,7 @@ public:
|
||||
QString dateFormat(FormatType format = LongFormat) const;
|
||||
QString timeFormat(FormatType format = LongFormat) const;
|
||||
QString dateTimeFormat(FormatType format = LongFormat) const;
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
QDate toDate(const QString &string, FormatType = LongFormat) const;
|
||||
QTime toTime(const QString &string, FormatType = LongFormat) const;
|
||||
QDateTime toDateTime(const QString &string, FormatType format = LongFormat) const;
|
||||
|
@ -525,7 +525,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;
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
do {
|
||||
dateTime = QLocale::c().toDateTime(dateString, formats.at(n++));
|
||||
} while (n < formats.size() && (!dateTime.isValid()));
|
||||
@ -600,7 +600,7 @@ static void _q_parseDosDir(const QStringList &tokens, const QString &userName, Q
|
||||
info->setWritable(info->isFile());
|
||||
|
||||
QDateTime dateTime;
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
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,
|
||||
|
@ -370,7 +370,7 @@ void QNetworkAccessFtpBackend::ftpRawCommandReply(int code, const QString &text)
|
||||
if (id == sizeId) {
|
||||
// reply to the size command
|
||||
setHeader(QNetworkRequest::ContentLengthHeader, text.toLongLong());
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
} else if (id == mdtmId) {
|
||||
QDateTime dt = QDateTime::fromString(text, QLatin1String("yyyyMMddHHmmss"));
|
||||
setHeader(QNetworkRequest::LastModifiedHeader, dt);
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include "QtCore/qdatetime.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
@ -1159,7 +1159,7 @@ QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value)
|
||||
|
||||
int pos = value.indexOf(',');
|
||||
QDateTime dt;
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
if (pos == -1) {
|
||||
// no comma -> asctime(3) format
|
||||
dt = QDateTime::fromString(QString::fromLatin1(value), Qt::TextDate);
|
||||
@ -1186,7 +1186,7 @@ QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value)
|
||||
dt = c.toDateTime(sansWeekday, QLatin1String("dd-MMM-yy hh:mm:ss 'GMT'"));
|
||||
}
|
||||
}
|
||||
#endif // QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
if (dt.isValid())
|
||||
dt.setTimeSpec(Qt::UTC);
|
||||
|
@ -699,7 +699,7 @@ QDebug operator<<(QDebug debug, const QSslCertificate &certificate)
|
||||
<< ", " << certificate.issuerInfo(QSslCertificate::Organization)
|
||||
<< ", " << certificate.subjectInfo(QSslCertificate::Organization)
|
||||
<< ", " << certificate.subjectAlternativeNames()
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
<< ", " << certificate.effectiveDate()
|
||||
<< ", " << certificate.expiryDate()
|
||||
#endif
|
||||
|
@ -126,7 +126,7 @@ static inline QByteArray fromUnicode(QTextCodec *tc, const QString &str)
|
||||
|
||||
static inline QVariant qDateFromString(const QString &val)
|
||||
{
|
||||
#ifdef QT_NO_DATESTRING
|
||||
#if !QT_CONFIG(datestring)
|
||||
Q_UNUSED(val);
|
||||
return QVariant(val);
|
||||
#else
|
||||
@ -138,7 +138,7 @@ static inline QVariant qDateFromString(const QString &val)
|
||||
|
||||
static inline QVariant qTimeFromString(const QString &val)
|
||||
{
|
||||
#ifdef QT_NO_DATESTRING
|
||||
#if !QT_CONFIG(datestring)
|
||||
Q_UNUSED(val);
|
||||
return QVariant(val);
|
||||
#else
|
||||
@ -150,7 +150,7 @@ static inline QVariant qTimeFromString(const QString &val)
|
||||
|
||||
static inline QVariant qDateTimeFromString(QString &val)
|
||||
{
|
||||
#ifdef QT_NO_DATESTRING
|
||||
#if !QT_CONFIG(datestring)
|
||||
Q_UNUSED(val);
|
||||
return QVariant(val);
|
||||
#else
|
||||
|
@ -679,7 +679,7 @@ QVariant QPSQLResult::data(int i)
|
||||
if (val[0] == '\0') {
|
||||
return QVariant(QDate());
|
||||
} else {
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
return QVariant(QDate::fromString(QString::fromLatin1(val), Qt::ISODate));
|
||||
#else
|
||||
return QVariant(QString::fromLatin1(val));
|
||||
@ -687,7 +687,7 @@ QVariant QPSQLResult::data(int i)
|
||||
}
|
||||
case QVariant::Time: {
|
||||
const QString str = QString::fromLatin1(val);
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
if (str.isEmpty())
|
||||
return QVariant(QTime());
|
||||
else
|
||||
@ -698,7 +698,7 @@ QVariant QPSQLResult::data(int i)
|
||||
}
|
||||
case QVariant::DateTime: {
|
||||
QString dtval = QString::fromLatin1(val);
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
if (dtval.length() < 10) {
|
||||
return QVariant(QDateTime());
|
||||
} else {
|
||||
@ -1497,7 +1497,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
|
||||
} else {
|
||||
switch (int(field.type())) {
|
||||
case QVariant::DateTime:
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
if (field.value().toDateTime().isValid()) {
|
||||
// we force the value to be considered with a timezone information, and we force it to be UTC
|
||||
// this is safe since postgresql stores only the UTC value and not the timezone offset (only used
|
||||
@ -1510,10 +1510,10 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
|
||||
}
|
||||
#else
|
||||
r = QLatin1String("NULL");
|
||||
#endif // QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
break;
|
||||
case QVariant::Time:
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
if (field.value().toTime().isValid()) {
|
||||
r = QLatin1Char('\'') + field.value().toTime().toString(QLatin1String("hh:mm:ss.zzz")) + QLatin1Char('\'');
|
||||
} else
|
||||
|
@ -617,7 +617,7 @@ QString QSqlDriver::formatValue(const QSqlField &field, bool trimStrings) const
|
||||
else
|
||||
r = field.value().toString();
|
||||
break;
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
case QVariant::Date:
|
||||
if (field.value().toDate().isValid())
|
||||
r = QLatin1Char('\'') + field.value().toDate().toString(Qt::ISODate)
|
||||
|
@ -85,7 +85,7 @@ template<> inline char *toString(const QByteArray &ba)
|
||||
return QTest::toPrettyCString(ba.constData(), ba.length());
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
template<> inline char *toString(const QTime &time)
|
||||
{
|
||||
return time.isValid()
|
||||
@ -106,7 +106,7 @@ template<> inline char *toString(const QDateTime &dateTime)
|
||||
? qstrdup(qPrintable(dateTime.toString(QStringViewLiteral("yyyy/MM/dd hh:mm:ss.zzz[t]"))))
|
||||
: qstrdup("Invalid QDateTime");
|
||||
}
|
||||
#endif // QT_NO_DATESTRING
|
||||
#endif // datestring
|
||||
|
||||
template<> inline char *toString(const QChar &c)
|
||||
{
|
||||
|
@ -794,7 +794,7 @@ QString QFileSystemModelPrivate::time(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QString();
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
return node(index)->lastModified().toString(Qt::SystemLocaleDate);
|
||||
#else
|
||||
Q_UNUSED(index);
|
||||
|
@ -1319,7 +1319,7 @@ QString QDirModelPrivate::type(const QModelIndex &index) const
|
||||
|
||||
QString QDirModelPrivate::time(const QModelIndex &index) const
|
||||
{
|
||||
#ifndef QT_NO_DATESTRING
|
||||
#if QT_CONFIG(datestring)
|
||||
return node(index)->info.lastModified().toString(Qt::LocalDate);
|
||||
#else
|
||||
Q_UNUSED(index);
|
||||
|
Loading…
Reference in New Issue
Block a user