I'm using boost::date_time and I got a time_t, that have been generated by a library using the time() function from the C standard library.
I'm looking for a way get a local time from that time_t. I'm reading the documentation and can't find any way to do this without providing a time zone, that I don't know about because it's dependant on the machine's locale, and I can't find any way to get one from it.
What am I missing?
For this task, I'd ignore
boost::date_time
and just uselocaltime
(orlocaltime_r
, if available) from the standard library.boost::posix_time::from_time_t()
Try this:
which on my box (Central time) yields:
If you want to format it (which was my test case), use
before calling
second_clock::local_time()
.