Skip to content

Commit

Permalink
get rid of asctime -- it is unsafe (#2793)
Browse files Browse the repository at this point in the history
flagged by clang-tidy bugprone-unsafe-functions
  • Loading branch information
zingale authored Mar 19, 2024
1 parent ae7a061 commit 3942b71
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Source/driver/Castro_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3942b71

Please sign in to comment.