mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 23:10:54 +01:00
ircd: Update date utils.
This commit is contained in:
parent
1acd278632
commit
b24d36c70d
2 changed files with 38 additions and 14 deletions
|
@ -25,29 +25,58 @@
|
||||||
|
|
||||||
namespace ircd
|
namespace ircd
|
||||||
{
|
{
|
||||||
|
using std::chrono::seconds;
|
||||||
|
using std::chrono::milliseconds;
|
||||||
|
using std::chrono::microseconds;
|
||||||
|
using std::chrono::nanoseconds;
|
||||||
|
using std::chrono::duration_cast;
|
||||||
|
using std::chrono::system_clock;
|
||||||
|
using std::chrono::steady_clock;
|
||||||
|
using std::chrono::time_point;
|
||||||
|
|
||||||
using microtime_t = std::pair<time_t, int32_t>;
|
using microtime_t = std::pair<time_t, int32_t>;
|
||||||
|
using steady_point = time_point<steady_clock>;
|
||||||
|
using system_point = time_point<system_clock>;
|
||||||
|
|
||||||
microtime_t microtime();
|
microtime_t microtime();
|
||||||
ssize_t microtime(char *const &buf, const size_t &size);
|
ssize_t microtime(char *const &buf, const size_t &size);
|
||||||
std::ostream &operator<<(std::ostream &, const microtime_t &);
|
std::ostream &operator<<(std::ostream &, const microtime_t &);
|
||||||
|
|
||||||
template<class resolution = std::chrono::seconds> resolution now();
|
template<class unit = seconds> unit now();
|
||||||
template<class resolution = std::chrono::seconds> time_t time();
|
template<> steady_point now();
|
||||||
|
template<> system_point now();
|
||||||
|
|
||||||
|
template<class unit = seconds> time_t time();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class resolution>
|
template<class unit>
|
||||||
time_t
|
time_t
|
||||||
ircd::time()
|
ircd::time()
|
||||||
{
|
{
|
||||||
return now<resolution>().count();
|
return now<unit>().count();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class resolution>
|
template<> inline
|
||||||
resolution
|
ircd::steady_point
|
||||||
|
ircd::now()
|
||||||
|
{
|
||||||
|
return steady_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> inline
|
||||||
|
ircd::system_point
|
||||||
|
ircd::now()
|
||||||
|
{
|
||||||
|
return system_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class unit>
|
||||||
|
unit
|
||||||
ircd::now()
|
ircd::now()
|
||||||
{
|
{
|
||||||
const auto now
|
const auto now
|
||||||
{
|
{
|
||||||
std::chrono::system_clock::now()
|
steady_clock::now()
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto tse
|
const auto tse
|
||||||
|
@ -55,7 +84,7 @@ ircd::now()
|
||||||
now.time_since_epoch()
|
now.time_since_epoch()
|
||||||
};
|
};
|
||||||
|
|
||||||
return std::chrono::duration_cast<resolution>(tse);
|
return std::chrono::duration_cast<unit>(tse);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::ostream &
|
inline std::ostream &
|
||||||
|
|
|
@ -165,7 +165,7 @@ namespace boost::asio
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Items imported into our namespace.
|
// Some items imported into our namespace.
|
||||||
//
|
//
|
||||||
|
|
||||||
namespace ircd
|
namespace ircd
|
||||||
|
@ -174,11 +174,6 @@ namespace ircd
|
||||||
using std::begin;
|
using std::begin;
|
||||||
using std::end;
|
using std::end;
|
||||||
using std::get;
|
using std::get;
|
||||||
using std::chrono::seconds;
|
|
||||||
using std::chrono::milliseconds;
|
|
||||||
using std::chrono::microseconds;
|
|
||||||
using std::chrono::nanoseconds;
|
|
||||||
using std::chrono::duration_cast;
|
|
||||||
using std::static_pointer_cast;
|
using std::static_pointer_cast;
|
||||||
using std::dynamic_pointer_cast;
|
using std::dynamic_pointer_cast;
|
||||||
using std::const_pointer_cast;
|
using std::const_pointer_cast;
|
||||||
|
|
Loading…
Reference in a new issue