Pristine Ack-5.5
[Ack-5.5.git] / lang / cem / libcc.ansi / time / time.c
1 /*
2  * time - return the current calendar time (seconds since jan 1, 1970)
3  */
4 /* $Id: time.c,v 1.4 1994/06/24 11:58:26 ceriel Exp $ */
5
6 #if     defined(__BSD4_2)
7 #include        <time.h>
8 /*
9  * Structure returned by gettimeofday(2) system call,
10  * and used in other calls.
11  */
12 struct timeval {
13         long    tv_sec;         /* seconds */
14         long    tv_usec;        /* and microseconds */
15 };
16
17 struct timezone {
18         int     tz_minuteswest; /* minutes west of Greenwich */
19         int     tz_dsttime;     /* type of dst correction */
20 };
21
22 int _gettimeofday(struct timeval *tp, struct timezone *tzp);
23
24 time_t
25 time(time_t *timer)
26 {
27         struct timeval tv;
28         struct timezone tz;
29         _gettimeofday(&tv, &tz);
30
31         if (timer) *timer = tv.tv_sec;
32         return tv.tv_sec;
33 }
34 #else
35 /* Assume time() is a system call */    /* ??? */
36 #endif