Check for non standard timegm, and replace it if not available.
This commit is contained in:
parent
b97121a0e9
commit
5d9e481dff
@ -98,6 +98,11 @@ AC_CHECK_MEMBER([struct tm.tm_gmtoff],
|
||||
,
|
||||
[#include <time.h>])
|
||||
|
||||
AC_CHECK_DECL([timegm],
|
||||
[AC_DEFINE(HAVE_TIMEGM, 1, [Define this if timegm function is available])],
|
||||
,
|
||||
[#include <time.h>])
|
||||
|
||||
THREAD_LIBS=-lpthread
|
||||
AC_SUBST(THREAD_LIBS)
|
||||
|
||||
|
@ -1058,6 +1058,26 @@ void iso_datetime_17(unsigned char *buf, time_t t, int always_gmt)
|
||||
|
||||
}
|
||||
|
||||
#ifndef HAVE_TIMEGM
|
||||
static
|
||||
time_t 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
time_t iso_datetime_read_7(const uint8_t *buf)
|
||||
{
|
||||
struct tm tm;
|
||||
|
Loading…
Reference in New Issue
Block a user