i2pd/Timestamp.h

35 lines
712 B
C
Raw Normal View History

2013-10-27 15:29:34 +00:00
#ifndef TIMESTAMP_H__
#define TIMESTAMP_H__
#include <inttypes.h>
#include <chrono>
namespace i2p
{
namespace util
{
2016-11-01 20:27:44 +00:00
extern std::chrono::seconds g_TimeOffset;
2016-09-21 16:02:52 +00:00
2013-10-27 15:29:34 +00:00
inline uint64_t GetMillisecondsSinceEpoch ()
{
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()).count ();
}
inline uint32_t GetHoursSinceEpoch ()
{
return std::chrono::duration_cast<std::chrono::hours>(
std::chrono::system_clock::now().time_since_epoch()).count ();
}
2013-12-10 13:10:49 +00:00
inline uint64_t GetSecondsSinceEpoch ()
2013-12-10 13:10:49 +00:00
{
return std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::system_clock::now().time_since_epoch()).count ();
}
2013-10-27 15:29:34 +00:00
}
}
#endif