开发者

boost::posix_time. How to represent both microsecond and nanosecond datetimes in the same application

I'd like to use boost::posix_time::ptime as a 64 bit representation of a datetime with microsecond resolution. I'd also sometimes like to represent a datetime with nanosecond resolution which uses 96 bits.

Unfortunately, it seems like you have to choose one or the other. Why have the boost developers done this via a #define rather than a template parameter? Is there any way to represent both of these types within the one application?

From: http://www.boost.org/doc/libs/1_47_0/doc/html/date_time/details.html#date_time.buildinfo

"To use the alternate resolution (96 bit nanosecond) the variable BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG must be defined in the li开发者_开发百科brary users project files (ie Makefile, Jamfile, etc). This macro is not used by the Gregorian system and therefore has no effect when building the library."


The BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG basically makes the data type use higher precession for the time. Since you need it, use it. I do not see how does,

"I'd like to use boost::posix_time::ptime as a 64 bit representation of a datetime with microsecond resolution,"

come into that. Are you saying that you are using the ptime type as a binary/on-disk representation of the time?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜