Skip to content

Commit

Permalink
Re-fix scheduler part of "fall back" hour.
Browse files Browse the repository at this point in the history
This more involved way doesn't break daily and weekly rules.

IMPORTANT NOTE: The manual recording rule wizard needs to be fixed to
actually allow the user to choose the "fall back" hour and prevent
choosing the missed "spring forward" hour.
  • Loading branch information
gigem committed Aug 7, 2013
1 parent eede3aa commit d766874
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions mythtv/programs/mythbackend/scheduler.cpp
Expand Up @@ -3184,11 +3184,11 @@ void Scheduler::UpdateManuals(uint recordid)
RecordingType rectype = RecordingType(query.value(0).toInt());
QString title = query.value(1).toString();
QString station = query.value(2).toString() ;
QDateTime lstartdt = QDateTime(query.value(3).toDate(),
query.value(4).toTime(), Qt::UTC).toLocalTime();
int duration = lstartdt.secsTo(
QDateTime startdt = QDateTime(query.value(3).toDate(),
query.value(4).toTime(), Qt::UTC);
int duration = startdt.secsTo(
QDateTime(query.value(5).toDate(),
query.value(6).toTime(), Qt::UTC).toLocalTime());
query.value(6).toTime(), Qt::UTC));

query.prepare("SELECT chanid from channel "
"WHERE callsign = :STATION");
Expand All @@ -3206,7 +3206,8 @@ void Scheduler::UpdateManuals(uint recordid)
int progcount;
int skipdays;
bool weekday;
int weeksoff;
int daysoff;
QDateTime lstartdt = startdt.toLocalTime();

switch (rectype)
{
Expand All @@ -3216,21 +3217,26 @@ void Scheduler::UpdateManuals(uint recordid)
progcount = 1;
skipdays = 1;
weekday = false;
daysoff = 0;
break;
case kDailyRecord:
progcount = 13;
skipdays = 1;
weekday = (lstartdt.date().dayOfWeek() < 6);
lstartdt = QDateTime(MythDate::current().toLocalTime().date(),
lstartdt.time(), Qt::LocalTime);
daysoff = lstartdt.date().daysTo(
MythDate::current().toLocalTime().date());
startdt = QDateTime(lstartdt.date().addDays(daysoff),
lstartdt.time(), Qt::LocalTime).toUTC();
break;
case kWeeklyRecord:
progcount = 2;
skipdays = 7;
weekday = false;
weeksoff = (lstartdt.date()
.daysTo(MythDate::current().toLocalTime().date()) + 6) / 7;
lstartdt = lstartdt.addDays(weeksoff * 7);
daysoff = lstartdt.date().daysTo(
MythDate::current().toLocalTime().date());
daysoff = (daysoff + 6) / 7 * 7;
startdt = QDateTime(lstartdt.date().addDays(daysoff),
lstartdt.time(), Qt::LocalTime).toUTC();
break;
default:
LOG(VB_GENERAL, LOG_ERR,
Expand All @@ -3242,26 +3248,29 @@ void Scheduler::UpdateManuals(uint recordid)
{
for (int i = 0; i < (int)chanidlist.size(); i++)
{
if (weekday && lstartdt.toLocalTime().date().dayOfWeek() >= 6)
if (weekday && startdt.toLocalTime().date().dayOfWeek() >= 6)
continue;

query.prepare("REPLACE INTO program (chanid, starttime, endtime,"
" title, subtitle, manualid, generic) "
"VALUES (:CHANID, :STARTTIME, :ENDTIME, :TITLE,"
" :SUBTITLE, :RECORDID, 1)");
query.bindValue(":CHANID", chanidlist[i]);
query.bindValue(":STARTTIME", lstartdt.toUTC());
query.bindValue(":ENDTIME", lstartdt.toUTC().addSecs(duration));
query.bindValue(":STARTTIME", startdt);
query.bindValue(":ENDTIME", startdt.addSecs(duration));
query.bindValue(":TITLE", title);
query.bindValue(":SUBTITLE", lstartdt);
query.bindValue(":SUBTITLE", startdt.toLocalTime());
query.bindValue(":RECORDID", recordid);
if (!query.exec())
{
MythDB::DBError("UpdateManuals", query);
return;
}
}
lstartdt = lstartdt.addDays(skipdays);

daysoff += skipdays;
startdt = QDateTime(lstartdt.date().addDays(daysoff),
lstartdt.time(), Qt::LocalTime).toUTC();
}
}

Expand Down

0 comments on commit d766874

Please sign in to comment.