diff options
author | Jose <pepone@users.noreply.github.com> | 2021-01-01 15:59:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-01 15:59:04 +0100 |
commit | 41d195922ab07220a002cb8072ab28f22c4287d2 (patch) | |
tree | 45d14eba345024657e04b4b2378542163351bc3b /cpp/src/IceUtil/Time.cpp | |
parent | Add /node_modules to test HTTP server paths (diff) | |
download | ice-41d195922ab07220a002cb8072ab28f22c4287d2.tar.bz2 ice-41d195922ab07220a002cb8072ab28f22c4287d2.tar.xz ice-41d195922ab07220a002cb8072ab28f22c4287d2.zip |
Fix localtime/gmtime usage (#1227)
* Prefer the reentrant versions of localtime/gmtime when available
* Simplify pragmas
* Review comment fixes
* Remove comment
Diffstat (limited to 'cpp/src/IceUtil/Time.cpp')
-rw-r--r-- | cpp/src/IceUtil/Time.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/cpp/src/IceUtil/Time.cpp b/cpp/src/IceUtil/Time.cpp index bac201a055d..68d775d0a9a 100644 --- a/cpp/src/IceUtil/Time.cpp +++ b/cpp/src/IceUtil/Time.cpp @@ -280,17 +280,15 @@ IceUtil::Time::toString(const std::string& format) const { time_t time = static_cast<long>(_usec / 1000000); - struct tm* t; -#ifdef _WIN32 - t = localtime(&time); -#else struct tm tr; +#ifdef _MSC_VER + localtime_s(&tr, &time); +#else localtime_r(&time, &tr); - t = &tr; #endif char buf[32]; - if(strftime(buf, sizeof(buf), format.c_str(), t) == 0) + if(strftime(buf, sizeof(buf), format.c_str(), &tr) == 0) { return std::string(); } |