r10523: fixed timegm() to not depend on get_time_zone(), so it works in lib/replace/
authorAndrew Tridgell <tridge@samba.org>
Tue, 27 Sep 2005 02:36:56 +0000 (02:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:39:00 +0000 (13:39 -0500)
the old timegm() replacement was also broken (it returned the wrong value)
(This used to be commit 342489a1d4d5cc4b16cf2e5ff7e671326f0cb3d5)

source4/lib/replace/replace.c

index c53b5a572772e980f48be277a47176bf22c8d0a9..5e60252a67b6e8becdc127bd42cbc376435080d8 100644 (file)
@@ -369,18 +369,8 @@ duplicate a string
 */
  time_t timegm(struct tm *tm) 
 {
-       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 -= get_time_zone(t);
-
+       time_t t = mktime(tm);
+       t -= mktime(gmtime(&t)) - (int)mktime(localtime(&t));
        return t;
 }
 #endif