summaryrefslogtreecommitdiffstats
path: root/contrib/ldns/compat/timegm.c
blob: 97e1e5443664b87747a63eacfc53277b38c0a050 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifdef HAVE_CONFIG_H
#include <ldns/config.h>
#endif

#include <stdio.h>

#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif

#include <time.h>

time_t
timegm (struct tm *tm) {
	time_t ret;
	char *tz;
	
	tz = getenv("TZ");
	putenv((char*)"TZ=");
	tzset();
	ret = mktime(tm);
	if (tz) {
		char buf[256];
		snprintf(buf, sizeof(buf), "TZ=%s", tz);
		putenv(tz);
	}
	else
		putenv((char*)"TZ");
	tzset();
	return ret;
}
OpenPOWER on IntegriCloud