Minor updates for versions 0.2.1 and 0.2.2. See changelog file.
[movie-schedule] / src / searchclients / theaterschedulesearchclient.cpp
index 7e1d0ce..82f8482 100644 (file)
@@ -92,7 +92,7 @@ void TheaterScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
     QVector<QString> movie_spans;
     QString theaters_url;
     double rating = -1.0;
-    QList<QTime> schedule;
+    QList<QString> schedule;
     QRegExp time_pattern("\\d+:\\d+([aApP][mM])*");
     QRegExp duration_pattern("((\\d+)hr )?(\\d+)min");
     QRegExp reviews_pattern("\\d+ review(s)?");
@@ -202,8 +202,14 @@ void TheaterScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
                                     movie->SetComment(s);
                                 }
                             }
-                            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);
+                                }
                             }
                         }
                     }
@@ -228,11 +234,8 @@ void TheaterScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
                 int i = 0;
                 while ((i = time_pattern.indexIn(t, i)) != -1) {
                     int length = time_pattern.matchedLength();
-                    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;
                 }