From 3942b71e5ab61d6fa63b54f2997373a7c312eaff Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Tue, 19 Mar 2024 18:55:38 -0400 Subject: [PATCH] get rid of asctime -- it is unsafe (#2793) flagged by clang-tidy bugprone-unsafe-functions --- Source/driver/Castro_io.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/driver/Castro_io.cpp b/Source/driver/Castro_io.cpp index b002bf210e..e66a8b5ac9 100644 --- a/Source/driver/Castro_io.cpp +++ b/Source/driver/Castro_io.cpp @@ -574,11 +574,9 @@ Castro::writeJobInfo (const std::string& dir, const Real io_time) jobInfoFile << " Plotfile Information\n"; jobInfoFile << PrettyLine; - time_t now = time(nullptr); - - // Convert now to tm struct for local timezone - tm* localtm = localtime(&now); - jobInfoFile << "output date / time: " << asctime(localtm); + const std::time_t now = time(nullptr); + jobInfoFile << "output date / time: " + << std::put_time(std::localtime(&now), "%c\n") << "\n"; char currentDir[FILENAME_MAX]; if (getcwd(currentDir, FILENAME_MAX) != nullptr) {