Skip to content

Commit

Permalink
Fixes #10849. Treat MythFill{Min,Max}Hour as being in localtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-kristjansson committed Jun 22, 2012
1 parent c97f954 commit aefe0fc
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions mythtv/programs/mythbackend/housekeeper.cpp
Expand Up @@ -202,7 +202,6 @@ void HouseKeeper::RunHouseKeeping(void)
houseKeepingWait.wakeAll();
}

int period, maxhr, minhr;
QString dbTag;
bool initialRun = true;

Expand Down Expand Up @@ -242,18 +241,6 @@ void HouseKeeper::RunHouseKeeping(void)
}
else
{
period = 1;
minhr = gCoreContext->GetNumSetting("MythFillMinHour", -1);
if (minhr == -1)
{
minhr = 0;
maxhr = 24;
}
else
{
maxhr = gCoreContext->GetNumSetting("MythFillMaxHour", 24);
}

bool grabberSupportsNextTime = false;
MSqlQuery result(MSqlQuery::InitCon());
if (result.isConnected())
Expand All @@ -266,12 +253,15 @@ void HouseKeeper::RunHouseKeeping(void)
if ((result.exec()) &&
(result.next()) &&
(result.value(0).toInt() > 0))
grabberSupportsNextTime = true;
{
grabberSupportsNextTime =
gCoreContext->GetNumSetting(
"MythFillGrabberSuggestsTime", 1);
}
}

bool runMythFill = false;
if (grabberSupportsNextTime &&
gCoreContext->GetNumSetting("MythFillGrabberSuggestsTime", 1))
if (grabberSupportsNextTime)
{
QDateTime nextRun = MythDate::fromString(
gCoreContext->GetSetting("MythFillSuggestedRunTime",
Expand All @@ -283,10 +273,35 @@ void HouseKeeper::RunHouseKeeping(void)
(lastRun.secsTo(now) > (3 * 60 * 60)))
runMythFill = true;
}
else if (wantToRun("MythFillDB", period, minhr, maxhr,
initialRun))
else
{
runMythFill = true;
QDate date = QDate::currentDate();
int minhr = gCoreContext->GetNumSetting(
"MythFillMinHour", -1);
int maxhr = gCoreContext->GetNumSetting(
"MythFillMaxHour", 23) % 24;
if (minhr == -1)
{
minhr = 0;
maxhr = 23;
}
else
{
minhr %= 24;
}

QDateTime umin =
QDateTime(date, QTime(minhr,0)).toUTC();
QDateTime umax =
QDateTime(date, QTime(maxhr,0)).toUTC();

if (umax == umin)
umax.addSecs(60*60);

runMythFill = wantToRun(
"MythFillDB", 1,
umin.time().hour(), umax.time().hour(),
initialRun);
}

if (runMythFill)
Expand Down

0 comments on commit aefe0fc

Please sign in to comment.