46b907f269c53ab296879822292f73a96cc5c329
[ghc-hetmet.git] / ghc / lib / cbits / timezone.h
1 #ifndef TIMEZONE_H
2 #define TIMEZONE_H
3
4 #define _OSF_SOURCE
5
6 #if TIME_WITH_SYS_TIME
7 # include <sys/time.h>
8 # include <time.h>
9 #else
10 # if HAVE_SYS_TIME_H
11 #  include <sys/time.h>
12 # else
13 #  include <time.h>
14 # endif
15 #endif
16
17 #if HAVE_TM_ZONE
18 #define ZONE(x)          (((struct tm *)x)->tm_zone)
19 #define SETZONE(x,z)     (((struct tm *)x)->tm_zone = z)
20 #define GMTOFF(x)        (((struct tm *)x)->tm_gmtoff)
21 #else /* ! HAVE_TM_ZONE */
22 # if HAVE_TZNAME || cygwin32_TARGET_OS
23 #if cygwin32_TARGET_OS
24 extern char *tzname;
25 #else
26 extern char *tzname[2];
27 #endif
28 #  define ZONE(x)        (((struct tm *)x)->tm_isdst ? tzname[1] : tzname[0])
29 #  define SETZONE(x,z)
30 # else /* ! HAVE_TZNAME */
31 /* We're in trouble. If you should end up here, please report this as a bug. */
32 #  error Dont know how to get at timezone name on your OS.
33 # endif /* ! HAVE_TZNAME */
34 /* Get the offset in secs from UTC, if (struct tm) doesn't supply it. */
35
36 extern TYPE_TIMEZONE timezone;
37
38 # if HAVE_ALTZONE
39 extern time_t altzone;
40 #  define GMTOFF(x)      (((struct tm *)x)->tm_isdst ? altzone : timezone)
41 # else /* ! HAVE_ALTZONE */
42 /* Assume that DST offset is 1 hour ... */
43 #  define GMTOFF(x) (((struct tm *)x)->tm_isdst ? (timezone - 3600) : timezone)
44 # endif /* ! HAVE_ALTZONE */
45 #endif  /* ! HAVE_TM_ZONE */
46
47 #endif /* TIMEZONE_H */