lokinet/llarp/time.cpp

26 lines
611 B
C++
Raw Normal View History

2018-01-29 14:27:24 +00:00
#include <llarp/time.h>
#include <llarp/time.hpp>
2018-01-19 16:51:27 +00:00
2018-10-04 13:02:03 +00:00
namespace llarp
{
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-10-04 23:43:15 +00:00
// this time, it doesn't get truncated -despair
// that concern is what drove me back to the POSIX C time functions
// in the first place
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
}