xref: /original-bsd/lib/libcompat/4.1/ftime.c (revision 7211505a)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #if defined(LIBC_SCCS) && !defined(lint)
8 static char sccsid[] = "@(#)ftime.c	5.2 (Berkeley) 03/09/86";
9 #endif LIBC_SCCS and not lint
10 
11 #include <sys/types.h>
12 #include <sys/time.h>
13 
14 /*
15  * Backwards compatible ftime.
16  */
17 
18 /* from old timeb.h */
19 struct timeb {
20 	time_t	time;
21 	u_short	millitm;
22 	short	timezone;
23 	short	dstflag;
24 };
25 
26 ftime(tp)
27 	register struct timeb *tp;
28 {
29 	struct timeval t;
30 	struct timezone tz;
31 
32 	if (gettimeofday(&t, &tz) < 0)
33 		return (-1);
34 	tp->time = t.tv_sec;
35 	tp->millitm = t.tv_usec / 1000;
36 	tp->timezone = tz.tz_minuteswest;
37 	tp->dstflag = tz.tz_dsttime;
38 }
39