From ec57c7545db209f26a31852d64a854824198372f Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 5 Feb 2025 11:21:34 +0000 Subject: [PATCH] Move RPL_TIME to the numeric header, unify TIME and ALLTIME. --- include/numeric.h | 1 + src/coremods/core_info/cmd_time.cpp | 10 +++------- src/modules/m_alltime.cpp | 9 +++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/include/numeric.h b/include/numeric.h index fad86e316..78d7cd7b6 100644 --- a/include/numeric.h +++ b/include/numeric.h @@ -32,6 +32,7 @@ enum RPL_VERSION = 351, RPL_LINKS = 364, RPL_ENDOFLINKS = 365, + RPL_TIME = 391, ERR_NOSUCHNICK = 401, ERR_NOSUCHCHANNEL = 403, ERR_NORECIPIENT = 411, diff --git a/src/coremods/core_info/cmd_time.cpp b/src/coremods/core_info/cmd_time.cpp index deaf7f8ef..d1aa02246 100644 --- a/src/coremods/core_info/cmd_time.cpp +++ b/src/coremods/core_info/cmd_time.cpp @@ -28,12 +28,6 @@ #include "core_info.h" -enum -{ - // From RFC 1459. - RPL_TIME = 391, -}; - CommandTime::CommandTime(Module* parent) : ServerTargetCommand(parent, "TIME") { @@ -45,7 +39,9 @@ CmdResult CommandTime::Handle(User* user, const Params& parameters) if (!parameters.empty() && !irc::equals(parameters[0], ServerInstance->Config->ServerName)) return CmdResult::SUCCESS; - const auto timestr = Time::ToString(ServerInstance->Time(), "%A, %d %b %Y %H:%M:%S %Z"); + auto timestr = Time::ToString(ServerInstance->Time(), "%A, %d %B %Y @ %H:%M:%S %Z"); + timestr += INSP_FORMAT(" ({})", ServerInstance->Time()); + user->WriteRemoteNumeric(RPL_TIME, ServerInstance->Config->GetServerName(), timestr); return CmdResult::SUCCESS; } diff --git a/src/modules/m_alltime.cpp b/src/modules/m_alltime.cpp index 741e7ac06..fadb325f4 100644 --- a/src/modules/m_alltime.cpp +++ b/src/modules/m_alltime.cpp @@ -37,13 +37,10 @@ public: CmdResult Handle(User* user, const Params& parameters) override { - const std::string fmtdate = Time::ToString(ServerInstance->Time(), "%Y-%m-%d %H:%M:%S", true); + auto timestr = Time::ToString(ServerInstance->Time(), "%A, %d %B %Y @ %H:%M:%S %Z", true); + timestr += INSP_FORMAT(" ({})", ServerInstance->Time()); - std::string msg = "System time is " + fmtdate + " (" + ConvToStr(ServerInstance->Time()) + ") on " + ServerInstance->Config->ServerName; - - user->WriteRemoteNotice(msg); - - /* we want this routed out! */ + user->WriteRemoteNumeric(RPL_TIME, ServerInstance->Config->ServerName, timestr); return CmdResult::SUCCESS; }