diff --git a/a8/sysutils.cc b/a8/sysutils.cc index 4076ac6..ef8603e 100644 --- a/a8/sysutils.cc +++ b/a8/sysutils.cc @@ -153,4 +153,14 @@ namespace a8 return std::string(buf); } + std::string FormatDateTime(time_t time_val) + { + struct tm tm_time = {0}; + localtime_r(&time_val, &tm_time); + + char buff[256]; + buff[0] = '\0'; + strftime(buff, a8::ArraySize(buff), "%F %T", &tm_time); + return std::string(buff); + } } diff --git a/a8/sysutils.h b/a8/sysutils.h index c4bcdc5..c910a13 100644 --- a/a8/sysutils.h +++ b/a8/sysutils.h @@ -63,6 +63,7 @@ namespace a8 bool MkDir(const std::string& path); void ForceCreateDir(const std::string& path); std::string GetIpAddress(unsigned long ip_saddr); + std::string FormatDateTime(time_t time_val); }