You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/libsarp/time.cpp

26 lines
489 B
C++

#include <sarp/time.h>
#include <chrono>
namespace sarp
{
typedef std::chrono::steady_clock clock_t;
template<typename Res>
static uint64_t time_since_epoch()
{
return std::chrono::duration_cast<Res>(sarp::clock_t::now().time_since_epoch()).count();
}
}
extern "C" {
uint64_t sarp_time_now_ms()
{
return sarp::time_since_epoch<std::chrono::milliseconds>();
}
uint64_t sarp_time_now_sec()
{
return sarp::time_since_epoch<std::chrono::seconds>();
}
}