Skip to content

Commit

Permalink
Switch epoch time functions to system_clock
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Mar 1, 2018
1 parent a24bfe2 commit d47d421
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 0 additions & 2 deletions AirLib/include/common/ScalableClock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class ScalableClock : public ClockBase {


private:
typedef std::chrono::high_resolution_clock clock;

double scale_;
TTimeDelta latency_;
double offset_;
Expand Down
13 changes: 8 additions & 5 deletions AirLib/include/common/common_utils/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,18 @@ class Utils {
}

//high precision time in seconds since epoch
static double getTimeSinceEpochSecs(std::chrono::high_resolution_clock::time_point* t = nullptr)
static double getTimeSinceEpochSecs(std::chrono::system_clock::time_point* t = nullptr)
{
using Clock = std::chrono::high_resolution_clock;
using Clock = std::chrono::system_clock; //high res clock has epoch since boot instead of since 1970 for VC++
return std::chrono::duration<double>((t != nullptr ? *t : Clock::now() ).time_since_epoch()).count();
}
static uint64_t getTimeSinceEpochNanos(std::chrono::high_resolution_clock::time_point* t = nullptr)
static uint64_t getTimeSinceEpochNanos(std::chrono::system_clock::time_point* t = nullptr)
{
using Clock = std::chrono::high_resolution_clock;
return static_cast<uint64_t>((t != nullptr ? *t : Clock::now() ).time_since_epoch().count());
using Clock = std::chrono::system_clock; //high res clock has epoch since boot instead of since 1970 for VC++
return std::chrono::duration_cast<std::chrono::nanoseconds>(
(t != nullptr ? *t : Clock::now())
.time_since_epoch()).
count();
}

template<typename T>
Expand Down

0 comments on commit d47d421

Please sign in to comment.