[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / runtime / io / toClockSec.lc
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1995
3 %
4 \subsection[toClockSec.lc]{toClockSec Runtime Support}
5
6 \begin{code}
7
8 #include "rtsdefs.h"
9 #include "stgio.h"
10 #include "timezone.h"
11
12 StgAddr 
13 toClockSec(year, mon, mday, hour, min, sec, tz)
14 StgInt year;
15 StgInt mon;
16 StgInt mday;
17 StgInt hour;
18 StgInt min;
19 StgInt sec;
20 StgInt tz;
21 {
22     struct tm tm;
23     static time_t t;
24
25     tm.tm_year = year - 1900;
26     tm.tm_mon = mon;
27     tm.tm_mday = mday;
28     tm.tm_hour = hour;
29     tm.tm_min = min;
30     tm.tm_sec = sec;
31     tm.tm_isdst = -1;
32
33 #ifdef HAVE_MKTIME
34     t = mktime(&tm);
35 #else
36 #ifdef HAVE_TIMELOCAL
37     t = timelocal(&tm);
38 #else
39     t = (time_t) -1;
40 #endif
41 #endif
42     if (t == (time_t) -1)
43         return NULL;
44     else
45         return &t;
46 }
47
48 \end{code}