1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include "TimeUtil.h"
TimeUtil::TimeUtil()
{
}
TimeUtil::~TimeUtil()
{
}
// codigo extraido da JVM (para fazer um sysTimeMillis da mesma forma
#ifdef WINDOWS
#define FT2INT64(ft) ((jlong)(ft).dwHighDateTime << 32 | (jlong)(ft).dwLowDateTime)
void TimeUtil::sysTimeMillis(jlong ¤tTime)
{
static jlong fileTime_1_1_70 = 0;
if (fileTime_1_1_70 == 0) {
/* Initialize fileTime_1_1_70 -- the Win32 file time of midnight
* 1/1/70.
*/
memset(&st0, 0, sizeof(st0));
st0.wYear = 1970;
st0.wMonth = 1;
st0.wDay = 1;
SystemTimeToFileTime(&st0, &ft0);
fileTime_1_1_70 = FT2INT64(ft0);
}
GetSystemTime(&st0);
SystemTimeToFileTime(&st0, &ft0);
currentTime = (FT2INT64(ft0) - fileTime_1_1_70) / 10000;
}
#else
void TimeUtil::
sysTimeMillis(long & currentTime)
{
gettimeofday(&t, 0);
currentTime = ((jlong)t.tv_sec) * 1000 + (jlong)(t.tv_usec/1000);
}
#endif
|