1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 20:16:36 +02:00

Use clock_gettime if it is available.

This commit is contained in:
Sadie Powell
2024-03-18 11:13:46 +00:00
parent 753119c4a1
commit cb3848b7db
13 changed files with 42 additions and 31 deletions
+3 -8
View File
@@ -29,20 +29,15 @@
static Anope::string GetTimeStamp()
{
char tbuf[256];
time_t t;
if (time(&t) < 0)
t = Anope::CurTime;
tm tm = *localtime(&t);
Anope::UpdateTime();
auto tm = *localtime(&Anope::CurTime);
if (Anope::Debug)
{
char *s;
struct timeval tv;
gettimeofday(&tv, NULL);
strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S", &tm);
s = tbuf + strlen(tbuf);
s += snprintf(s, sizeof(tbuf) - (s - tbuf), ".%06d", static_cast<int>(tv.tv_usec));
s += snprintf(s, sizeof(tbuf) - (s - tbuf), ".%06lld", static_cast<long long>(Anope::CurTimeNs / 1000));
strftime(s, sizeof(tbuf) - (s - tbuf) - 1, " %Y]", &tm);
}
else