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/llarp/time.cpp

23 lines
566 B
C++

7 years ago
#include <chrono>
7 years ago
#include <llarp/time.h>
7 years ago
7 years ago
namespace llarp {
typedef std::chrono::steady_clock clock_t;
7 years ago
7 years ago
template <typename Res, typename IntType> static IntType time_since_epoch() {
return std::chrono::duration_cast<Res>(
llarp::clock_t::now().time_since_epoch())
.count();
7 years ago
}
7 years ago
} // namespace llarp
7 years ago
extern "C" {
7 years ago
llarp_time_t llarp_time_now_ms() {
return llarp::time_since_epoch<std::chrono::milliseconds, llarp_time_t>();
}
llarp_seconds_t llarp_time_now_sec() {
return llarp::time_since_epoch<std::chrono::seconds, llarp_seconds_t>();
}
7 years ago
}