Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: Problem with timer over end of month / Stirb Langsam



Klaus Schmidinger wrote:
> 
> _cooper_ wrote:
> >
> > Hi,
> >
> > I tried to record "Stirb langsam" on Pro 7 this eavening, but the recording
> > was incomplete.
> >
> > It was programmed from March 31th, 22:09 to April 1st, 00:50, stored as "timer
> > 10". However, without any logical reason the timer stopped at April 1st,
> > 00:00:00.
> > ...
> 
> There seems to be a bug in the mktime() function. Normally it works fine if
> you give it a 'struct tm' that contains out of range data, and normalizes it.
> However, if given, for instance, 'tm_mon = 3' (April) and 'tm_mday = 0' this
> doesn't result in 'March 31', but rather 'March 30'.
> 
> Looks like I'll have to work around this bug in cTimer::IncDay()...

Well, I guess I was wrong with blaming the mktime() function.
Actually the problem was that yesterday Daylight Saving Time was
switched on, and at some calls to mktime() I hadn't initialized
the 'isdst' flag so that mktime() would be forced to determine
whether there is DST at the time it converts.

The following fixes this (line numbers may be off little):

--- config.c    2002/03/31 21:17:24
+++ config.c    2002/04/01 10:54:32
@@ -439,6 +439,7 @@
                  tm_r.tm_year -= 1900;
                  tm_r.tm_mon--;
                  tm_r.tm_hour = tm_r.tm_min = tm_r.tm_sec = 0;
+                 tm_r.tm_isdst = -1; // makes sure mktime() will determine the correct DST setting
                  *FirstDay = mktime(&tm_r);
                  }
               }
@@ -560,6 +561,7 @@
   tm tm = *localtime_r(&t, &tm_r);
   tm.tm_mday += Days; // now tm_mday may be out of its valid range
   int h = tm.tm_hour; // save original hour to compensate for DST change
+  tm.tm_isdst = -1;   // makes sure mktime() will determine the correct DST setting
   t = mktime(&tm);    // normalize all values
   tm.tm_hour = h;     // compensate for DST change
   return mktime(&tm); // calculate final result
@@ -572,6 +574,7 @@
   tm.tm_hour = SecondsFromMidnight / 3600;
   tm.tm_min = (SecondsFromMidnight % 3600) / 60;
   tm.tm_sec =  SecondsFromMidnight % 60;
+  tm.tm_isdst = -1; // makes sure mktime() will determine the correct DST setting
   return mktime(&tm);
 }


This will of course be in VDR version 1.0.0pre5, which I am about to
release within the next few hours (hopefully...).

Klaus
-- 
_______________________________________________________________

Klaus Schmidinger                       Phone: +49-8635-6989-10
CadSoft Computer GmbH                   Fax:   +49-8635-6989-40
Hofmark 2                               Email:   kls@cadsoft.de
D-84568 Pleiskirchen, Germany           URL:     www.cadsoft.de
_______________________________________________________________



Home | Main Index | Thread Index