summaryrefslogtreecommitdiff
path: root/include/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 /include/modules
parent8bbd67b1f7b87df9b36a950b3b699c5b76a1748f (diff)
Implement support for millisecond level server-time accuracy.
Diffstat (limited to 'include/modules')
-rw-r--r--include/modules/ircv3_servertime.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/modules/ircv3_servertime.h b/include/modules/ircv3_servertime.h
index b917531a0..899fd1098 100644
--- a/include/modules/ircv3_servertime.h
+++ b/include/modules/ircv3_servertime.h
@@ -27,12 +27,15 @@ namespace IRCv3
class API;
/** Format a unix timestamp into the format used by server-time.
- * @param t Time to format.
+ * @param secs UNIX timestamp to format.
+ * @params millisecs Number of milliseconds to format.
* @return Time in server-time format, as a string.
*/
- inline std::string FormatTime(time_t t)
+ inline std::string FormatTime(time_t secs, long millisecs = 0)
{
- return InspIRCd::TimeString(t, "%Y-%m-%dT%H:%M:%S.000Z", true);
+ std::string timestr = InspIRCd::TimeString(secs, "%Y-%m-%dT%H:%M:%S.Z", true);
+ timestr.insert(20, InspIRCd::Format("%03ld", millisecs));
+ return timestr;
}
}
}