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.
Edit: The original timestamp is floating point. I can't change it and i don't want to lose the sub-second precision.
For a machine that has boost date/time compiled to the default level of microsecond resolution, try this:
The output for this is "Time stamp is 2009-Aug-17 16:00:00.500000" on my linux box.
after some fiddling around i came up with this:
I'm not sure this is the best solution, but it seems to do what i need.
Use the
from_time_t()
conversion function. Atime_t
is a UNIX timestamp, i.e. the number of seconds since the epoch.