Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
timerec: fix 20:40 ... 00:40 case, fixes #3662
  • Loading branch information
perexg committed Mar 27, 2016
1 parent cd9f07f commit 5098357
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/dvr/dvr_timerec.c
Expand Up @@ -105,7 +105,7 @@ void
dvr_timerec_check(dvr_timerec_entry_t *dte)
{
dvr_entry_t *de;
time_t start, stop, limit;
time_t clk, start, stop, limit;
struct tm tm_start, tm_stop;
const char *title;
char buf[200];
Expand All @@ -119,22 +119,21 @@ dvr_timerec_check(dvr_timerec_entry_t *dte)
if(dte->dte_channel == NULL)
goto fail;

limit = gclk() - 600;
start = dvr_timerec_timecorrection(gclk(), dte->dte_start, &tm_start);
stop = dvr_timerec_timecorrection(gclk(), dte->dte_stop, &tm_stop);
clk = gclk();
limit = clk - 600;
start = dvr_timerec_timecorrection(clk, dte->dte_start, &tm_start);
stop = dvr_timerec_timecorrection(clk, dte->dte_stop, &tm_stop);
if (start < limit && stop < limit) {
/* next day */
start = dvr_timerec_timecorrection(gclk() + 24*60*60,
dte->dte_start,
&tm_start);
stop = dvr_timerec_timecorrection(gclk() + 24*60*60,
dte->dte_stop,
&tm_stop);
clk += 24*60*60;
start = dvr_timerec_timecorrection(clk, dte->dte_start, &tm_start);
stop = dvr_timerec_timecorrection(clk, dte->dte_stop, &tm_stop);
}
/* day boundary correction */
if (start > stop)
stop += 24 * 60 * 60;
assert(start <= stop);
while (start > stop) {
clk += 24*60*60;
stop = dvr_timerec_timecorrection(clk, dte->dte_stop, &tm_stop);
}

if(dte->dte_weekdays != 0x7f) {
localtime_r(&start, &tm_start);
Expand Down

0 comments on commit 5098357

Please sign in to comment.