00001 /*-------------------------------------------------------------------- 00002 * kb_time.c - KoreBot Library - Basic Time Function 00003 *-------------------------------------------------------------------- 00004 * $Id: kb_time.c,v 1.1 2004/07/29 10:51:55 cgaudin Exp $ 00005 *-------------------------------------------------------------------- 00006 * $Author: cgaudin $ 00007 * $Revision: 1.1 $ 00008 * $Date: 2004/07/29 10:51:55 $ 00009 *--------------------------------------------------------------------*/ 00010 00011 #include "korebot.h" 00012 00027 /*--------------------------------------------------------------------*/ 00031 static u_int32_t ref_time = 0; 00032 00033 /*--------------------------------------------------------------------*/ 00040 kb_time_t kb_getTime(void) 00041 { 00042 unsigned long val; 00043 struct timeval tv; 00044 00045 gettimeofday( &tv , NULL ); 00046 00047 /* set the reference time */ 00048 if ( ref_time == 0 ) { 00049 ref_time = (( tv.tv_sec * 1000 ) + ( tv.tv_usec / 1000 )); 00050 } 00051 00052 val = ( tv.tv_sec * 1000 ) + ( tv.tv_usec / 1000 ); 00053 val -= ref_time; 00054 00055 00056 return val; 00057 } 00058