abs() is part of C89.
[mmh] / sbr / dtime.c
index 5a73934..1273112 100644 (file)
@@ -11,8 +11,8 @@
 #include <h/tws.h>
 #include <time.h>
 
-#ifndef abs
-# define abs(a) (a >= 0 ? a : -a)
+#if !defined(HAVE_STRUCT_TM_TM_GMTOFF)
+extern long timezone;
 #endif
 
 /*
@@ -102,8 +102,14 @@ dlocaltime(time_t *clock)
        if (tm->tm_isdst)
                tw.tw_flags |= TW_DST;
 
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
+       tw.tw_zone = tm->tm_gmtoff / 60;
+       if (tm->tm_isdst)  /* if DST is in effect */
+               tw.tw_zone -= 60;  /* reset to normal offset */
+#else
        tzset();
        tw.tw_zone = -(timezone / 60);
+#endif
 
        tw.tw_flags &= ~TW_SDAY;
        tw.tw_flags |= TW_SEXP;