Wouldn't it be simpler to write a mktime function from scratch to use instead of getting the OS-ones to work?
In the last episode (Oct 15), Martin Nilsson (Fake Build Master) @ Pike (-) developers forum said:
Wouldn't it be simpler to write a mktime function from scratch to use instead of getting the OS-ones to work?
I think they are working. Pike's pre- and post-processing to force mktime to return GMT is the problem. What is needed is a timegm() function that f_mktime() can use when called with 7 arguments. Linux and *BSD provide timegm(), and the Linux manpage suggests this quick hack for systems without it.
Oh you lucky pepole who live in places where TZ=GMT :)
For a portable version of timegm(), set the TZ environment variable to UTC, call mktime() and restore the value of TZ. Something like
#include <time.h> #include <stdlib.h>
time_t my_timegm (struct tm *tm) { time_t ret; char *tz;
tz = getenv("TZ"); setenv("TZ", "", 1); tzset(); ret = mktime(tm); if (tz) setenv("TZ", tz, 1); else unsetenv("TZ"); tzset(); return ret; }
pike-devel@lists.lysator.liu.se