id summary reporter owner description type status milestone component version severity resolution keywords cc 3470 Bug in boost::date_time::c_time::localtime(), boost::date_time::c_time::gmtime() Farid Zaripov Andrey Semashev " The code below fails on asserts on MSVC 8 {{{ const std::time_t tt = std::time(0); std::tm tms; tms.tm_hour = 28; const std::tm * ptm = boost::date_time::c_time::localtime(&tt, &tms); assert(&tms == ptm); assert(28 != tms.tm_hour); }}} The proposed patch: {{{ Index: c_time.hpp =================================================================== --- c_time.hpp (revision 56335) +++ c_time.hpp (working copy) @@ -80,18 +80,20 @@ inline static std::tm* localtime(const std::time_t* t, std::tm* result) { - result = std::localtime(t); - if (!result) + std::tm* const tmp = std::localtime(t); + if (!tmp) boost::throw_exception(std::runtime_error(""could not convert calendar time to local time"")); + *result = *tmp; return result; } //! requires a pointer to a user created std::tm struct inline static std::tm* gmtime(const std::time_t* t, std::tm* result) { - result = std::gmtime(t); - if (!result) + std::tm* const tmp = std::gmtime(t); + if (!tmp) boost::throw_exception(std::runtime_error(""could not convert calendar time to UTC time"")); + *result = *tmp; return result; } #if (defined(_MSC_VER) && (_MSC_VER >= 1400)) }}} " Bugs closed Boost 1.41.0 date_time Boost 1.40.0 Problem fixed gmtime, localtime