mirror of
https://github.com/google/googletest.git
synced 2025-12-06 16:57:00 +08:00
Merge 666a7e47a3e251a732fe2ec7ee4e39514df0ae1f into 1b96fa13f549387b7549cc89e1a785cf143a1a50
This commit is contained in:
commit
6a6e91e016
@ -2376,4 +2376,32 @@ using StringView = ::std::string_view;
|
|||||||
#define GTEST_INTERNAL_HAS_COMPARE_LIB 0
|
#define GTEST_INTERNAL_HAS_COMPARE_LIB 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef GTEST_INTERNAL_LOCALTIME_
|
||||||
|
#include <time.h> // NOLINT
|
||||||
|
namespace testing {
|
||||||
|
namespace internal {
|
||||||
|
inline bool LocalTime(time_t seconds, struct tm* out) {
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
return localtime_s(out, &seconds) == 0;
|
||||||
|
#elif defined(__MINGW32__) || defined(__MINGW64__)
|
||||||
|
// MINGW <time.h> provides neither localtime_r nor localtime_s, but uses
|
||||||
|
// Windows' localtime(), which has a thread-local tm buffer.
|
||||||
|
struct tm* tm_ptr = localtime(&seconds); // NOLINT
|
||||||
|
if (tm_ptr == nullptr) return false;
|
||||||
|
*out = *tm_ptr;
|
||||||
|
return true;
|
||||||
|
#elif defined(__STDC_LIB_EXT1__)
|
||||||
|
// Uses localtime_s when available as localtime_r is only available from
|
||||||
|
// C23 standard.
|
||||||
|
return localtime_s(&seconds, out) != nullptr;
|
||||||
|
#else
|
||||||
|
return localtime_r(&seconds, out) != nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace testing
|
||||||
|
#endif // GTEST_INTERNAL_LOCALTIME_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||||
|
|||||||
@ -4170,22 +4170,7 @@ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool PortableLocaltime(time_t seconds, struct tm* out) {
|
static bool PortableLocaltime(time_t seconds, struct tm* out) {
|
||||||
#if defined(_MSC_VER)
|
return internal::LocalTime(seconds, out);
|
||||||
return localtime_s(out, &seconds) == 0;
|
|
||||||
#elif defined(__MINGW32__) || defined(__MINGW64__)
|
|
||||||
// MINGW <time.h> provides neither localtime_r nor localtime_s, but uses
|
|
||||||
// Windows' localtime(), which has a thread-local tm buffer.
|
|
||||||
struct tm* tm_ptr = localtime(&seconds); // NOLINT
|
|
||||||
if (tm_ptr == nullptr) return false;
|
|
||||||
*out = *tm_ptr;
|
|
||||||
return true;
|
|
||||||
#elif defined(__STDC_LIB_EXT1__)
|
|
||||||
// Uses localtime_s when available as localtime_r is only available from
|
|
||||||
// C23 standard.
|
|
||||||
return localtime_s(&seconds, out) != nullptr;
|
|
||||||
#else
|
|
||||||
return localtime_r(&seconds, out) != nullptr;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts the given epoch time in milliseconds to a date string in the ISO
|
// Converts the given epoch time in milliseconds to a date string in the ISO
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user