efl/legacy/ecore/src/lib/ecore/ecore_time.c

44 lines
933 B
C
Raw Normal View History

/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# undef WIN32_LEAN_AND_MEAN
2004-10-20 10:51:29 -07:00
#else
# include <sys/time.h>
2004-10-20 10:51:29 -07:00
#endif
2007-08-26 05:57:11 -07:00
#include "ecore_private.h"
#include "Ecore.h"
2004-10-20 10:51:29 -07:00
2007-09-17 16:13:59 -07:00
/* FIXME: clock_gettime() is an option... */
/**
* Retrieves the current system time as a floating point value in seconds.
* @return The number of seconds since 12.00AM 1st January 1970.
* @ingroup Ecore_Time_Group
*/
EAPI double
ecore_time_get(void)
{
#ifdef _WIN32
FILETIME ft;
double time;
GetSystemTimeAsFileTime(&ft);
time = (double)ft.dwLowDateTime + 4294967296.0 * (double)ft.dwHighDateTime;
return time / 10000000;
#else
# ifdef HAVE_GETTIMEOFDAY
struct timeval timev;
gettimeofday(&timev, NULL);
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
# else
# error "Your platform isn't supported yet"
# endif
#endif /* _WIN32 */
}