From b26cd68bf61346273a5a03bbc1e60a7cdffa4f0d Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 19 Sep 2018 13:31:18 +0200 Subject: Modernize the "datestring" feature Change-Id: I2236a456fe3758d9054b22e36fe6316f3522d533 Reviewed-by: Lars Knoll Reviewed-by: Edward Welbourne --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/plugins/sqldrivers/psql/qsql_psql.cpp') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 5e0f7626b4a..fe9e098c123 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -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 -- cgit v1.2.3