X-Git-Url: http://git.maemo.org/git/?p=movie-schedule;a=blobdiff_plain;f=src%2Fsearchclients%2Ftheaterschedulesearchclient.cpp;h=82f8482a834e9728e2b5986c5a29ef4a1504b28c;hp=7e1d0ce3e34d7f9504849d048a752d435d0ddd62;hb=fbbb2a758b18a7afff51d27852f85977fe796b35;hpb=2198ae3ccdffc8b6495ee1f5f91657611808ec93 diff --git a/src/searchclients/theaterschedulesearchclient.cpp b/src/searchclients/theaterschedulesearchclient.cpp index 7e1d0ce..82f8482 100644 --- a/src/searchclients/theaterschedulesearchclient.cpp +++ b/src/searchclients/theaterschedulesearchclient.cpp @@ -92,7 +92,7 @@ void TheaterScheduleSearchClient::ReplyFinished(QNetworkReply *reply) QVector movie_spans; QString theaters_url; double rating = -1.0; - QList schedule; + QList 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 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; }