Skip to content

Commit

Permalink
Auto merge of #1601 - str4d:1459-revert-reversion, r=daira
Browse files Browse the repository at this point in the history
Revert "Revert "Avoid boost::posix_time functions that have potential out-of-bounds read bugs. ref #1459""

This reverts commit f19cb7b.

Closes #1459.
  • Loading branch information
zkbot committed Oct 22, 2016
2 parents a12eaa2 + 09864ab commit 0b38094
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/utiltime.cpp
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 0b38094

Please sign in to comment.