Merge pull request #122 from mamarley/psqltzfix
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 21 Apr 2015 20:38:00 +0000 (22:38 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 21 Apr 2015 20:38:00 +0000 (22:38 +0200)
Set the PostgreSQL session timezone to 'UTC'

src/core/postgresqlstorage.cpp

index ca86570..68cf254 100644 (file)
@@ -136,6 +136,14 @@ bool PostgreSqlStorage::initDbSession(QSqlDatabase &db)
         return false;
         break;
     }
+
+    // Set the PostgreSQL session timezone to UTC, since we want timestamps stored in UTC
+    QSqlQuery tzQuery = db.exec("SET timezone = 'UTC'");
+    if (tzQuery.lastError().isValid()) {
+        quError() << "Failed to set timezone to UTC!";
+        return false;
+    }
+
     return true;
 }