summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-11-23 06:39:04 +0000
committerAndrew Tridgell <tridge@samba.org>2002-11-23 06:39:04 +0000
commit9c68f9064d487573fa94d7decfb1bd68afd37070 (patch)
tree2855575eb30ef5a737f0b02f426673e1f6e08dab /source3
parent905639d9fa2b2bd01ef592635f115483b7c85bb2 (diff)
downloadsamba-9c68f9064d487573fa94d7decfb1bd68afd37070.tar.gz
samba-9c68f9064d487573fa94d7decfb1bd68afd37070.tar.bz2
samba-9c68f9064d487573fa94d7decfb1bd68afd37070.zip
a working timegm() function for systems that don't have it
(This used to be commit 6efdd54d063043cac2fe151231ac1999ade25704)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/replace.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/source3/lib/replace.c b/source3/lib/replace.c
index dfc88e7028..913cd29b23 100644
--- a/source3/lib/replace.c
+++ b/source3/lib/replace.c
@@ -432,26 +432,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