File: timegm.c

package info (click to toggle)
ldns 1.7.0-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,416 kB
  • sloc: ansic: 43,318; python: 7,675; sh: 3,642; pascal: 2,351; perl: 2,188; makefile: 1,439; xml: 518
file content (31 lines) | stat: -rw-r--r-- 414 bytes parent folder | download | duplicates (10)
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;
}