Alain Guibert <[EMAIL PROTECTED]> writes: > On Saturday, May 14, 2005 at 10:09:32 PM +0200, Hrvoje Niksic wrote: > >> Alain Guibert <[EMAIL PROTECTED]> writes: >>> Maybe cmpt.c mktime is failing because of incompatible timezone and >>> daylight infos on the platform? >> If you change __tzset() to tzset() and remove the surrounding #ifdef >> _LIBC, does it then work? > > Same false result: Files from 3:30 and 4:30 GMT get minus one hour > on libc5, while on Glibc2 the 3:30 file gets minus one hour and the > 4:30 gets download date. Cygwin behaves as Glibc2.
Could you write a summary of the problem and Cc it to Roger Beeman <[EMAIL PROTECTED]>? I believe you are in a better position to describe the problem than I am. Roger has been responsive regarding problems with mktime_from_utc() in the past and I'd like to hear what he thinks about switching to your approach. Additional points to consider: * Is "GMT0" a portable value for TZ? * Do all systems have the setenv function? Linux man page documents it as conforming to "BSD 4.3", and also documents putenv, which conforms to (among others) SVID. Opengroup's rationale for setenv (http://tinyurl.com/bs8qv) confirms that historically two interfaces existed. setenv is not available on Windows, or at least Borland's headers don't include a prototype. (But they do include putenv.) My conclusion is that portably setting environment variables requires additional Autoconf magic. * GNU libc has a timegm() function that could be used as a drop-in replacement for mktime_from_utc(). I suspect that it would fix the problem on glibc-based systems, but what of non-glibc ones? Do they even have the same problem? * timegm man page suggests this as a portable implementation of that function: 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; } Aside from the issue of portability of setenv and unsetenv, I really don't understand how setting TZ to an empty string makes it point to UTC.