Skip to content

Commit

Permalink
Revert "Revert "Avoid boost::posix_time functions that have potential…
Browse files Browse the repository at this point in the history
… out-of-bounds read bugs. ref #1459""

This reverts commit f19cb7b.
  • Loading branch information
str4d committed Oct 22, 2016
1 parent f808be7 commit 09864ab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/utiltime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "utiltime.h"

#include <chrono>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread.hpp>

Expand All @@ -30,14 +31,14 @@ void SetMockTime(int64_t nMockTimeIn)

int64_t GetTimeMillis()
{
return (boost::posix_time::microsec_clock::universal_time() -
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
}

int64_t GetTimeMicros()
{
return (boost::posix_time::microsec_clock::universal_time() -
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_microseconds();
return std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
}

void MilliSleep(int64_t n)
Expand Down

0 comments on commit 09864ab

Please sign in to comment.