mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-05 15:26:19 +00:00
Fix server event timing
This commit is contained in:
@@ -11,35 +11,29 @@
|
||||
std::string GetDate() {
|
||||
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
|
||||
time_t tt = std::chrono::system_clock::to_time_t(now);
|
||||
tm local_tm {};
|
||||
#ifdef WIN32
|
||||
localtime_s(&local_tm, &tt);
|
||||
#else // unix
|
||||
localtime_r(&tt, &local_tm);
|
||||
#endif // WIN32
|
||||
std::stringstream date;
|
||||
int S = local_tm.tm_sec;
|
||||
int M = local_tm.tm_min;
|
||||
int H = local_tm.tm_hour;
|
||||
std::string Secs = (S > 9 ? std::to_string(S) : "0" + std::to_string(S));
|
||||
std::string Min = (M > 9 ? std::to_string(M) : "0" + std::to_string(M));
|
||||
std::string Hour = (H > 9 ? std::to_string(H) : "0" + std::to_string(H));
|
||||
date
|
||||
<< "["
|
||||
<< local_tm.tm_mday << "/"
|
||||
<< local_tm.tm_mon + 1 << "/"
|
||||
<< local_tm.tm_year + 1900 << " "
|
||||
<< Hour << ":"
|
||||
<< Min << ":"
|
||||
<< Secs
|
||||
<< "] ";
|
||||
/* TODO
|
||||
if (Debug) {
|
||||
date << ThreadName()
|
||||
<< " ";
|
||||
auto local_tm = std::localtime(&tt);
|
||||
char buf[30];
|
||||
std::string date;
|
||||
#if defined(DEBUG)
|
||||
if (Application::Settings.DebugModeEnabled) {
|
||||
std::strftime(buf, sizeof(buf), "[%d/%m/%y %T.", local_tm);
|
||||
date += buf;
|
||||
auto seconds = std::chrono::time_point_cast<std::chrono::seconds>(now);
|
||||
auto fraction = now - seconds;
|
||||
size_t ms = std::chrono::duration_cast<std::chrono::milliseconds>(fraction).count();
|
||||
char fracstr[5];
|
||||
std::sprintf(fracstr, "%0.3lu", ms);
|
||||
date += fracstr;
|
||||
date += "] ";
|
||||
} else {
|
||||
#endif
|
||||
std::strftime(buf, sizeof(buf), "[%d/%m/%y %T] ", local_tm);
|
||||
date += buf;
|
||||
#if defined(DEBUG)
|
||||
}
|
||||
*/
|
||||
return date.str();
|
||||
#endif
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
void TConsole::BackupOldLog() {
|
||||
|
||||
Reference in New Issue
Block a user