Skip to content

Commit e025246

Browse files
committed
scheduler: fix sub-second precision with boost < 1.50
1 parent cde9b1a commit e025246

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)