]> ToastFreeware Gitweb - toast/confclerk.git/blobdiff - src/orm/ormrecord.h
Add Stefan as a copyright holder to source files, too.
[toast/confclerk.git] / src / orm / ormrecord.h
index 4f5828dabde16bab9c91c74126cab9e57cb65944..e5e6cfa1488f2c9c76b0ce15aafeafa7b9368da2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 Ixonos Plc.
- * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
+ * Copyright (C) 2011-2012 Philipp Spitzer, gregor herrmann, Stefan Stahl
  *
  * This file is part of ConfClerk.
  *
@@ -93,8 +93,8 @@ T OrmRecord<T>::hydrate(const QSqlRecord& record)
 }
 
 // updates specified column 'col'
-// if the value is not specified  as an argument,
-// it's taken from the reford itself
+// if the value is not specified as an argument,
+// it's taken from the record itself
 // see also: setValue() method for more details
 template <typename T>
 void OrmRecord<T>::update(QString col, QVariant value)
@@ -106,7 +106,6 @@ void OrmRecord<T>::update(QString col, QVariant value)
     else // take 'col' value from the record; see setValue()
         query.bindValue(":col", convertToDb(this->value(col), this->value(col).type()));
     query.bindValue(":id", this->value("id"));
-    //query.bindValue(":id", convertToDb(value("id"), QVariant::Int));
     query.exec();
 }
 
@@ -216,7 +215,9 @@ QVariant OrmRecord<T>::convertToDb(QVariant value, QVariant::Type colType)
 {
     if (colType == QVariant::DateTime && value.canConvert<QDateTime>())
     {
-        return value.toDateTime().toTime_t();
+        QDateTime dateTime = value.toDateTime();
+        dateTime.setTimeSpec(Qt::UTC); // this is to avoid that dateTime.toTime_t changes the time depending on the local time zone
+        return dateTime.toTime_t();
     }
 
     return value;