Skip to content

Commit

Permalink
get rid of asctime -- it is unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Mar 19, 2024
1 parent ae7a061 commit 819dd31
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Source/driver/Castro_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 819dd31

Please sign in to comment.