2018-01-29 14:27:24 +00:00
|
|
|
#include <llarp/time.h>
|
2018-10-04 13:02:03 +00:00
|
|
|
#include <chrono>
|
2018-01-19 16:51:27 +00:00
|
|
|
|
2018-10-04 13:02:03 +00:00
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
typedef std::chrono::steady_clock Clock_t;
|
|
|
|
|
|
|
|
template < typename Res >
|
|
|
|
static llarp_time_t
|
|
|
|
time_since_epoch()
|
|
|
|
{
|
|
|
|
return std::chrono::duration_cast< Res >(
|
|
|
|
llarp::Clock_t::now().time_since_epoch())
|
|
|
|
.count();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
// use std::chrono because otherwise the network breaks with Daylight Savings
|
2018-05-22 15:54:19 +00:00
|
|
|
llarp_time_t
|
|
|
|
llarp_time_now_ms()
|
|
|
|
{
|
2018-10-04 13:02:03 +00:00
|
|
|
return llarp::time_since_epoch< std::chrono::milliseconds >();
|
2018-01-29 14:27:24 +00:00
|
|
|
}
|