22 #include "boost/date_time/posix_time/posix_time.hpp"
25 template <
typename Duration>
27 const std::chrono::time_point<std::chrono::system_clock, Duration> &from)
29 typedef std::chrono::nanoseconds duration_t;
30 typedef duration_t::rep rep_t;
32 std::chrono::duration_cast<duration_t>(from.time_since_epoch()).count();
33 rep_t sec = d / 1000000000;
34 rep_t nsec = d % 1000000000;
35 return boost::posix_time::from_time_t(0) +
36 boost::posix_time::seconds(
static_cast<long>(sec)) +
37 #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
38 boost::posix_time::nanoseconds(nsec);
40 boost::posix_time::microseconds((nsec + 500) / 1000);