]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_info/cmd_time.cpp
core_whois Fix numeric 319 not obeying MaxLine
[user/henk/code/inspircd.git] / src / coremods / core_info / cmd_time.cpp
index 9c4688029767624435a3cea6cfb0bdd735587246..95cfb12fddc5bcb0c2034359f2fc0b7e7fff457e 100644 (file)
 
 
 #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;
+}