mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 08:12:37 +01:00
ircd: Add ago() convenience to timedate suite.
This commit is contained in:
parent
27d394ebfa
commit
87a35a5a41
2 changed files with 19 additions and 0 deletions
|
@ -44,6 +44,7 @@ namespace ircd
|
|||
template<size_t max = 128, class... args> std::string timestr(args&&...);
|
||||
|
||||
// Other tools
|
||||
string_view ago(const mutable_buffer &buf, const system_point &, const uint &fmt = 0);
|
||||
string_view smalldate(const mutable_buffer &buf, const time_t <ime);
|
||||
string_view microdate(const mutable_buffer &buf);
|
||||
string_view microtime(const mutable_buffer &);
|
||||
|
|
|
@ -82,6 +82,24 @@ ircd::microdate(const mutable_buffer &buf)
|
|||
};
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::ago(const mutable_buffer &buf,
|
||||
const system_point &tp,
|
||||
const uint &fmt)
|
||||
{
|
||||
const auto diff
|
||||
{
|
||||
now<system_point>() - tp
|
||||
};
|
||||
|
||||
thread_local char tmp[64];
|
||||
return fmt::sprintf
|
||||
{
|
||||
buf, "%s ago",
|
||||
pretty(tmp, diff, fmt),
|
||||
};
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::timef(const mutable_buffer &out,
|
||||
const char *const &fmt)
|
||||
|
|
Loading…
Reference in a new issue