2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: timezone.h,v 1.3 1998/12/02 13:28:01 simonm 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
31 #if TIME_WITH_SYS_TIME
32 # include <sys/time.h>
36 # include <sys/time.h>
43 #define ZONE(x) (((struct tm *)x)->tm_zone)
44 #define SETZONE(x,z) (((struct tm *)x)->tm_zone = z)
45 #define GMTOFF(x) (((struct tm *)x)->tm_gmtoff)
46 #else /* ! HAVE_TM_ZONE */
47 # if HAVE_TZNAME || cygwin32_TARGET_OS
48 #if cygwin32_TARGET_OS
49 #define tzname _tzname
51 extern char *tzname[2];
52 # define ZONE(x) (((struct tm *)x)->tm_isdst ? tzname[1] : tzname[0])
54 # else /* ! HAVE_TZNAME */
55 /* We're in trouble. If you should end up here, please report this as a bug. */
56 # error Dont know how to get at timezone name on your OS.
57 # endif /* ! HAVE_TZNAME */
58 /* Get the offset in secs from UTC, if (struct tm) doesn't supply it. */
60 extern TYPE_TIMEZONE timezone;
63 extern time_t altzone;
64 # define GMTOFF(x) (((struct tm *)x)->tm_isdst ? altzone : timezone)
65 # else /* ! HAVE_ALTZONE */
66 /* Assume that DST offset is 1 hour ... */
67 # define GMTOFF(x) (((struct tm *)x)->tm_isdst ? (timezone - 3600) : timezone)
68 # endif /* ! HAVE_ALTZONE */
69 #endif /* ! HAVE_TM_ZONE */
71 #endif /* TIMEZONE_H */