From 2fb9a1968c7c2886c9b79d97f981ecf395d37d1b Mon Sep 17 00:00:00 2001 From: Talyx Date: Thu, 3 Mar 2022 20:33:49 +0300 Subject: [PATCH] fix debug time --- src/Server/ServerConfig.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Server/ServerConfig.cpp b/src/Server/ServerConfig.cpp index 5029dcd..8ef2a44 100644 --- a/src/Server/ServerConfig.cpp +++ b/src/Server/ServerConfig.cpp @@ -22,17 +22,14 @@ std::string getDebugTime(void) { time_t rawtime; struct tm *timeinfo; + char buf[32]; time(&rawtime); timeinfo = localtime(&rawtime); - std::string ret = std::string(asctime(timeinfo)); - for (size_t i = 0; i < 3; i++) - { - ret.erase(0, ret.find(" ") + 1); - } - ret.erase(ret.find(" ")); - + int tmp = strftime(buf, 32, "%T", timeinfo); + buf[tmp] = '\0'; + std::string ret = std::string(buf); ret = std::string(WARNING) + "[ " + ret + " ] " + std::string(RESET) + std::string(OKCYAN);