Skip to content

Commit 4838452

Browse files
authored
Update libs/rtefsutils/src/RteFsUtils.cpp
1 parent 70fa79a commit 4838452

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

libs/rtefsutils/src/RteFsUtils.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,15 @@ std::string RteFsUtils::FileTimeToString(const fs::file_time_type& timeStamp) {
926926
auto sctp = std::chrono::time_point_cast<std::chrono::system_clock::duration>(
927927
timeStamp - fs::file_time_type::clock::now() + std::chrono::system_clock::now());
928928
std::time_t cftime = std::chrono::system_clock::to_time_t(sctp);
929-
strTime = std::asctime(std::localtime(&cftime));
929+
std::tm tm{};
930+
#if defined(_WIN32)
931+
localtime_s(&tm, &t); // Windows secure version
932+
#else
933+
localtime_r(&t, &tm); // POSIX thread-safe version
934+
#endif
935+
std::ostringstream oss;
936+
oss << std::put_time(&tm, "%Y-%m-%d %H:%M:%S");
937+
strTime = oss.str();
930938
}
931939
return strTime;
932940
}

0 commit comments

Comments
 (0)