Browse Source

scheduler: fix sub-second precision with boost < 1.50

0.15
Cory Fields 8 years ago
parent
commit
e025246fe2
  1. 4
      src/scheduler.cpp

4
src/scheduler.cpp

@ -23,7 +23,9 @@ CScheduler::~CScheduler() @@ -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

Loading…
Cancel
Save