From 26c6a8811b93c2dae412bd238af0aaf2b28b2328 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 4 Jan 2023 19:46:53 +0000 Subject: Allow specifying milliseconds and a timespec in the server-time API. --- include/modules/ircv3_servertime.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'include/modules') diff --git a/include/modules/ircv3_servertime.h b/include/modules/ircv3_servertime.h index 3f7f20d7c..c5cc7b2b2 100644 --- a/include/modules/ircv3_servertime.h +++ b/include/modules/ircv3_servertime.h @@ -63,11 +63,21 @@ public: /** Set the server time on a message. * @param msg Message to set the time on. No-op if the message already has server time set. - * @param t Unix timestamp to set. + * @param ts Timestamp to set. */ - void Set(ClientProtocol::Message& msg, time_t t) + void Set(ClientProtocol::Message& msg, const timespec& ts) { - Set(msg, FormatTime(t)); + Set(msg, FormatTime(ts.tv_sec, ts.tv_nsec / 1'000'000)); + } + + /** Set the server time on a message. + * @param msg Message to set the time on. No-op if the message already has server time set. + * @param secs UNIX timestamp to set. + * @param millisecs Number of milliseconds to set. + */ + void Set(ClientProtocol::Message& msg, time_t secs, long millisecs = 0) + { + Set(msg, FormatTime(secs, millisecs)); } /** Set the server time on a message. -- cgit v1.3.1-10-gc9f91