Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix breakage introduced by use of FormatISO8601DateTime #2398

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
jamescowens marked this conversation as resolved.
Show resolved Hide resolved
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