unix timestamp to boost::posix_time::ptime

前端 未结 3 1004
Happy的楠姐
Happy的楠姐 2021-01-17 13:42

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. T

3条回答
  •  半阙折子戏
    2021-01-17 14:08

    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.

提交回复
热议问题