Skip to content

Commit

Permalink
Fix some UTC breakage for find and custom rules.
Browse files Browse the repository at this point in the history
Update the find day and time for recording rules.

Update the SQL clause for the  "Prime time" recording filter.

Update the time-related, example, SQL clauses in the custom rule
editor.

IMPORTANT NOTE: For the two latter changes to work properly, time zone
data must be loaded into the MySQL server.  If that is not done, any
recording rules using them will not match any programs.
  • Loading branch information
gigem committed Jun 7, 2012
1 parent b119cf2 commit 7fb9747
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 19 deletions.
2 changes: 1 addition & 1 deletion mythtv/bindings/perl/MythTV.pm
Expand Up @@ -114,7 +114,7 @@ package MythTV;
# schema version supported in the main code. We need to check that the schema
# version in the database is as expected by the bindings, which are expected
# to be kept in sync with the main code.
our $SCHEMA_VERSION = "1303";
our $SCHEMA_VERSION = "1305";

# NUMPROGRAMLINES is defined in mythtv/libs/libmythtv/programinfo.h and is
# the number of items in a ProgramInfo QStringList group used by
Expand Down
2 changes: 1 addition & 1 deletion mythtv/bindings/python/MythTV/static.py
Expand Up @@ -5,7 +5,7 @@
"""

OWN_VERSION = (0,26,-1,1)
SCHEMA_VERSION = 1304
SCHEMA_VERSION = 1305
NVSCHEMA_VERSION = 1007
MUSICSCHEMA_VERSION = 1018
PROTO_VERSION = '75'
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -57,7 +57,7 @@
* mythtv/bindings/php/MythBackend.php
#endif

#define MYTH_DATABASE_VERSION "1304"
#define MYTH_DATABASE_VERSION "1305"


MBASE_PUBLIC const char *GetMythSourceVersion();
Expand Down
37 changes: 37 additions & 0 deletions mythtv/libs/libmythtv/dbcheck.cpp
Expand Up @@ -2173,6 +2173,43 @@ NULL
return false;
}

if (dbver == "1304")
{
QDateTime loc = QDateTime::currentDateTime();
QDateTime utc = loc.toUTC();
loc = QDateTime(loc.date(), loc.time(), Qt::UTC);
int utc_offset = loc.secsTo(utc) / 60;

QList<QByteArray> updates_ba;

updates_ba.push_back(
"UPDATE recordfilter SET clause="
"'HOUR(CONVERT_TZ(program.starttime, ''UTC'', ''SYSTEM'')) >= 19 AND "
"HOUR(CONVERT_TZ(program.starttime, ''UTC'', ''SYSTEM'')) < 22' "
"WHERE filterid=3");

updates_ba.push_back(QString(
"UPDATE record SET "
"findday = DAYOFWEEK(ADDTIME('2012-06-02 00:00:00', findtime) "
" + INTERVAL %1 MINUTE + INTERVAL findday DAY) "
"WHERE findday > 0").arg(utc_offset).toLocal8Bit());

updates_ba.push_back(QString(
"UPDATE record SET "
"findtime = TIME(ADDTIME('2012-06-02 00:00:00', findtime) "
" + INTERVAL %1 MINUTE)").arg(utc_offset).toLocal8Bit());

// Convert update ByteArrays to NULL terminated char**
QList<QByteArray>::const_iterator it = updates_ba.begin();
vector<const char*> updates;
for (; it != updates_ba.end(); ++it)
updates.push_back((*it).constData());
updates.push_back(NULL);

if (!performActualUpdate(&updates[0], "1305", dbver))
return false;
}

return true;
}

Expand Down
39 changes: 23 additions & 16 deletions mythtv/programs/mythfrontend/customedit.cpp
Expand Up @@ -315,33 +315,38 @@ void CustomEdit::loadClauses()

rule.title = tr("Anytime on a specific day of the week");
rule.subtitle.clear();
rule.description = QString("DAYNAME(program.starttime) = '{DAYNAME}' ");
rule.description =
"DAYNAME(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) = '{DAYNAME}' ";
new MythUIButtonListItem(m_clauseList, rule.title,
qVariantFromValue(rule));

rule.title = tr("Only on weekdays (Monday through Friday)");
rule.subtitle.clear();
rule.description = "WEEKDAY(program.starttime) < 5 ";
rule.description =
"WEEKDAY(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) < 5 ";
new MythUIButtonListItem(m_clauseList, rule.title,
qVariantFromValue(rule));

rule.title = tr("Only on weekends");
rule.subtitle.clear();
rule.description = "WEEKDAY(program.starttime) >= 5 ";
rule.description =
"WEEKDAY(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) >= 5 ";
new MythUIButtonListItem(m_clauseList, rule.title,
qVariantFromValue(rule));

rule.title = tr("Only in primetime");
rule.title = tr("Only in prime time");
rule.subtitle.clear();
rule.description = QString("HOUR(program.starttime) >= 19 \n"
"AND HOUR(program.starttime) < 23 ");
rule.description =
"HOUR(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) >= 19 "
"AND HOUR(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) < 23 ";
new MythUIButtonListItem(m_clauseList, rule.title,
qVariantFromValue(rule));

rule.title = tr("Not in primetime");
rule.title = tr("Not in prime time");
rule.subtitle.clear();
rule.description = QString("(HOUR(program.starttime) < 19 \n"
" OR HOUR(program.starttime) >= 23) ");
rule.description =
"(HOUR(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) < 19 "
" OR HOUR(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) >= 23) ";
new MythUIButtonListItem(m_clauseList, rule.title,
qVariantFromValue(rule));

Expand Down Expand Up @@ -516,18 +521,20 @@ void CustomEdit::loadClauses()
rule.title =
tr("SportsCenter Overnight (complete example - use FindDaily)");
rule.subtitle.clear();
rule.description = "program.title = 'SportsCenter' \n"
"AND HOUR(program.starttime) >= 2 \n"
"AND HOUR(program.starttime) <= 6 ";
rule.description =
"program.title = 'SportsCenter' \n"
"AND HOUR(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) >= 2 \n"
"AND HOUR(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) <= 6 ";
new MythUIButtonListItem(m_clauseList, rule.title,
qVariantFromValue(rule));

rule.title = tr("Movie of the Week (complete example - use FindWeekly)");
rule.subtitle.clear();
rule.description = "program.category_type='movie' \n"
"AND program.stars >= 1.0 AND program.airdate >= 1965 \n"
"AND DAYNAME(program.starttime) = 'Friday' \n"
"AND HOUR(program.starttime) >= 12 ";
rule.description =
"program.category_type='movie' \n"
"AND program.stars >= 1.0 AND program.airdate >= 1965 \n"
"AND DAYNAME(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) = 'Friday' \n"
"AND HOUR(CONVERT_TZ(program.starttime, 'UTC', 'SYSTEM')) >= 12 ";
new MythUIButtonListItem(m_clauseList, rule.title,
qVariantFromValue(rule));

Expand Down

0 comments on commit 7fb9747

Please sign in to comment.