mktime bug?

Guido Flohr gufl0000 at stud.uni-sb.de
Thu May 13 00:35:29 UTC 1999


Hi,

sorry, it's me again.  I have problems with this little piece of code:

bash$ cat >mktimetest <<EOF
#include <stdio.h>
#include <time.h>

int main ()
{
  struct tm tm;
  time_t secs;

  memset (&tm, 0, sizeof tm);
  tm.year = 99;
  tm.mon = 4;
  tm.mday = 13;
  secs = mktime (&tm);
  printf ("secs: %ld (%s)\n", secs, strerror (errno));
  return 0;
}
EOF
# make mktimetest
# TZ=CET-1CEST-2 ./mktimetest
secs: -1 (OK)

On installations where summertime applies during May mktime returns an
error here (happens somewhere in the function time2).  If I set

	tm.tm_isdst = -1;

before calling mktime() the function returns the correct time.

I have fixed that by inserting the line

	tmp->tm_isdst = -1;

in mktime() before time1() gets called but I'm not sure if this is the
right place to do that (or if this is correct at all).

Can you verify that behavior or have I messed up my sources?  If it is a
bug, how should it be fixed?

Thanks

Guido
-- 
http://stud.uni-sb.de/~gufl0000
mailto:gufl0000 at stud.uni-sb.de



More information about the tz mailing list