diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2012-07-04 14:22:28 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2012-07-04 14:22:28 +0000 |
commit | a1ba2d1ca3a1d6c9c36a79a196dd3ccb83ede353 (patch) | |
tree | ae20718827f0ca6f869c0f7bdb777816d3bf5f3a /compat/timegm.c |
Notes
Diffstat (limited to 'compat/timegm.c')
-rw-r--r-- | compat/timegm.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/compat/timegm.c b/compat/timegm.c new file mode 100644 index 000000000000..97e1e5443664 --- /dev/null +++ b/compat/timegm.c @@ -0,0 +1,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; +} |