diff options
author | Andrew Bartlett <abartlet@samba.org> | 2003-01-03 01:41:44 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2003-01-03 01:41:44 +0000 |
commit | 353c6b24234444c5430de183c3a4b1318bfce02c (patch) | |
tree | e6e0bcf273c69ba982cdb9166a9aad350dfe1129 /source/lib/replace.c | |
parent | c9994ab7bb0ea96e1a2ddf78935306a7b8507f25 (diff) | |
download | samba-353c6b24234444c5430de183c3a4b1318bfce02c.tar.gz samba-353c6b24234444c5430de183c3a4b1318bfce02c.tar.xz samba-353c6b24234444c5430de183c3a4b1318bfce02c.zip |
Merge from HEAD - tridge's new timegm() that actually works on solaris.
Andrew Bartlett
Diffstat (limited to 'source/lib/replace.c')
-rw-r--r-- | source/lib/replace.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/source/lib/replace.c b/source/lib/replace.c index a826de3560e..cd48b8d160f 100644 --- a/source/lib/replace.c +++ b/source/lib/replace.c @@ -427,26 +427,23 @@ char *rep_inet_ntoa(struct in_addr ip) #ifndef HAVE_TIMEGM /* - see the timegm man page on linux + yes, I know this looks insane, but its really needed. The function in the + Linux timegm() manpage does not work on solaris. */ time_t timegm(struct tm *tm) { - time_t ret; - char *tz; - char *tzvar; - - tz = getenv("TZ"); - putenv("TZ="); - tzset(); - ret = mktime(tm); - if (tz) { - asprintf(&tzvar, "TZ=%s", tz); - putenv(tzvar); - safe_free(tzvar); - } else { - putenv("TZ"); - } - tzset(); - return ret; + struct tm tm2, tm3; + time_t t; + + tm2 = *tm; + + t = mktime(&tm2); + tm3 = *localtime(&t); + tm2 = *tm; + tm2.tm_isdst = tm3.tm_isdst; + t = mktime(&tm2); + t -= TimeDiff(t); + + return t; } #endif |