From da53c17315d3eb0d0177608d306d208bdf05786b Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 7 Jun 2019 20:13:23 +0100 Subject: Implement support for millisecond level server-time accuracy. --- src/modules/m_ircv3_servertime.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modules/m_ircv3_servertime.cpp b/src/modules/m_ircv3_servertime.cpp index 1c35c422b..ec6e48daa 100644 --- a/src/modules/m_ircv3_servertime.cpp +++ b/src/modules/m_ircv3_servertime.cpp @@ -24,16 +24,20 @@ class ServerTimeTag : public IRCv3::ServerTime::Manager, public IRCv3::CapTag { time_t lasttime; + long lasttimens; std::string lasttimestring; void RefreshTimeString() { const time_t currtime = ServerInstance->Time(); - if (currtime != lasttime) + const long currtimens = ServerInstance->Time_ns(); + if (currtime != lasttime || currtimens != lasttimens) { lasttime = currtime; - // Cache the string so it's not recreated every time a message is sent - lasttimestring = IRCv3::ServerTime::FormatTime(currtime); + lasttimens = currtimens; + + // Cache the string so it's not recreated every time a message is sent. + lasttimestring = IRCv3::ServerTime::FormatTime(currtime, (currtimens ? currtimens / 1000000 : 0)); } } @@ -42,6 +46,7 @@ class ServerTimeTag : public IRCv3::ServerTime::Manager, public IRCv3::CapTag(mod, "server-time", "time") , lasttime(0) + , lasttimens(0) { tagprov = this; } -- cgit v1.2.3