From 8ad775ad9cbff9d8e7c46be669faf32c1fa408e9 Mon Sep 17 00:00:00 2001 From: ChunelFeng Date: Sun, 17 Sep 2023 18:33:23 +0800 Subject: [PATCH] [os] support windows time stamp --- src/UtilsCtrl/UtilsFunction.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/UtilsCtrl/UtilsFunction.h b/src/UtilsCtrl/UtilsFunction.h index 89e6112a..45a571c3 100644 --- a/src/UtilsCtrl/UtilsFunction.h +++ b/src/UtilsCtrl/UtilsFunction.h @@ -33,22 +33,11 @@ inline CVoid CGRAPH_ECHO(const char *cmd, ...) { #endif std::lock_guard lock{ g_echo_mtx }; -#ifndef _WIN32 - // 非windows系统,打印到毫秒 auto now = std::chrono::system_clock::now(); auto time = std::chrono::system_clock::to_time_t(now); auto ms = std::chrono::duration_cast(now.time_since_epoch()).count() % 1000; std::cout << "[" << std::put_time(std::localtime(&time), "%Y-%m-%d %H:%M:%S.") \ << std::setfill('0') << std::setw(3) << ms << "] "; -#else - // windows系统,打印到秒 - time_t curTime; - time(&curTime); - std::string ct = ctime(&curTime); - std::cout << "[CGraph] [" - << ct.assign(ct.begin(), ct.end()-1) // 去掉时间的最后一位\n信息 - << "] "; -#endif va_list args; va_start(args, cmd); @@ -64,7 +53,7 @@ inline CVoid CGRAPH_ECHO(const char *cmd, ...) { */ inline CMSec CGRAPH_GET_CURRENT_MS() { // 获取当前的时间戳信息 - return std::chrono::time_point_cast \ + return (CMSec)std::chrono::time_point_cast \ (std::chrono::steady_clock::now()).time_since_epoch().count(); }