UNIX时间戳提振::了posix_time ::分组时间 [英] unix timestamp to boost::posix_time::ptime
本文介绍了UNIX时间戳提振::了posix_time ::分组时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从epoch到分组时间
双转换与秒数。我是preTY肯定必须有一个简单的方法来做到这一点,但我无法找到任何东西。谢谢你。
I need to convert double with number of seconds since the epoch to ptime
. I'm prety sure there must be an easy way to do this, but I couldn't find anything. Thanks.
编辑:原时间戳是浮点。我不能改变它,我不想失去亚秒precision。
The original timestamp is floating point. I can't change it and i don't want to lose the sub-second precision.
推荐答案
一些摆弄周围后,我想出了这一点:
after some fiddling around i came up with this:
ptime(date(1970, 1, 1), time_duration(0, 0, 0, time_duration::ticks_per_second() * 1234567890.0987654321))
我不知道这是最好的解决办法,但似乎做我所需要的。
I'm not sure this is the best solution, but it seems to do what i need.
这篇关于UNIX时间戳提振::了posix_time ::分组时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文