Changeset View
Changeset View
Standalone View
Standalone View
src/util/time.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
void MilliSleep(int64_t n) { | void MilliSleep(int64_t n) { | ||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(n)); | boost::this_thread::sleep_for(boost::chrono::milliseconds(n)); | ||||
} | } | ||||
std::string FormatISO8601DateTime(int64_t nTime) { | std::string FormatISO8601DateTime(int64_t nTime) { | ||||
struct tm ts; | struct tm ts; | ||||
time_t time_val = nTime; | time_t time_val = nTime; | ||||
#ifdef _MSC_VER | #ifdef _WIN32 | ||||
gmtime_s(&ts, &time_val); | gmtime_s(&ts, &time_val); | ||||
#else | #else | ||||
gmtime_r(&time_val, &ts); | gmtime_r(&time_val, &ts); | ||||
#endif | #endif | ||||
return strprintf("%04i-%02i-%02iT%02i:%02i:%02iZ", ts.tm_year + 1900, | 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_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, | ||||
ts.tm_sec); | ts.tm_sec); | ||||
} | } | ||||
std::string FormatISO8601Date(int64_t nTime) { | std::string FormatISO8601Date(int64_t nTime) { | ||||
struct tm ts; | struct tm ts; | ||||
time_t time_val = nTime; | time_t time_val = nTime; | ||||
#ifdef _MSC_VER | #ifdef _WIN32 | ||||
gmtime_s(&ts, &time_val); | gmtime_s(&ts, &time_val); | ||||
#else | #else | ||||
gmtime_r(&time_val, &ts); | gmtime_r(&time_val, &ts); | ||||
#endif | #endif | ||||
return strprintf("%04i-%02i-%02i", ts.tm_year + 1900, ts.tm_mon + 1, | return strprintf("%04i-%02i-%02i", ts.tm_year + 1900, ts.tm_mon + 1, | ||||
ts.tm_mday); | ts.tm_mday); | ||||
} | } |