Fix corrupt timestamps on Windows builds

The logic for building the timeval struct wasn't quite right.
This commit is contained in:
Jon Escombe
2016-04-07 12:58:55 +01:00
parent beb663fa44
commit 21bd66e616

View File

@@ -108,9 +108,9 @@ typedef struct ant_sensor_type {
static inline double get_timestamp( void ) {
struct timeval tv;
#ifdef Q_CC_MSVC
QTime now = QTime::currentTime();
tv.tv_sec = now.second();
tv.tv_usec = now.msec();
QDateTime now = QDateTime::currentDateTime();
tv.tv_sec = now.toMSecsSinceEpoch() / 1000;
tv.tv_usec = (now.toMSecsSinceEpoch() % 1000) * 1000;
#else
gettimeofday(&tv, NULL);
#endif
@@ -119,9 +119,9 @@ static inline double get_timestamp( void ) {
static inline void get_timeofday(struct timeval* tv) {
#ifdef Q_CC_MSVC
QTime now = QTime::currentTime();
tv->tv_sec = now.second();
tv->tv_usec = now.msec();
QDateTime now = QDateTime::currentDateTime();
tv->tv_sec = now.toMSecsSinceEpoch() / 1000;
tv->tv_usec = (now.toMSecsSinceEpoch() % 1000) * 1000;
#else
gettimeofday(tv, NULL);
#endif