version 1.1, 2001/04/10 23:01:52
|
version 1.2, 2001/04/11 00:23:44
|
|
|
// Author: Michael E. Brasher | // Author: Michael E. Brasher |
// | // |
// $Log$ | // $Log$ |
|
// Revision 1.2 2001/04/11 00:23:44 mike |
|
// new files |
|
// |
// Revision 1.1 2001/04/10 23:01:52 mike | // Revision 1.1 2001/04/10 23:01:52 mike |
// Added new TimeValue class and regression tests for it. | // Added new TimeValue class and regression tests for it. |
// Modified Stopwatch class to use TimeValue class. | // Modified Stopwatch class to use TimeValue class. |
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
#include <cstdio> |
|
#include <cstdlib> |
|
|
|
#ifdef PEGASUS_OS_TYPE_WINDOWS |
|
# include <windows.h> |
|
# include <sys/types.h> |
|
# include <sys/timeb.h> |
|
#elif PEGASUS_OS_TYPE_UNIX |
|
# include <time.h> |
|
#elif |
|
# error not implemented on this platform |
|
#endif |
|
|
|
void _GetCurrentTime(Uint32& seconds, Uint32& milliseconds) |
|
{ |
|
#ifdef PEGASUS_OS_TYPE_UNIX |
|
timeval tv; |
|
gettimeofday(&tv, 0); |
|
seconds = (int)tv.tv_sec; |
|
milliseconds = (int)tv.tvusec; |
|
#else |
|
FILETIME ft; |
|
GetSystemTimeAsFileTime(&ft); |
|
ULARGE_INTEGER largeInt = { ft.dwLowDateTime, ft.dwHighDateTime }; |
|
largeInt.QuadPart -= 0x19db1ded53e8000; |
|
seconds = long(largeInt.QuadPart / (10000 * 1000)); |
|
milliseconds = long((largeInt.QuadPart % (10000 * 1000)) / 10); |
|
#endif |
|
} |
|
|
|
TimeValue TimeValue::getCurrentTime() |
|
{ |
|
Uint32 seconds; |
|
Uint32 milliseconds; |
|
_GetCurrentTime(seconds, milliseconds); |
|
return TimeValue(seconds, milliseconds); |
|
} |
|
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |