51 lines
1.4 KiB
C
51 lines
1.4 KiB
C
static char sccsid[] = "@(#)91 1.3 src/bos/usr/ccs/lib/libbsd/ftime.c, libbsd, bos411, 9428A410j 3/4/94 10:11:33";
|
|
/*
|
|
* COMPONENT_NAME: (LIBBSD) Berkeley Compatibility Library
|
|
*
|
|
* FUNCTIONS: ftime
|
|
*
|
|
* ORIGINS: 26 27
|
|
*
|
|
* This module contains IBM CONFIDENTIAL code. -- (IBM
|
|
* Confidential Restricted when combined with the aggregated
|
|
* modules for this product)
|
|
* SOURCE MATERIALS
|
|
* (C) COPYRIGHT International Business Machines Corp. 1985, 1994
|
|
* All Rights Reserved
|
|
*
|
|
* US Government Users Restricted Rights - Use, duplication or
|
|
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
*
|
|
* Copyright (c) 1980 Regents of the University of California.
|
|
* All rights reserved. The Berkeley software License Agreement
|
|
* specifies the terms and conditions for redistribution.
|
|
*/
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/time.h>
|
|
#include <timeb.h>
|
|
|
|
/*
|
|
* NAME: ftime
|
|
*
|
|
* FUNCTION: returns the number of seconds (up to 1000 milliseconds) since epoch.
|
|
*
|
|
* RETURNS:
|
|
*/
|
|
|
|
int
|
|
ftime(struct timeb *tp)
|
|
{
|
|
struct timeval t;
|
|
struct timezone tz;
|
|
|
|
if (gettimeofday(&t, &tz) < 0)
|
|
return (-1);
|
|
tp->time = t.tv_sec;
|
|
tp->millitm = t.tv_usec / 1000;
|
|
tp->timezone = tz.tz_minuteswest;
|
|
tp->dstflag = tz.tz_dsttime;
|
|
|
|
return(0);
|
|
}
|