summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-06-07 20:13:23 +0100
committerPeter Powell <petpow@saberuk.com>2019-06-07 20:22:43 +0100
commitda53c17315d3eb0d0177608d306d208bdf05786b (patch)
treef5e85992d318f385ad16779ab3dbceb3765e08b4 /src/modules
parent8bbd67b1f7b87df9b36a950b3b699c5b76a1748f (diff)
Implement support for millisecond level server-time accuracy.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_ircv3_servertime.cpp11
1 files changed, 8 insertions, 3 deletions
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<ServerTimeTag>
{
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<Se
: IRCv3::ServerTime::Manager(mod)
, IRCv3::CapTag<ServerTimeTag>(mod, "server-time", "time")
, lasttime(0)
+ , lasttimens(0)
{
tagprov = this;
}