summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@jollamobile.com>2014-05-16 15:11:39 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-16 19:20:01 +0200
commitcfcbb957c7ee85decee3379d8876a7b4094ae501 (patch)
treec615a018c98ea2e3074f22dbb175692270c531f9 /src/corelib/tools
parent102cec7ec03822243d9cb99763a0c02f9a13351d (diff)
Call tzset() before localtime_r() as the docs say.
Without it, one might run the risk of QDateTime::currentDateTime() returning an invalid QDateTime the first time after changing timezone. Change-Id: I3efb04d41e7fe4685f6cc5fb41b68424eb4b9eb8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qdatetime.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 801876629c..d6f1d6c942 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -2405,6 +2405,9 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT
local.tm_year = sysTime.wYear - 1900;
}
#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+ // localtime() is required to work as if tzset() was called before it.
+ // localtime_r() does not have this requirement, so make an explicit call.
+ qt_tzset();
// Use the reentrant version of localtime() where available
// as is thread-safe and doesn't use a shared static data area
tm *res = 0;