
3 Nov
2009
3 Nov
'09
2:26 a.m.
A lot of the constructors of ptime deals with getting the current system time or time structures. I have a double with the seconds and fractional microseconds from midnight January 1, 1970. What is the best way to create a ptime object from this double?
#include <boost/date_time/posix_time/posix_time.hpp> #include <math.h> namespace pt = boost::posix_time; int main() { double d = 1000.1; double sec; double mksec = std::modf(d, &sec); pt::ptime t = pt::from_time_t(static_cast<int>(sec)) + pt::microseconds(static_cast<int>(mksec)); }