summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY2
-rw-r--r--menuitems.c9
-rw-r--r--menuitems.h6
-rw-r--r--timers.c14
-rw-r--r--timers.h3
5 files changed, 27 insertions, 7 deletions
diff --git a/HISTORY b/HISTORY
index ebcd3a61..3e956527 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3156,3 +3156,5 @@ Video Disk Recorder Revision History
- Fixed some typos in the Makefile's 'font' target (thanks to Olaf Titz).
- Fixed handling childTid in cThread to avoid possible race conditions (thanks
to Stefan Huelswitt for pointing this out).
+- Fixed toggling the "Day" item in the "Timers" menu, so that it selects the
+ right day of week for timers in the future.
diff --git a/menuitems.c b/menuitems.c
index dea20295..9b86db4b 100644
--- a/menuitems.c
+++ b/menuitems.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menuitems.c 1.20 2004/11/14 16:16:21 kls Exp $
+ * $Id: menuitems.c 1.21 2004/11/21 13:24:10 kls Exp $
*/
#include "menuitems.h"
@@ -554,6 +554,7 @@ cMenuEditDayItem::cMenuEditDayItem(const char *Name, int *Value)
:cMenuEditIntItem(Name, Value, -INT_MAX, 31)
{
d = -1;
+ md = 0;
if (*value < 0) {
int n = 0;
while (days[n]) {
@@ -621,12 +622,14 @@ eOSState cMenuEditDayItem::ProcessKey(eKeys Key)
eOSState result = cMenuEditIntItem::ProcessKey(Key);
if (result == osContinue && Key == k0) {
if (d >= 0) {
- *value = cTimer::GetMDay(time(NULL));
+ *value = md ? md : cTimer::GetMDay(time(NULL));
+ md = 0;
d = -1;
Set();
}
else if (*value == 0 || *value == v) {
- d = cTimer::GetWDay(time(NULL));
+ md = v;
+ d = cTimer::GetWDayFromMDay(v);
*value = days[d];
Set();
}
diff --git a/menuitems.h b/menuitems.h
index 5a2912c8..28904013 100644
--- a/menuitems.h
+++ b/menuitems.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menuitems.h 1.9 2004/05/16 12:45:14 kls Exp $
+ * $Id: menuitems.h 1.10 2004/11/21 13:23:00 kls Exp $
*/
#ifndef __MENUITEMS_H
@@ -119,9 +119,11 @@ public:
};
class cMenuEditDayItem : public cMenuEditIntItem {
-protected:
+private:
static int days[];
int d;
+ int md;
+protected:
virtual void Set(void);
public:
cMenuEditDayItem(const char *Name, int *Value);
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;
diff --git a/timers.h b/timers.h
index bdf1b0d9..eceb0780 100644
--- a/timers.h
+++ b/timers.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: timers.h 1.11 2004/11/14 16:02:28 kls Exp $
+ * $Id: timers.h 1.12 2004/11/21 12:37:33 kls Exp $
*/
#ifndef __TIMERS_H
@@ -66,6 +66,7 @@ public:
bool IsSingleEvent(void) const;
static int GetMDay(time_t t);
static int GetWDay(time_t t);
+ static int GetWDayFromMDay(int MDay);
bool DayMatches(time_t t) const;
static time_t IncDay(time_t t, int Days);
static time_t SetTime(time_t t, int SecondsFromMidnight);