#include #include #include // Demonstrates the conversion error in boost::date_time::time_resolution_traits // Since v_type is boost::int32_t, even for 64-bit systems like // time_resolution_traits_bi64_impl and time_resolution_traits_adapted64_impl, // date-times whose tick-counts exceed the int32_t limit will overflow. int main() { typedef boost::posix_time::ptime system_time; typedef system_time::date_type date_type; typedef system_time::time_duration_type time_duration_type; date_type d(2038,1,19); time_duration_type td(3,14,8,0); system_time st(system_time(d,td)); // snippet found in boost/thread/pthread/timespec.hpp boost::posix_time::time_duration const time_since_epoch = st - boost::posix_time::from_time_t(0); // the typecast error will cause total_seconds to be negative. std::cerr << st << std::endl; std::cerr << time_since_epoch.total_seconds() << std::endl; }