aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4dateobject.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2013-10-10 14:17:04 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-31 16:01:21 +0100
commitce3e8f93c3a4d5f89b371b9e3598c8e39d4c12e4 (patch)
treed44c13f750b8c08edc0d9f37627280999ab755f9 /src/qml/jsruntime/qv4dateobject.cpp
parentb566c9121c066669a88f01143034078ae0cccc90 (diff)
Fix compilation with Mingw.org headers
Mingw.org (gcc 4.7.2) does not provide an implementation of localtime_r. Anyhow, the localtime() in the Windows runtime is thread safe, so we can use localtime() instead. Change-Id: I387e0dcc22e519777fa9ceb9ad6a8b030d0438c1 Task-number: QTBUG-34038 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4dateobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index cfc4843ec9..688730af9b 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -295,6 +295,13 @@ static inline double DaylightSavingTA(double t)
__time64_t tt = (__time64_t)(t / msPerSecond);
// _localtime_64_s returns non-zero on failure
if (_localtime64_s(&tmtm, &tt) != 0)
+#elif defined(Q_CC_MINGW) && !defined(__MINGW64_VERSION_MAJOR)
+ // mingw.org headers do not define localtime_r.
+ // luckily Windows localtime() is thread safe.
+ long int tt = (long int)(t / msPerSecond);
+ if (struct tm *tmtm_p = localtime((const time_t*) &tt))
+ tmtm = *tmtm_p;
+ else
#else
long int tt = (long int)(t / msPerSecond);
if (!localtime_r((const time_t*) &tt, &tmtm))