Fixed toggling the 'Day' item in the 'Timers' menu, so that it selects the right day of week for timers in the future

This commit is contained in:
Klaus Schmidinger
2004-11-21 13:28:05 +01:00
parent 969864aacb
commit c2daf37ed1
5 changed files with 27 additions and 7 deletions

View File

@@ -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;