QString theater_name;
QString theater_address;
QString theater_phone;
- QList<QTime> schedule;
+ QList<QString> schedule;
QRegExp time_pattern("\\d+:\\d+([aApP][mM])*");
while (!xml.atEnd()) {
QXmlStreamReader::TokenType token = xml.readNext();
if (!theater_phone.isEmpty()) {
cinema->SetTelephone(theater_phone);
}
- Q_FOREACH(const QTime time, schedule) {
- _cinema_schedule->AddSchedule(cinema, movie, time, _date);
+ QList<QTime> schedule_times = TimesFromString(schedule);
+ Q_FOREACH(const QTime time, schedule_times) {
+ if (time.hour() < 3) {
+ // interpret very early times as shifted by 1 day (seems to be a Google logic)
+ _cinema_schedule->AddSchedule(cinema, movie, time, _date.addDays(1));
+ } else {
+ _cinema_schedule->AddSchedule(cinema, movie, time, _date);
+ }
}
}
}
while ((i = time_pattern.indexIn(t, i)) != -1) {
int length = time_pattern.matchedLength();
//std::cout << "time " << qPrintable(t.mid(i, length)) << std::endl;
- QTime time = TimeUtils::FromTimeString(t.mid(i, length));
- if (time.isValid()) {
- schedule.append(time);
- } else {
- std::cout << "ERROR: time " << qPrintable(t.mid(i, length)) << " is invalid." << std::endl;
+ if (length > 0) {
+ schedule.append(t.mid(i, length));
}
i += length;
found = true;