aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-04-01 12:25:50 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-04-01 12:25:56 +0200
commit351d0ad40495d1d2a2400af4d2cc975863258d3f (patch)
tree46ee676e63dd87792e46236d65b4ce4c809b48d6 /src
parent4aa07fa735696eef828b7a82daedc654d626deac (diff)
parente025246fe27f2d4bcdb6f4e9b5af9084dcc2e0a8 (diff)
downloadbitcoin-351d0ad40495d1d2a2400af4d2cc975863258d3f.tar.xz
Merge #10129: scheduler: fix sub-second precision with boost < 1.50
e025246 scheduler: fix sub-second precision with boost < 1.50 (Cory Fields) Tree-SHA512: b9d4875406c1a2bf3cb6412d7511c24d871bfba6a2ea5ccfbbf7392f2f8850027b001b776da422fea592878da21d897b1aa56d92bc2239869055dce79fd442ac
Diffstat (limited to 'src')
-rw-r--r--src/scheduler.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/scheduler.cpp b/src/scheduler.cpp
index 861c1a0220..0c1cfa2718 100644
--- a/src/scheduler.cpp
+++ b/src/scheduler.cpp
@@ -23,7 +23,9 @@ CScheduler::~CScheduler()
#if BOOST_VERSION < 105000
static boost::system_time toPosixTime(const boost::chrono::system_clock::time_point& t)
{
- return boost::posix_time::from_time_t(boost::chrono::system_clock::to_time_t(t));
+ // Creating the posix_time using from_time_t loses sub-second precision. So rather than exporting the time_point to time_t,
+ // start with a posix_time at the epoch (0) and add the milliseconds that have passed since then.
+ return boost::posix_time::from_time_t(0) + boost::posix_time::milliseconds(boost::chrono::duration_cast<boost::chrono::milliseconds>(t.time_since_epoch()).count());
}
#endif