How can I convert a chrono duration to a time_point, which is later than clock's epoch with the given duration? I tried to find epoch time in chrono clock without success.
From the synopsis in 20.12.6 [time.point]:
template <class Clock, class Duration = typename Clock::duration>
class time_point
{
public:
constexpr explicit time_point(const duration& d); // same as time_point() + d
This can be used (for example) like:
using namespace std::chrono;
system_clock::time_point tp{30min}; // Needs C++14 for the literal
Though the system_clock::time_point is not specified in the standard, in practice this creates a time_point
referring to 1970-01-01 00:30:00 UTC.
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