+movie-schedule (0.2.2) unstable; urgency=low
+
+ * Fixed interpretation of schedule times (Closes: #6234)
+
+ -- Jochen Becher <j.becher@ovi.com> Sun, 05 Sep 2010 22:15:00 +0000
+
+
+movie-schedule (0.2.1) unstable; urgency=low
+
+ * Fixed link to bugtracker in debian/control files (Closes: #6226)
+
+ -- Jochen Becher <j.becher@ovi.com> Fri, 13 Aug 2010 16:35:00 +0000
+
movie-schedule (0.2.0) unstable; urgency=low
* Fixed trimming of phone numbers before calling cinema (Closes: #6110)
days or find your preferred time to watch the latest block buster.
Don't miss a movie by addding a calendar entry automatically or
google for the cinema's or movie's web page.
-XSBC-Bugtracker: https://bugs.maemo.org/enter_bug.cgi?product=movie-schedule
+XSBC-Bugtracker: https://garage.maemo.org/tracker/?group_id=1781
XSBC-Maemo-Display-Name: MovieSchedule
XB-Maemo-Icon-26:
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAL
#include "abstractsearchclient.h"
+#include "utils/timeutils.h"
+
#include <QMutexLocker>
#include <iostream>
_start(0)
{
connect(_network, SIGNAL(finished(QNetworkReply *)),
- this, SLOT(ReplyFinished(QNetworkReply*)));
+ this, SLOT(ReplyFinished(QNetworkReply*)));
{
QMutexLocker locker(&_next_search_task_id_mutex);
_search_task_id = _next_search_task_id++;
deleteLater();
}
+QList<QTime> AbstractSearchClient::TimesFromString(const QList<QString> &time_strings)
+{
+ QList<QTime> schedule_times;
+ bool am_pm = false;
+ Q_FOREACH(const QString time_str, time_strings) {
+ if (time_str.endsWith("am", Qt::CaseInsensitive) || time_str.endsWith("pm", Qt::CaseInsensitive)) {
+ am_pm = true;
+ }
+ }
+ if (am_pm) {
+ int i = 0;
+ bool am = true;
+ while (i < time_strings.length()) {
+ int j = i;
+ while (i < time_strings.length()) {
+ if (time_strings[i].endsWith("am", Qt::CaseInsensitive)) {
+ am = true;
+ break;
+ } else if (time_strings[i].endsWith("pm", Qt::CaseInsensitive)) {
+ am = false;
+ break;
+ }
+ ++i;
+ }
+ while (j < i) {
+ QString time_str = time_strings[j] + (am ? "am" : "pm");
+ QTime time = TimeUtils::FromTimeString(time_str);
+ if (time.isValid()) {
+ schedule_times.append(time);
+ } else {
+ std::cout << "ERROR: time " << qPrintable(time_str) << " is invalid." << std::endl;
+ }
+ ++j;
+ }
+ if (i < time_strings.length()) {
+ QString time_str = time_strings[i];
+ QTime time = TimeUtils::FromTimeString(time_str);
+ if (time.isValid()) {
+ schedule_times.append(time);
+ } else {
+ std::cout << "ERROR: time " << qPrintable(time_str) << " is invalid." << std::endl;
+ }
+ schedule_times.append(time);
+ }
+ ++i;
+ }
+ } else {
+ Q_FOREACH(const QString time_str, time_strings) {
+ QTime time = TimeUtils::FromTimeString(time_str);
+ if (time.isValid()) {
+ schedule_times.append(time);
+ } else {
+ std::cout << "ERROR: time " << qPrintable(time_str) << " is invalid." << std::endl;
+ }
+ }
+ }
+ return schedule_times;
+}
+
void AbstractSearchClient::FixLocation(QUrl *url)
{
// Try to fix the Google url which returns
Q_SLOT virtual void DownloadProgress(qint64, qint64);
Q_SLOT virtual void NetworkError(QNetworkReply::NetworkError);
+protected:
+ QList<QTime> TimesFromString(const QList<QString> &time_strings);
+
private:
void FixLocation(QUrl *url);
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;
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)?");
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);
+ }
}
}
}
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;
}
++m;
}
if (m == 0 || pos >= n || time[pos] != ':') {
+ // syntax error
return QTime();
}
++pos;
++m;
}
if (m == 0) {
+ // syntax error
return QTime();
}
if (pos < n) {
hours += 12;
}
} else if (s.compare("am", Qt::CaseInsensitive) == 0) {
- // nothing to do
+ if (hours >= 12) {
+ hours -= 12;
+ }
} else {
+ // illegal suffix
return QTime();
}
- } else {
- // assume pm as default
- if (hours < 12) {
- hours += 12;
- }
}
return QTime(hours, minutes);
}