timegm.c revision 238104
11558Srgrimes#ifdef HAVE_CONFIG_H 21558Srgrimes#include <ldns/config.h> 31558Srgrimes#endif 41558Srgrimes 51558Srgrimes#include <stdio.h> 61558Srgrimes 71558Srgrimes#ifdef HAVE_STDLIB_H 81558Srgrimes#include <stdlib.h> 91558Srgrimes#endif 101558Srgrimes 111558Srgrimes#include <time.h> 121558Srgrimes 131558Srgrimestime_t 141558Srgrimestimegm (struct tm *tm) { 151558Srgrimes time_t ret; 161558Srgrimes char *tz; 171558Srgrimes 181558Srgrimes tz = getenv("TZ"); 191558Srgrimes putenv((char*)"TZ="); 201558Srgrimes tzset(); 211558Srgrimes ret = mktime(tm); 221558Srgrimes if (tz) { 231558Srgrimes char buf[256]; 241558Srgrimes snprintf(buf, sizeof(buf), "TZ=%s", tz); 251558Srgrimes putenv(tz); 261558Srgrimes } 271558Srgrimes else 281558Srgrimes putenv((char*)"TZ"); 291558Srgrimes tzset(); 301558Srgrimes return ret; 311558Srgrimes} 321558Srgrimes