Skip to content

Commit c96fae6

Browse files
committed
fix: use localtime_s on Windows for log timestamp
1 parent 3cb8078 commit c96fae6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/log.cppm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ std::string timestamp() {
7878
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
7979
now.time_since_epoch()) % 1000;
8080
std::tm tm{};
81+
#if defined(_WIN32)
82+
localtime_s(&tm, &tt);
83+
#else
8184
localtime_r(&tt, &tm);
85+
#endif
8286
char buf[32];
8387
std::snprintf(buf, sizeof(buf), "%04d-%02d-%02d %02d:%02d:%02d.%03d",
8488
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,

0 commit comments

Comments
 (0)