summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2013-03-03 15:06:40 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-05 21:56:52 +0100
commit56820382f26069ea81444da075e6cbefc8f03765 (patch)
treea48277c4cf18a768608e62454d9364501c09c221 /src/corelib
parent4f60ff6ad3e89696cfe9550b0e05de779163d677 (diff)
Workaround a bug in mktime on QNX
Under certain circumstances, mktime failes to convert the tm struct into secs since epoch. This is a workaround and fixes the qdatetime and qqmllocale autotests. Change-Id: If99385142a049c5315429dca177df7fc8e947d55 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Wolfgang Bremer <wbremer@rim.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qdatetime.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 4b6e739759..88f22daad5 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -4050,6 +4050,16 @@ static void localToUtc(QDate &date, QTime &time, int isdst)
_tzset();
#endif
time_t secsSince1Jan1970UTC = mktime(&localTM);
+#ifdef Q_OS_QNX
+ //mktime sometimes fails on QNX. Following workaround converts the date and time then manually
+ if (secsSince1Jan1970UTC == (time_t)-1) {
+ QDateTime tempTime = QDateTime(date, time, Qt::UTC);;
+ tempTime = tempTime.addMSecs(timezone * 1000);
+ date = tempTime.date();
+ time = tempTime.time();
+ return;
+ }
+#endif
#endif
tm *brokenDown = 0;
#if defined(Q_OS_WINCE)