Пример #1
0
        void save(Archive& ar, boost::chrono::time_point<clock> const& tp, unsigned)
        {
            using namespace boost::chrono;

            milliseconds::rep millis = duration_cast<milliseconds>(tp.time_since_epoch()).count();
            ar & millis;
        }
Пример #2
0
    boost::posix_time::ptime
    to_ptime(boost::chrono::time_point<Clock, Duration> const& from)
    {
        typedef boost::chrono::nanoseconds duration_type;
        typedef duration_type::rep rep_type;
        rep_type d = boost::chrono::duration_cast<duration_type>(
            from.time_since_epoch()).count();
        rep_type sec = d / 1000000000;
        rep_type nsec = d % 1000000000;
        return boost::posix_time::from_time_t(0) +

            boost::posix_time::seconds(static_cast<long>(sec)) +
#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
            boost::posix_time::nanoseconds(nsec);
#else
            boost::posix_time::microseconds((nsec+500)/1000);
#endif
    }