Skip to content

Commit

Permalink
fraction part of the twamp timestamp fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
demirten committed May 13, 2016
1 parent 71ed95e commit 000fa2d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions common/twamp_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ TwampCommon::TwampCommon(QObject *parent) :
struct twamp_time TwampCommon::getTwampTime()
{
struct twamp_time t;
t.seconds = QDateTime::currentMSecsSinceEpoch() / 1000 + TWAMP_BASE_TIME_OFFSET;
t.fraction = (QDateTime::currentMSecsSinceEpoch() % 1000) * TWAMP_FLOAT_DENOM;
qint64 currentTime = QDateTime::currentMSecsSinceEpoch();
t.seconds = (currentTime / 1000) + TWAMP_BASE_TIME_OFFSET;
/* convert milliseconds to microseconds multiplying by 1000 */
t.fraction = (currentTime % 1000) * TWAMP_FLOAT_DENOM * 1000;
return t;
}

Expand Down

0 comments on commit 000fa2d

Please sign in to comment.