[date-time] converting milliseconds to time_duration - overflow issue

Hello,
When I convert a (large) number of milliseconds to a time_duration, I noticed a truncation error. This is shown in the following example:
BOOST_AUTO_TEST_CASE(test_time_duration)
{
static const boost::posix_time::ptime ref(boost::gregorian::date(1400,1,1));
static const boost::posix_time::ptime now(boost::gregorian::date(2010,5,18));
boost::int64_t elapsed = (now-ref).total_milliseconds();
boost::posix_time::time_duration d1 = boost::posix_time::millisec(elapsed);
BOOST_CHECK_EQUAL(d1.total_milliseconds(), elapsed);
}
error in "test_time_duration": check d1.total_milliseconds() == elapsed failed [814839926290 != 19261584000000]
This is caused by an overflow issue in the constructor of subsecond_duration (called by boost::posix_time::millisec):
template
participants (1)
-
Johan Ditmar