Move RPL_TIME to the numeric header, unify TIME and ALLTIME.

This commit is contained in:
Sadie Powell 2025-02-05 11:21:34 +00:00
parent af8b171ccf
commit ec57c7545d
3 changed files with 7 additions and 13 deletions

View File

@ -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,

View File

@ -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;
}

View File

@ -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;
}