diff options
author | Jeff Cohen <jeffc@jolt-lang.org> | 2004-12-15 04:28:44 +0000 |
---|---|---|
committer | Jeff Cohen <jeffc@jolt-lang.org> | 2004-12-15 04:28:44 +0000 |
commit | 003485a0b3705ca86b17411e32956f7df3282c20 (patch) | |
tree | e41c79d602ee8a8a492c4c13f9b057a8f2c2258b /lib/System/Win32/TimeValue.cpp | |
parent | ab68df02bc29045b9f02783518fbc7d0f23f56b7 (diff) |
Make Win32 TimeValue::toString() re-entrant and work with mingw
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18954 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32/TimeValue.cpp')
-rw-r--r-- | lib/System/Win32/TimeValue.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/System/Win32/TimeValue.cpp b/lib/System/Win32/TimeValue.cpp index f45662948b..de8f267089 100644 --- a/lib/System/Win32/TimeValue.cpp +++ b/lib/System/Win32/TimeValue.cpp @@ -31,13 +31,17 @@ TimeValue TimeValue::now() { } std::string TimeValue::toString() const { - // Alas, asctime is not re-entrant on Windows... - +#ifdef __MINGW + time_t ourTime = time_t(this->toEpochTime()); + struct tm *lt = ::localtime(&ourTime); +#else __time64_t ourTime = this->toEpochTime(); - char* buffer = ::asctime(::_localtime64(&ourTime)); + struct tm *lt = ::_localtime64(&ourTime); +#endif - std::string result(buffer); - return result.substr(0,24); + char buffer[25]; + strftime(buffer, 25, "%a %b %d %H:%M:%S %Y", lt); + return std::string(buffer); } // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab |