summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMichael Jabbour <micjabbour@gmail.com>2017-03-18 04:46:45 +0200
committerMichael Jabbour <micjabbour@gmail.com>2017-03-18 19:37:35 +0000
commitac74abdf50f7047cf43b3577a70d0995e197659d (patch)
treeb69ccabd5a43d8e6bd0283b126ff2ed2ed90b421 /src/plugins
parent5c724a6087b0a647e8241d35f0d44bce08e35281 (diff)
PostgreSQL: fix datetime format when system locale doesn't use arabic numerals
psql driver was previously using QDateTime::toString() function which is locale-depndent. Task-number: QTBUG-59524 Change-Id: I7f50f95b5c82e66476abfee24ad28b78b3257041 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp
index 7fa1ff7da5..1faab22f66 100644
--- a/src/plugins/sqldrivers/psql/qsql_psql.cpp
+++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp
@@ -50,6 +50,7 @@
#include <qsqlquery.h>
#include <qsocketnotifier.h>
#include <qstringlist.h>
+#include <qlocale.h>
#include <QtSql/private/qsqlresult_p.h>
#include <QtSql/private/qsqldriver_p.h>
@@ -1307,7 +1308,9 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
// 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
// while parsing), so we have correct behavior in both case of with timezone and without tz
- r = QLatin1String("TIMESTAMP WITH TIME ZONE ") + QLatin1Char('\'') + field.value().toDateTime().toUTC().toString(QLatin1String("yyyy-MM-ddThh:mm:ss.zzz")) + QLatin1Char('Z') + QLatin1Char('\'');
+ r = QLatin1String("TIMESTAMP WITH TIME ZONE ") + QLatin1Char('\'') +
+ QLocale::c().toString(field.value().toDateTime().toUTC(), QLatin1String("yyyy-MM-ddThh:mm:ss.zzz")) +
+ QLatin1Char('Z') + QLatin1Char('\'');
} else {
r = QLatin1String("NULL");
}