#include "inspircd.h"
+#include "core_info.h"
-/** Handle /TIME.
- */
-class CommandTime : public Command
+CommandTime::CommandTime(Module* parent)
+ : Command(parent, "TIME", 0, 0)
{
- public:
- /** Constructor for time.
- */
- CommandTime ( Module* parent) : Command(parent,"TIME",0,0) { syntax = "[<servername>]"; }
- /** Handle command.
- * @param parameters The parameters to the command
- * @param user The user issuing the command
- * @return A value from CmdResult to indicate command success or failure.
- */
- CmdResult Handle(const std::vector<std::string>& parameters, User *user);
- RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
- {
- if (parameters.size() > 0)
- return ROUTE_UNICAST(parameters[0]);
- return ROUTE_LOCALONLY;
- }
-};
+ syntax = "[<servername>]";
+}
CmdResult CommandTime::Handle (const std::vector<std::string>& parameters, User *user)
{
if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
return CMD_SUCCESS;
- time_t local = ServerInstance->Time();
- struct tm* timeinfo = localtime(&local);
- const std::string& humanTime = asctime(timeinfo);
-
user->SendText(":%s %03d %s %s :%s", ServerInstance->Config->ServerName.c_str(), RPL_TIME, user->nick.c_str(),
- ServerInstance->Config->ServerName.c_str(), humanTime.c_str());
+ ServerInstance->Config->ServerName.c_str(), InspIRCd::TimeString(ServerInstance->Time()).c_str());
return CMD_SUCCESS;
}
-COMMAND_INIT(CommandTime)
+RouteDescriptor CommandTime::GetRouting(User* user, const std::vector<std::string>& parameters)
+{
+ if (parameters.size() > 0)
+ return ROUTE_UNICAST(parameters[0]);
+ return ROUTE_LOCALONLY;
+}