From c2daf37ed136f85dd94cfd6cfa670aba9d93193c Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 21 Nov 2004 13:28:05 +0100 Subject: Fixed toggling the 'Day' item in the 'Timers' menu, so that it selects the right day of week for timers in the future --- timers.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'timers.c') diff --git a/timers.c b/timers.c index 501396ee..62f59d84 100644 --- a/timers.c +++ b/timers.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: timers.c 1.17 2004/11/14 16:02:42 kls Exp $ + * $Id: timers.c 1.18 2004/11/21 13:15:33 kls Exp $ */ #include "timers.h" @@ -269,6 +269,18 @@ int cTimer::GetWDay(time_t t) return weekday == 0 ? 6 : weekday - 1; // we start with monday==0! } +int cTimer::GetWDayFromMDay(int MDay) +{ + time_t now = time(NULL); + int md = GetMDay(now); + for (int i = -1; i <= 28; i++) { // looking 4 weeks into the future should be enough + time_t t0 = IncDay(now, i); + if (GetMDay(t0) == MDay) + return GetWDay(t0); + } + return GetWDay(now); // just to return something +} + bool cTimer::DayMatches(time_t t) const { return IsSingleEvent() ? GetMDay(t) == day : (day & (1 << GetWDay(t))) != 0; -- cgit v1.2.3