ack/lang/cem/libcc.ansi/time/time.c

37 lines
704 B
C
Raw Normal View History

1989-06-12 15:22:14 +00:00
/*
* time - return the current calendar time (seconds since jan 1, 1970)
*/
/* $Header$ */
1989-12-18 15:33:48 +00:00
#if defined(__BSD4_2)
1989-06-12 15:22:14 +00:00
#include <time.h>
1989-12-18 15:33:48 +00:00
/*
* Structure returned by gettimeofday(2) system call,
* and used in other calls.
*/
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int _gettimeofday(struct timeval *tp, struct timezone *tzp);
1989-06-12 15:22:14 +00:00
time_t
time(time_t *timer)
{
struct timeval tv;
struct timezone tz;
_gettimeofday(&tv, &tz);
1989-06-12 15:22:14 +00:00
if (timer) *timer = tv.tv_sec;
return tv.tv_sec;
}
1989-12-18 15:33:48 +00:00
#else
/* Assume time() is a system call */ /* ??? */
#endif