From 299f016b5dd946ea194fe770020e1e00d16e65e0 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 8 Oct 2021 13:15:48 +0200 Subject: [PATCH] Broaden condition on use of MS's localtime_s() It's available on MinGW, so not limited to MSVC; and the MinGW localtime() and localtime_r() fail in some cases where it works. Use the generic name rather than _localtime64_s(), since localtime_s() now just calls it; and, in any case, we were assuming time_t is __time64_t when calling it. Change-Id: I316cc5b1a3e19cd6725555042dfaba3124a25a03 Reviewed-by: Thiago Macieira --- src/corelib/time/qdatetime.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index cdfe0287d6..0d836fa936 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2619,8 +2619,8 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT Q_ASSERT(res == &local); valid = true; } -#elif defined(Q_CC_MSVC) - if (!_localtime64_s(&local, &secsSinceEpoch)) +#elif defined(Q_OS_WIN) + if (!localtime_s(&local, &secsSinceEpoch)) valid = true; #else // Returns shared static data which may be overwritten at any time