From 819dd31c28e129ecab23eca01a50fa693e822997 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Tue, 19 Mar 2024 16:47:52 -0400 Subject: [PATCH] get rid of asctime -- it is unsafe --- Source/driver/Castro_io.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/driver/Castro_io.cpp b/Source/driver/Castro_io.cpp index b002bf210e..7289d09df1 100644 --- a/Source/driver/Castro_io.cpp +++ b/Source/driver/Castro_io.cpp @@ -574,11 +574,11 @@ 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); + char buf[64]; + if (strftime(buf, sizeof buf, "%c\n", std::localtime(&now))) { + jobInfoFile << "output date / time: " << buf << "\n"; + } char currentDir[FILENAME_MAX]; if (getcwd(currentDir, FILENAME_MAX) != nullptr) {