a67faf6bcd22d769f11c95951f3700344717572f
[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 
22 #if HAVE_TZNAME
23 extern char *tzname[2];
24 #define ZONE(x)          (((struct tm *)x)->tm_isdst ? tzname[1] : tzname[0])
25 #define SETZONE(x,z)
26 #else
27 /* We're in trouble. If you should end up here, please report this as a bug. */
28 #error Dont know how to get at timezone name on your OS.
29 #endif
30 /* Get the offset in secs from UTC, if (struct tm) doesn't supply it. */
31 extern time_t timezone;
32 #if HAVE_ALTZONE
33 extern time_t altzone;
34 #define GMTOFF(x)        (((struct tm *)x)->tm_isdst ? altzone : timezone)
35 #else
36 /* Assume that DST offset is 1 hour ... */
37 #define GMTOFF(x) (((struct tm *)x)->tm_isdst ? (timezone - 3600) : timezone)
38 #endif
39 #endif
40
41 #endif