Ignore:
Timestamp:
04/30/13 23:42:38 (9 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
5130dc7
Parents:
83481c6
Message:

Now the dayChange time is taken into account. This fixes #43.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sql/sqlengine.cpp

    r83481c6 r41c4ceb  
    173173
    174174void SqlEngine::addEventToDB(QHash<QString,QString> &aEvent) {
    175     //insert event track to table and get track id
    176     int conference = aEvent["conference_id"].toInt();
    177     QString name = aEvent["track"];
     175    int conferenceId = aEvent["conference_id"].toInt();
     176    Conference conference = Conference::getById(conferenceId);
     177
     178    // insert event track to table and get track id
    178179    Track track;
    179180    int trackId;
     181    QString trackName = aEvent["track"];
    180182    try
    181183    {
    182         track = Track::retrieveByName(conference, name);
     184        track = Track::retrieveByName(conferenceId, trackName);
    183185        trackId = track.id();
    184186    }
    185187    catch (OrmNoObjectException &e) {
    186         track.setConference(conference);
    187         track.setName(name);
     188        track.setConference(conferenceId);
     189        track.setName(trackName);
    188190        trackId = track.insert();
    189191    }
     192    QDate startDate = QDate::fromString(aEvent["date"], DATE_FORMAT);
     193    QTime startTime = QTime::fromString(aEvent["start"], TIME_FORMAT);
     194    // consider day_change (note that if day_change is e.g. at 04:00 AM, an event starting at 02:00 AM has the previous date in the XML file)
     195    if (startTime < conference.dayChangeTime()) startDate = startDate.addDays(1);
    190196    QDateTime startDateTime;
    191197    startDateTime.setTimeSpec(Qt::UTC);
    192     startDateTime = QDateTime(QDate::fromString(aEvent["date"],DATE_FORMAT),QTime::fromString(aEvent["start"],TIME_FORMAT),Qt::UTC);
     198    startDateTime = QDateTime(startDate, startTime, Qt::UTC);
    193199
    194200    bool event_exists = false;
Note: See TracChangeset for help on using the changeset viewer.