Partially resolves issue #46 Use epoch milliseconds rather than seconds

This commit is contained in:
Matt Hill
2014-08-31 10:34:50 -04:00
parent 3b2cd74306
commit 41bedff338
2 changed files with 21 additions and 5 deletions

View File

@@ -97,6 +97,12 @@ timespec diff(timespec start, timespec end)
return temp; return temp;
} }
long getEpochTime()
{
return std::time(0) * 1000;
}
#else #else
void getTime(timespec* time) void getTime(timespec* time)
@@ -138,10 +144,14 @@ timespec diff(timespec start, timespec end)
return temp; return temp;
} }
long getEpochTime()
{
struct timeval tp;
gettimeofday(&tp, NULL);
long int ms = tp.tv_sec * 1000 + tp.tv_usec / 1000;
}
#endif #endif
int getEpochTime()
{
return std::time(0);
}

View File

@@ -4,6 +4,12 @@
#include <iostream> #include <iostream>
#include <ctime> #include <ctime>
#ifdef WINDOWS
// Import windows only stuff
#else
#include <sys/time.h>
#endif
// Support for OS X // Support for OS X
#ifdef __MACH__ #ifdef __MACH__
#include <mach/clock.h> #include <mach/clock.h>
@@ -20,6 +26,6 @@
void getTime(timespec* time); void getTime(timespec* time);
double diffclock(timespec time1,timespec time2); double diffclock(timespec time1,timespec time2);
int getEpochTime(); long getEpochTime();
#endif #endif