diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2017-03-30 15:26:31 -0400 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2017-03-31 11:54:58 -0400 |
commit | e025246fe27f2d4bcdb6f4e9b5af9084dcc2e0a8 (patch) | |
tree | 537f1a5b97bedbf1cfc66bd1f89de49577696917 | |
parent | cde9b1a864c1743b0a20f914028e53df12a70906 (diff) |
scheduler: fix sub-second precision with boost < 1.50
-rw-r--r-- | src/scheduler.cpp | 4 |
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 |