I have a double
containing seconds. I would like to convert this into a time_t
.
I can't find a standard function which accomplishes this. Do I have to fill out the time_t
by hand?
The type of std::time_t
is unspecified.
Although not defined, this is almost always an integral value holding the number of seconds (not counting leap seconds) since 00:00, Jan 1 1970 UTC, corresponding to POSIX time.
So, just a safe casting between them could be fine. Also be carefull about portability (because it's type is not specified in the standard) and consider about the values than can not fit while casting from double to integrals.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With