2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: timezone.h,v 1.9 1999/05/05 10:33:17 sof Exp $
6 * Time-zone support header
15 # include <sys/types.h>
19 /* Sigh, RedHat 5 has the TM_ZONE stuff, but only when _BSD_SOURCE is
20 * on. The configure script erroneously says we've got TM_ZONE, so
21 * make sure we use the TZNAME stuff instead.
23 * Aside: tzname is POSIX, whereas tm_zone is BSD. We should be using
24 * tzname by preference, but the GNU configure stuff gives us HAVE_TM_ZONE
25 * in preference to HAVE_TZNAME. More sighs.
28 # define HAVE_TZNAME 1
30 /* Double sigh. The timezone variable is only available under Linux
31 * when we're compiling NON_POSIX_SOURCE (or _GNU_SOURCE or whatever),
32 * but to make that work we have to make sure NON_POSIX_SOURCE is
33 * defined before anything from /usr/include is included. To avoid
34 * infecting too much source with NON_POSIX_SOURCE, we frob it
39 /* The correct solution to this problem would appear to be to ditch
40 * the standard GNU configure tests for the time stuff, and hack up
41 * our own that test for POSIX-compliant time support first, then
42 * BSD-style time stuff.
46 #ifdef solaris2_TARGET_OS
50 #if TIME_WITH_SYS_TIME
51 # include <sys/time.h>
55 # include <sys/time.h>
62 #define ZONE(x) (((struct tm *)x)->tm_zone)
63 #define SETZONE(x,z) (((struct tm *)x)->tm_zone = z)
64 #define GMTOFF(x) (((struct tm *)x)->tm_gmtoff)
65 #else /* ! HAVE_TM_ZONE */
66 # if HAVE_TZNAME || _WIN32
67 # if cygwin32_TARGET_OS
68 # define tzname _tzname
70 # ifndef mingw32_TARGET_OS
71 extern char *tzname[2];
74 # define ZONE(x) (((struct tm *)x)->tm_isdst ? tzname[1] : tzname[0])
76 # else /* ! HAVE_TZNAME */
77 /* We're in trouble. If you should end up here, please report this as a bug. */
78 # error Dont know how to get at timezone name on your OS.
79 # endif /* ! HAVE_TZNAME */
80 /* Get the offset in secs from UTC, if (struct tm) doesn't supply it. */
82 #ifdef mingw32_TARGET_OS
83 #define timezone _timezone
85 # ifdef cygwin32_TARGET_OS
86 # define timezone _timezone
91 extern TYPE_TIMEZONE timezone;
95 extern time_t altzone;
96 # define GMTOFF(x) (((struct tm *)x)->tm_isdst ? altzone : timezone )
97 # else /* ! HAVE_ALTZONE */
98 /* Assume that DST offset is 1 hour ... */
99 # define GMTOFF(x) (((struct tm *)x)->tm_isdst ? (timezone - 3600) : timezone )
100 # endif /* ! HAVE_ALTZONE */
101 #endif /* ! HAVE_TM_ZONE */
103 #endif /* TIMEZONE_H */