Skip to content

Commit 351d0ad

Browse files
committed
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
2 parents 4aa07fa + e025246 commit 351d0ad

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/scheduler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ CScheduler::~CScheduler()
2323
#if BOOST_VERSION < 105000
2424
static boost::system_time toPosixTime(const boost::chrono::system_clock::time_point& t)
2525
{
26-
return boost::posix_time::from_time_t(boost::chrono::system_clock::to_time_t(t));
26+
// Creating the posix_time using from_time_t loses sub-second precision. So rather than exporting the time_point to time_t,
27+
// start with a posix_time at the epoch (0) and add the milliseconds that have passed since then.
28+
return boost::posix_time::from_time_t(0) + boost::posix_time::milliseconds(boost::chrono::duration_cast<boost::chrono::milliseconds>(t.time_since_epoch()).count());
2729
}
2830
#endif
2931

0 commit comments

Comments
 (0)