Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要将自纪元以来以毫秒为单位的时间转换为 a boost::posix_time::ptime。我看到的唯一功能是转换,from_time_t但这仅以秒为单位,并且会丢失毫秒。
boost::posix_time::ptime
from_time_t
如何从纪元以来的毫秒数转换为 ptime 类型?
ms自纪元以来您的毫秒数在哪里:
ms
ptime epoch_milliseconds_to_ptime(unsigned long int ms) { static const ptime epoch(date(1970, 1, 1)); return epoch + milliseconds(ms); }
from_time_t(millis / 1000) + millisec(millis % 1000)