Ignore:
Timestamp:
09/13/17 23:28:44 (5 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master
Children:
d03ca41
Parents:
f0f9fdc
git-author:
Philipp Spitzer <philipp@…> (09/13/17 23:20:23)
git-committer:
Philipp Spitzer <philipp@…> (09/13/17 23:28:44)
Message:

Import schedules with dates attached to events correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sql/schedulexmlparser.cpp

    rf0f9fdc r7ba0378  
    2121#include <QDomDocument>
    2222#include <QHash>
     23#include <QTime>
    2324
    2425#include "schedulexmlparser.h"
     
    5152    {
    5253        QDomElement conferenceElement = scheduleElement.firstChildElement("conference");
     54        QTime conference_day_change;
    5355        if (!conferenceElement.isNull())
    5456        {
     
    6870            conferenceId = conference["id"].toInt();
    6971            conference_title = conference["title"];
     72            conference_day_change = QTime(0, 0).addSecs(conference["day_change"].toInt());
    7073        }
    7174
     
    109112                        event["id"] = eventElement.attribute("id");;
    110113                        event["conference_id"] = QString::number(conferenceId, 10);
    111                         event["start"] = eventElement.firstChildElement("start").text(); // time eg. 10:00
    112                         event["date"] = dayElement.attribute("date"); // date eg. 2009-02-07
     114                        QTime event_start = QTime::fromString(eventElement.firstChildElement("start").text(), sqlEngine->TIME_FORMAT);
     115                        event["start"] = event_start.toString(sqlEngine->TIME_FORMAT); // time eg. 10:00
     116                        QDate event_date;
     117                        QDomElement eventDateElement = eventElement.firstChildElement("date");
     118                        if (!eventDateElement.isNull()) {
     119                            QString date_str = eventDateElement.text(); // date eg. 2009-02-07T10:00:00+00:00
     120                            event_date = QDate::fromString(date_str.left(sqlEngine->DATE_FORMAT.size()), sqlEngine->DATE_FORMAT);
     121                        } else {
     122                            event_date = QDate::fromString(dayElement.attribute("date"),sqlEngine->DATE_FORMAT); // date eg. 2009-02-07
     123                            if (event_start < conference_day_change) event_date = event_date.addDays(1);
     124                        }
     125                        event["date"] = event_date.toString(sqlEngine->DATE_FORMAT); // date eg. 2009-02-07
    113126                        event["duration"] = eventElement.firstChildElement("duration").text(); // time eg. 00:30
    114127                        event["room_name"] = eventElement.firstChildElement("room").text(); // string eg. "Janson"
Note: See TracChangeset for help on using the changeset viewer.