From d766874e45507c6873934c827d267f5dde1a28da Mon Sep 17 00:00:00 2001 From: David Engel Date: Wed, 7 Aug 2013 14:07:53 -0500 Subject: [PATCH] Re-fix scheduler part of "fall back" hour. 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. --- mythtv/programs/mythbackend/scheduler.cpp | 39 ++++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/mythtv/programs/mythbackend/scheduler.cpp b/mythtv/programs/mythbackend/scheduler.cpp index 914a1ae554e..6f4adeac8b4 100644 --- a/mythtv/programs/mythbackend/scheduler.cpp +++ b/mythtv/programs/mythbackend/scheduler.cpp @@ -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"); @@ -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) { @@ -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, @@ -3242,7 +3248,7 @@ 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," @@ -3250,10 +3256,10 @@ void Scheduler::UpdateManuals(uint recordid) "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()) { @@ -3261,7 +3267,10 @@ void Scheduler::UpdateManuals(uint recordid) return; } } - lstartdt = lstartdt.addDays(skipdays); + + daysoff += skipdays; + startdt = QDateTime(lstartdt.date().addDays(daysoff), + lstartdt.time(), Qt::LocalTime).toUTC(); } }