Adjust alarm logic to include UTC offset or displayTimeShift.
[debian/confclerk.git] / src / mvc / event.cpp
index d2075e784e30d6664029128dcf28a2e200b6a209..615bb09593c7a54aabe6f27e898b1bd58ada4ebb 100644 (file)
@@ -103,10 +103,19 @@ QList<Event> Event::conflictEvents(int aEventId, int conferenceId) {
 
 
 QList<Event> Event::getImminentAlarmEvents(int maxSecToAlarm, int conferenceId) {
+    Conference conference = Conference::getById(conferenceId);
     QSqlQuery query;
     query.prepare(selectQuery() + "WHERE xid_conference = :conf AND (start < :start AND alarm = 1) ORDER BY start, duration");
     query.bindValue(":conf", conferenceId);
-    query.bindValue(":start", convertToDb(QDateTime::currentDateTime().addSecs(maxSecToAlarm), QVariant::DateTime));
+    QDateTime start;
+    if (conference.hasUtcOffset()) {
+        start = QDateTime::currentDateTimeUtc().addSecs(conference.utcOffset() * 60);
+    } else {
+        start = QDateTime::currentDateTime();
+        if (conference.hasDisplayTimeShift()) start = start.addSecs(conference.displayTimeShift() * 60);
+    }
+    start = start.addSecs(maxSecToAlarm);
+    query.bindValue(":start", convertToDb(start, QVariant::DateTime));
     return load(query);
 }