diff options
author | Peter Powell <petpow@saberuk.com> | 2013-05-06 11:49:50 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2013-05-15 03:32:56 +0100 |
commit | accccc212cd4f08a3c5532b1ae7a17e76bac8718 (patch) | |
tree | 18f4370778cc79d2f21a4308dafbb29a77cfa213 /src/commands/cmd_time.cpp | |
parent | 23e8bba13c55d33ce89d505780da36c9589e300a (diff) |
Replace some C-isms with C++-isms.
* 'const char*' to 'const std::string&'.
* snprintf to std::string concatenation.
* Replace duplicated OneOfMatches with InspIRCd::MatchMask.
Diffstat (limited to 'src/commands/cmd_time.cpp')
-rw-r--r-- | src/commands/cmd_time.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/commands/cmd_time.cpp b/src/commands/cmd_time.cpp index db452d381..8c516ac42 100644 --- a/src/commands/cmd_time.cpp +++ b/src/commands/cmd_time.cpp @@ -50,16 +50,13 @@ CmdResult CommandTime::Handle (const std::vector<std::string>& parameters, User { if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName) return CMD_SUCCESS; - struct tm* timeinfo; - time_t local = ServerInstance->Time(); - - timeinfo = localtime(&local); - char tms[26]; - snprintf(tms,26,"%s",asctime(timeinfo)); - tms[24] = 0; + 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(),tms); + 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()); return CMD_SUCCESS; } |