mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
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:
14
timers.c
14
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;
|
||||
|
||||
Reference in New Issue
Block a user