mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
ircd: Add additional formatted microdate().
This commit is contained in:
parent
432e317314
commit
8dd0a22351
2 changed files with 29 additions and 0 deletions
|
@ -46,6 +46,7 @@ namespace ircd
|
||||||
|
|
||||||
// Other tools
|
// Other tools
|
||||||
string_view smalldate(const mutable_buffer &buf, const time_t <ime);
|
string_view smalldate(const mutable_buffer &buf, const time_t <ime);
|
||||||
|
string_view microdate(const mutable_buffer &buf);
|
||||||
|
|
||||||
// Interface conveniences.
|
// Interface conveniences.
|
||||||
std::ostream &operator<<(std::ostream &, const microtime_t &);
|
std::ostream &operator<<(std::ostream &, const microtime_t &);
|
||||||
|
|
|
@ -54,6 +54,34 @@ ircd::smalldate(const mutable_buffer &buf,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ircd::string_view
|
||||||
|
ircd::microdate(const mutable_buffer &buf)
|
||||||
|
{
|
||||||
|
auto mt
|
||||||
|
{
|
||||||
|
microtime()
|
||||||
|
};
|
||||||
|
|
||||||
|
struct tm lt;
|
||||||
|
localtime_r(&mt.first, <);
|
||||||
|
const auto length
|
||||||
|
{
|
||||||
|
::snprintf(data(buf), size(buf), "%04d/%02d/%02d %02d:%02d:%02d.%06d",
|
||||||
|
lt.tm_year + 1900,
|
||||||
|
lt.tm_mon + 1,
|
||||||
|
lt.tm_mday,
|
||||||
|
lt.tm_hour,
|
||||||
|
lt.tm_min,
|
||||||
|
lt.tm_sec,
|
||||||
|
mt.second)
|
||||||
|
};
|
||||||
|
|
||||||
|
return string_view
|
||||||
|
{
|
||||||
|
data(buf), size_t(length)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
ircd::string_view
|
ircd::string_view
|
||||||
ircd::timef(const mutable_buffer &out,
|
ircd::timef(const mutable_buffer &out,
|
||||||
const char *const &fmt)
|
const char *const &fmt)
|
||||||
|
|
Loading…
Reference in a new issue