6 #if defined(HAVE_CONFIG_H)
7 #include "config/bitcoin-config.h"
12 #include <boost/date_time/posix_time/posix_time.hpp>
13 #include <boost/thread.hpp>
17 static int64_t nMockTime = 0;
21 if (nMockTime)
return nMockTime;
23 time_t now = time(NULL);
30 nMockTime = nMockTimeIn;
35 int64_t now = (boost::posix_time::microsec_clock::universal_time() -
36 boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
43 int64_t now = (boost::posix_time::microsec_clock::universal_time() -
44 boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_microseconds();
57 if (nMockTime)
return nMockTime*1000000;
70 #if defined(HAVE_WORKING_BOOST_SLEEP_FOR)
71 boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
72 #elif defined(HAVE_WORKING_BOOST_SLEEP)
73 boost::this_thread::sleep(boost::posix_time::milliseconds(n));
76 #error missing boost sleep implementation
82 static std::locale classic(std::locale::classic());
84 std::locale loc(classic,
new boost::posix_time::time_facet(pszFormat));
87 ss << boost::posix_time::from_time_t(nTime);
int64_t GetSystemTimeInSeconds()
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units.
int64_t GetLogTimeMicros()
Return a time useful for the debug log.
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
void SetMockTime(int64_t nMockTimeIn)
void MilliSleep(int64_t n)