From 9cdabec265f161cdec2eb7566b1770a2dfac5fff Mon Sep 17 00:00:00 2001 From: barton26 Date: Thu, 9 Sep 2021 17:29:21 -0400 Subject: [PATCH] Don't use localtime() Co-Authored-By: James C. Owens --- src/gridcoin/backup.cpp | 10 +++------- src/rpc/rawtransaction.cpp | 9 +-------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/gridcoin/backup.cpp b/src/gridcoin/backup.cpp index 8d926f0664..dc818ae84f 100644 --- a/src/gridcoin/backup.cpp +++ b/src/gridcoin/backup.cpp @@ -9,6 +9,8 @@ #include "util.h" #include "util/time.h" +#include + #include using namespace GRC; @@ -21,15 +23,9 @@ fs::path GRC::GetBackupPath() std::string GRC::GetBackupFilename(const std::string& basename, const std::string& suffix) { - time_t biTime; - struct tm * blTime; - time (&biTime); - blTime = localtime(&biTime); - char boTime[200]; - strftime(boTime, sizeof(boTime), "%Y-%m-%dT%H-%M-%S", blTime); std::string sBackupFilename; fs::path rpath; - sBackupFilename = basename + "-" + std::string(boTime); + sBackupFilename = basename + "-" + std::string(FormatISO8601DateTime(GetTime())); if (!suffix.empty()) sBackupFilename = sBackupFilename + "-" + suffix; rpath = GetBackupPath() / sBackupFilename; diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index a30c20d4ae..59b3dfabfe 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1407,14 +1407,7 @@ UniValue scanforunspent(const UniValue& params, bool fHelp) // We will place this in wallet backups as a safer location then in main data directory fs::path exportpath; - time_t biTime; - struct tm * blTime; - time (&biTime); - blTime = localtime(&biTime); - char boTime[200]; - strftime(boTime, sizeof(boTime), "%Y-%m-%dT%H-%M-%S", blTime); - - std::string exportfile = params[0].get_str() + "-" + std::string(boTime) + "." + params[4].get_str(); + std::string exportfile = params[0].get_str() + "-" + std::string(FormatISO8601DateTime(GetTime())) + "." + params[4].get_str(); std::string backupdir = gArgs.GetArg("-backupdir", "");