1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
15 #include "commands/cmd_whois.h"
16 #include "commands/cmd_stats.h"
19 #include "transport.h"
20 #include "socketengine.h"
22 #include "m_spanningtree/main.h"
23 #include "m_spanningtree/utils.h"
24 #include "m_spanningtree/treeserver.h"
25 #include "m_spanningtree/treesocket.h"
27 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
29 bool TreeSocket::Time(const std::string &prefix, std::deque<std::string> ¶ms)
31 // :source.server TIME remote.server sendernick
32 // :remote.server TIME source.server sendernick TS
33 if (params.size() == 2)
35 // someone querying our time?
36 if (this->ServerInstance->Config->ServerName == params[0] || this->ServerInstance->Config->GetSID() == params[0])
38 User* u = this->ServerInstance->FindNick(params[1]);
41 params.push_back(ConvToStr(ServerInstance->Time()));
43 Utils->DoOneToOne(this->ServerInstance->Config->GetSID(),"TIME",params,params[0]);
49 User* u = this->ServerInstance->FindNick(params[1]);
51 Utils->DoOneToOne(prefix,"TIME",params,params[0]);
54 else if (params.size() == 3)
56 // a response to a previous TIME
57 User* u = this->ServerInstance->FindNick(params[1]);
58 if ((u) && (IS_LOCAL(u)))
60 std::string sourceserv = Utils->FindServer(prefix)->GetName();
61 time_t rawtime = atol(params[2].c_str());
63 timeinfo = localtime(&rawtime);
65 snprintf(tms,26,"%s",asctime(timeinfo));
67 u->WriteNumeric(RPL_TIME, "%s %s :%s",u->nick.c_str(),sourceserv.c_str(),tms);
72 Utils->DoOneToOne(prefix,"TIME",params,u->server);