summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers/psql
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-09-19 13:31:18 +0200
committerLiang Qi <liang.qi@qt.io>2018-09-24 17:12:29 +0000
commitb26cd68bf61346273a5a03bbc1e60a7cdffa4f0d (patch)
tree7580a1749931d86bfd67357d1be73355d6b7645e /src/plugins/sqldrivers/psql
parente226b0f94afc85f79d82fc54421487bf2a529ba5 (diff)
Modernize the "datestring" feature
Change-Id: I2236a456fe3758d9054b22e36fe6316f3522d533 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/plugins/sqldrivers/psql')
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp
index 5e0f7626b4..fe9e098c12 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