If no day_change was given for a conference 4 AM is assumed.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 13 Sep 2017 21:26:25 +0000 (23:26 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 13 Sep 2017 21:28:44 +0000 (23:28 +0200)
Fixes #53.

src/sql/schedulexmlparser.cpp
src/sql/sqlengine.cpp

index 7bf7ed6..056e0e1 100644 (file)
@@ -63,7 +63,9 @@ void ScheduleXmlParser::parseData(const QByteArray &aData, const QString& url, i
             conference["city"] = conferenceElement.firstChildElement("city").text();
             conference["start"] = conferenceElement.firstChildElement("start").text(); // date
             conference["end"] = conferenceElement.firstChildElement("end").text(); // date
-            conference["day_change"] = conferenceElement.firstChildElement("day_change").text(); // time
+            QString conferenceDayChangeStr = conferenceElement.firstChildElement("day_change").text(); // time, e.g. "04:00:00"
+            if (conferenceDayChangeStr.isEmpty()) conferenceDayChangeStr = "04:00:00";
+            conference["day_change"] = conferenceDayChangeStr;
             conference["timeslot_duration"] = conferenceElement.firstChildElement("timeslot_duration").text(); // time
             conference["url"] = url;
             sqlEngine->addConferenceToDB(conference, conferenceId);
index e062387..9998467 100644 (file)
@@ -154,7 +154,8 @@ void SqlEngine::addConferenceToDB(QHash<QString,QString> &aConference, int confe
     }
     query.bindValue(":start", QDateTime(QDate::fromString(aConference["start"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t());
     query.bindValue(":end", QDateTime(QDate::fromString(aConference["end"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t());
-    query.bindValue(":day_change", -QTime::fromString(aConference["day_change"],TIME_FORMAT).secsTo(QTime(0,0)));
+    QTime dayChange = QTime::fromString(aConference["day_change"].left(TIME_FORMAT.size()), TIME_FORMAT);
+    query.bindValue(":day_change", QTime(0, 0).secsTo(dayChange));
     query.bindValue(":timeslot_duration", -QTime::fromString(aConference["timeslot_duration"],TIME_FORMAT).secsTo(QTime(0,0)));
     query.bindValue(":active", 1);
     if (!insert) query.bindValue(":id", conferenceId);