Skip to content

Commit

Permalink
Merge pull request #2398 from jamescowens/fix_backupwallet
Browse files Browse the repository at this point in the history
Fix breakage introduced by use of FormatISO8601DateTime
  • Loading branch information
jamescowens authored Nov 27, 2021
2 parents 088e0f3 + 3bdec99 commit 319a234
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gridcoin/backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ std::string GRC::GetBackupFilename(const std::string& basename, const std::strin
{
std::string sBackupFilename;
fs::path rpath;
sBackupFilename = basename + "-" + std::string(FormatISO8601DateTime(GetTime()));
sBackupFilename = basename + "-" + std::string(FormatISO8601DateTimeDashSep(GetTime()));
if (!suffix.empty())
sBackupFilename = sBackupFilename + "-" + suffix;
rpath = GetBackupPath() / sBackupFilename;
Expand Down
13 changes: 13 additions & 0 deletions src/util/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ std::string FormatISO8601DateTime(int64_t nTime) {
return strprintf("%04i-%02i-%02iT%02i:%02i:%02iZ", ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec);
}

std::string FormatISO8601DateTimeDashSep(int64_t nTime) {
struct tm ts;
time_t time_val = nTime;
#ifdef HAVE_GMTIME_R
if (gmtime_r(&time_val, &ts) == nullptr) {
#else
if (gmtime_s(&ts, &time_val) != 0) {
#endif
return {};
}
return strprintf("%04i-%02i-%02iT%02i-%02i-%02iZ", ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec);
}

std::string FormatISO8601Date(int64_t nTime) {
struct tm ts;
time_t time_val = nTime;
Expand Down
1 change: 1 addition & 0 deletions src/util/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ T GetTime();
* helper functions if possible.
*/
std::string FormatISO8601DateTime(int64_t nTime);
std::string FormatISO8601DateTimeDashSep(int64_t nTime);
std::string FormatISO8601Date(int64_t nTime);
int64_t ParseISO8601DateTime(const std::string& str);

Expand Down

0 comments on commit 319a234

Please sign in to comment.