7 #if defined(HAVE_CONFIG_H) 15 #include <boost/date_time/posix_time/posix_time.hpp> 16 #include <boost/thread.hpp> 18 static std::atomic<int64_t> nMockTime(0);
22 int64_t mocktime = nMockTime.load(std::memory_order_relaxed);
23 if (mocktime)
return mocktime;
25 time_t now = time(
nullptr);
32 nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
37 return nMockTime.load(std::memory_order_relaxed);
42 int64_t now = (boost::posix_time::microsec_clock::universal_time() -
43 boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
50 int64_t now = (boost::posix_time::microsec_clock::universal_time() -
51 boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_microseconds();
69 #if defined(HAVE_WORKING_BOOST_SLEEP_FOR) 70 boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
71 #elif defined(HAVE_WORKING_BOOST_SLEEP) 72 boost::this_thread::sleep(boost::posix_time::milliseconds(n));
75 #error missing boost sleep implementation 81 static std::locale classic(std::locale::classic());
83 std::locale loc(classic,
new boost::posix_time::time_facet(pszFormat));
86 ss << boost::posix_time::from_time_t(nTime);
void MilliSleep(int64_t n)
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
void SetMockTime(int64_t nMockTimeIn)
int64_t GetSystemTimeInSeconds()
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...