diff options
author | Michael Jabbour <micjabbour@gmail.com> | 2017-03-19 04:13:31 +0200 |
---|---|---|
committer | Michael Jabbour <micjabbour@gmail.com> | 2017-03-22 10:50:30 +0000 |
commit | 0f03296391b58edbaa7e779f580adc3075aff831 (patch) | |
tree | fbf99ecd2e1cbca058978a0f08093f7fdead337f | |
parent | 9b3530a3aeda8ea5462922f2b53c771ca722d4cd (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>
(cherry picked from commit ac74abdf50f7047cf43b3577a70d0995e197659d)
Reviewed-by: Julien Blanc <julien.blanc@nmc-company.fr>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
-rw-r--r-- | src/sql/drivers/psql/qsql_psql.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index 4f36e0b513..5f8c85d8aa 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -45,6 +45,7 @@ #include <qsocketnotifier.h> #include <qstringlist.h> #include <qmutex.h> +#include <qlocale.h> #include <QtSql/private/qsqlresult_p.h> #include <QtSql/private/qsqldriver_p.h> @@ -1280,7 +1281,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"); } |